Expose version property for `CustomVersioningPolicy` so that it may serialize/deserialize correctly (#4747)

Expose version property for  so that it may serialize/deserialize correctly

Expose version property for `CustomVersioningPolicy` so that it may serialize/deserialize correctly

Expose version property for CustomVersioningPolicy so that it may serialize/deserialize correctly

Expose version property for `CustomVersioningPolicy` so that it may serialize/deserialize correctly
This commit is contained in:
Kevin Conaway 2017-09-03 16:36:18 -04:00 committed by Gian Merlino
parent 06ac6678e6
commit 83e94e8b31
2 changed files with 54 additions and 0 deletions

View File

@ -43,4 +43,10 @@ public class CustomVersioningPolicy implements VersioningPolicy
{ {
return version; return version;
} }
@JsonProperty("version")
public String getVersion()
{
return version;
}
} }

View File

@ -0,0 +1,48 @@
/*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.druid.segment.realtime.plumber;
import io.druid.TestUtil;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Interval;
import org.junit.Assert;
import org.junit.Test;
public class CustomVersioningPolicyTest
{
@Test
public void testSerialization() throws Exception
{
Interval interval = new Interval(DateTime.now(DateTimeZone.UTC), DateTime.now(DateTimeZone.UTC));
String version = "someversion";
CustomVersioningPolicy policy = new CustomVersioningPolicy(version);
CustomVersioningPolicy serialized = TestUtil.MAPPER.readValue(
TestUtil.MAPPER.writeValueAsBytes(policy),
CustomVersioningPolicy.class
);
Assert.assertEquals(version, policy.getVersion(interval));
Assert.assertEquals(version, serialized.getVersion(interval));
}
}