use of com.fasterxml.jackson.databind.BeanProperty in project torodb by torodb.
the class AbstractBackendSerializer method depositSchemaProperty.
private void depositSchemaProperty(JsonObjectFormatVisitor v, String name, JavaType type) throws JsonMappingException {
BeanProperty prop = new BeanProperty.Std(PropertyName.construct(name), type, null, null, null, PropertyMetadata.STD_OPTIONAL) {
@Override
public void depositSchemaProperty(JsonObjectFormatVisitor v) {
try {
if (v != null) {
if (isRequired()) {
v.property(this);
} else {
v.optionalProperty(this);
}
}
} catch (JsonMappingException jsonMappingException) {
throw new RuntimeException(jsonMappingException);
}
}
};
prop.depositSchemaProperty(v);
}
use of com.fasterxml.jackson.databind.BeanProperty in project druid by druid-io.
the class GceAutoScalerTest method testConfig.
@Test
public void testConfig() {
final String json = "{\n" + " \"envConfig\" : {\n" + " \"numInstances\" : 1,\n" + " \"projectId\" : \"super-project\",\n" + " \"zoneName\" : \"winkie-country\",\n" + " \"managedInstanceGroupName\" : \"druid-mig\"\n" + " },\n" + " \"maxNumWorkers\" : 4,\n" + " \"minNumWorkers\" : 2,\n" + " \"type\" : \"gce\"\n" + "}";
final ObjectMapper objectMapper = new DefaultObjectMapper().registerModules((Iterable<Module>) new GceModule().getJacksonModules());
objectMapper.setInjectableValues(new InjectableValues() {
@Override
public Object findInjectableValue(Object o, DeserializationContext deserializationContext, BeanProperty beanProperty, Object o1) {
return null;
}
});
try {
final GceAutoScaler autoScaler = (GceAutoScaler) objectMapper.readValue(json, AutoScaler.class);
verifyAutoScaler(autoScaler);
final GceAutoScaler roundTripAutoScaler = (GceAutoScaler) objectMapper.readValue(objectMapper.writeValueAsBytes(autoScaler), AutoScaler.class);
verifyAutoScaler(roundTripAutoScaler);
Assert.assertEquals("Round trip equals", autoScaler, roundTripAutoScaler);
} catch (Exception e) {
Assert.fail(StringUtils.format("Got exception in test %s", e.getMessage()));
}
}
use of com.fasterxml.jackson.databind.BeanProperty in project druid by druid-io.
the class WorkerBehaviorConfigTest method testSerde.
@Test
public void testSerde() throws Exception {
DefaultWorkerBehaviorConfig config = new DefaultWorkerBehaviorConfig(new FillCapacityWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false)), new EC2AutoScaler(7, 11, new EC2EnvironmentConfig("us-east-1a", new EC2NodeData("amiid", "instanceType", 3, 5, Collections.singletonList("securityGroupIds"), "keyNames", "subnetId", null, null), new StringEC2UserData("availZone", "replace", "version")), null, null));
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.registerSubtypes(EC2AutoScaler.class);
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), DefaultWorkerBehaviorConfig.class));
}
use of com.fasterxml.jackson.databind.BeanProperty in project druid by druid-io.
the class EC2AutoScalerSerdeTest method testSerde.
@Test
public void testSerde() throws Exception {
final ObjectMapper objectMapper = new DefaultObjectMapper().registerModules((Iterable<Module>) new EC2Module().getJacksonModules());
objectMapper.setInjectableValues(new InjectableValues() {
@Override
public Object findInjectableValue(Object o, DeserializationContext deserializationContext, BeanProperty beanProperty, Object o1) {
return null;
}
});
final EC2AutoScaler autoScaler = (EC2AutoScaler) objectMapper.readValue(json, AutoScaler.class);
verifyAutoScaler(autoScaler);
final EC2AutoScaler roundTripAutoScaler = (EC2AutoScaler) objectMapper.readValue(objectMapper.writeValueAsBytes(autoScaler), AutoScaler.class);
verifyAutoScaler(roundTripAutoScaler);
Assert.assertEquals("Round trip equals", autoScaler, roundTripAutoScaler);
}
use of com.fasterxml.jackson.databind.BeanProperty in project beam by apache.
the class PipelineOptionsFactory method computeDeserializerForMethod.
private static JsonDeserializer<Object> computeDeserializerForMethod(Method method) {
try {
BeanProperty prop = createBeanProperty(method);
AnnotatedMember annotatedMethod = prop.getMember();
DefaultDeserializationContext context = DESERIALIZATION_CONTEXT.get();
Object maybeDeserializerClass = context.getAnnotationIntrospector().findDeserializer(annotatedMethod);
JsonDeserializer<Object> jsonDeserializer = context.deserializerInstance(annotatedMethod, maybeDeserializerClass);
if (jsonDeserializer == null) {
jsonDeserializer = context.findContextualValueDeserializer(prop.getType(), prop);
}
TypeDeserializer typeDeserializer = context.getFactory().findTypeDeserializer(context.getConfig(), prop.getType());
if (typeDeserializer != null) {
jsonDeserializer = new TypeWrappedDeserializer(typeDeserializer, jsonDeserializer);
}
return jsonDeserializer;
} catch (JsonMappingException e) {
throw new RuntimeException(e);
}
}
Aggregations