use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext in project druid by druid-io.
the class WorkerBehaviorConfigTest method testSerde.
@Test
public void testSerde() throws Exception {
WorkerBehaviorConfig config = new WorkerBehaviorConfig(new FillCapacityWithAffinityWorkerSelectStrategy(new FillCapacityWithAffinityConfig(ImmutableMap.of("foo", Arrays.asList("localhost")))), new EC2AutoScaler(7, 11, new EC2EnvironmentConfig("us-east-1a", new EC2NodeData("amiid", "instanceType", 3, 5, Arrays.asList("securityGroupIds"), "keyNames", "subnetId", null, null), new StringEC2UserData("availZone", "replace", "version")), null, null));
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues() {
@Override
public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) {
return null;
}
});
Assert.assertEquals(config, mapper.readValue(mapper.writeValueAsBytes(config), WorkerBehaviorConfig.class));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext in project druid by druid-io.
the class EC2AutoScalerSerdeTest method testSerde.
@Test
public void testSerde() throws Exception {
final ObjectMapper objectMapper = new DefaultObjectMapper();
objectMapper.setInjectableValues(new InjectableValues() {
@Override
public Object findInjectableValue(Object o, DeserializationContext deserializationContext, BeanProperty beanProperty, Object o1) {
return null;
}
});
final EC2AutoScaler autoScaler = objectMapper.readValue(json, EC2AutoScaler.class);
verifyAutoScaler(autoScaler);
final EC2AutoScaler roundTripAutoScaler = objectMapper.readValue(objectMapper.writeValueAsBytes(autoScaler), EC2AutoScaler.class);
verifyAutoScaler(roundTripAutoScaler);
Assert.assertEquals("Round trip equals", autoScaler, roundTripAutoScaler);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext in project java-chassis by ServiceComb.
the class TestAbstractDeserializer method testDeserialize.
@SuppressWarnings("unchecked")
@Test
public void testDeserialize() {
boolean status = false;
try {
DeserializationContext ctxt = Mockito.mock(DeserializationContext.class);
@SuppressWarnings("rawtypes") JsonDeserializer JsonDeserializer = Mockito.mock(JsonDeserializer.class);
Object object = null;
Mockito.when(jsonParser.nextFieldName()).thenReturn("abc", (String) null);
Mockito.when(readerHelpData.getDeser()).thenReturn(JsonDeserializer);
Mockito.when(JsonDeserializer.deserialize(jsonParser, ctxt)).thenReturn(object);
Object deserializeObject = abstractDeserializer.deserialize(jsonParser, ctxt);
Assert.assertNotNull(deserializeObject);
} catch (Exception e) {
status = true;
}
Assert.assertFalse(status);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext in project cyclops by aol.
the class IterableXDeserializer method deserialize.
@Override
public IterableX<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonDeserializer deser = ctxt.findRootValueDeserializer(ctxt.getTypeFactory().constructArrayType(Object.class));
Object o = deser.deserialize(p, ctxt);
if (Vector.class.isAssignableFrom(elementType))
return Vector.of((Object[]) o);
if (Seq.class.isAssignableFrom(elementType))
return Seq.of((Object[]) o);
if (LazySeq.class.isAssignableFrom(elementType))
return LazySeq.of((Object[]) o);
if (LazyString.class.isAssignableFrom(elementType))
return LazyString.fromLazySeq((LazySeq) LazySeq.of((Object[]) o));
if (IntMap.class.isAssignableFrom(elementType))
return IntMap.of((Object[]) o);
if (ReactiveSeq.class.isAssignableFrom(elementType))
return ReactiveSeq.of((Object[]) o);
if (Streamable.class.isAssignableFrom(elementType))
return Streamable.of((Object[]) o);
if (BankersQueue.class.isAssignableFrom(elementType))
return BankersQueue.of((Object[]) o);
if (Bag.class.isAssignableFrom(elementType))
return Bag.of((Object[]) o);
if (cyclops.data.HashSet.class.isAssignableFrom(elementType))
return HashSet.of((Object[]) o);
if (cyclops.data.TrieSet.class.isAssignableFrom(elementType))
return TrieSet.of((Object[]) o);
if (cyclops.data.TreeSet.class.isAssignableFrom(elementType))
return TreeSet.of((Comparator) Comparator.naturalOrder(), (Object[]) o);
Optional<Method> m = streamMethod.computeIfAbsent(itX, c -> Stream.of(c.getMethods()).filter(method -> "of".equals(method.getName())).filter(method -> method.getParameterCount() == 1).filter(method -> method.getParameterTypes()[0].isArray()).findFirst().map(m2 -> {
m2.setAccessible(true);
return m2;
}));
IterableX x = m.map(mt -> (IterableX) new Invoker().executeMethod(o, mt, itX)).orElse(null);
return x;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext in project cyclops by aol.
the class PersistentMapDeserializer method deserialize.
@Override
public PersistentMap<?, ?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonDeserializer deser = ctxt.findRootValueDeserializer(ctxt.getTypeFactory().constructRawMapType(Map.class));
Object o = deser.deserialize(p, ctxt);
if (HashMap.class.isAssignableFrom(mapType))
return HashMap.fromMap((Map) o);
if (TreeMap.class.isAssignableFrom(mapType))
return TreeMap.fromMap((Comparator) Comparator.naturalOrder(), (Map) o);
/**
* if(TrieMap.class.isAssignableFrom(mapType))
* return TrieMap.fromMap((Map)o);
* if(LinkedMap.class.isAssignableFrom(mapType))
* return LinkedMap.fromMap((Map)o);
*/
Optional<Method> m = streamMethod.computeIfAbsent(mapType, c -> Stream.of(c.getMethods()).filter(method -> "fromMap".equals(method.getName())).filter(method -> method.getParameterCount() == 1).filter(method -> method.getParameterTypes()[0].isAssignableFrom(Map.class)).findFirst().map(m2 -> {
m2.setAccessible(true);
return m2;
}));
PersistentMap<?, ?> x = m.map(mt -> (PersistentMap) new PersistentMapDeserializer.Invoker().executeMethod(o, mt, mapType)).orElse(null);
return x;
}
Aggregations