use of com.fasterxml.jackson.datatype.joda.JodaModule in project kylo by Teradata.
the class TriggerFeedTest method testFeedDependencyResultsExecutionContext.
@Test
public void testFeedDependencyResultsExecutionContext() {
FeedDependencyDeltaResults deltaResults = new FeedDependencyDeltaResults();
List<String> feedNames = new ArrayList<>();
feedNames.add("category.feed_a");
feedNames.add("category.feed_b");
deltaResults.setDependentFeedNames(feedNames);
Map<String, FeedDependencyDeltaResults.FeedJobExecutionData> jobData = new HashMap<>();
feedNames.stream().forEach(feedName -> {
Map<String, Object> executionContext = new HashMap<>();
executionContext.put("param1", "test");
executionContext.put("export.kylo.param2", "test2");
deltaResults.addFeedExecutionContext(feedName, new Long(1), DateTime.now(), DateTime.now(), executionContext);
});
String executionContextKeys = "export.kylo, export.test, test2 ";
List<String> list = new ArrayList<String>(Arrays.asList(executionContextKeys.trim().split("\\s*,\\s*")));
deltaResults.reduceExecutionContextToMatchingKeys(list);
// assert just the 1 property got sent to the execution context
Assert.assertEquals(1, deltaResults.getLatestFeedJobExecutionContext().get(feedNames.get(0)).getExecutionContext().size());
// validate JSON transform
ObjectMapper MAPPER = new ObjectMapper();
MAPPER.registerModule(new JodaModule());
MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
try {
String value = MAPPER.writeValueAsString(deltaResults);
Assert.assertNotNull(value);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
use of com.fasterxml.jackson.datatype.joda.JodaModule in project opsgenie-configuration-backup by opsgenie.
the class DeprecatedPolicyImporter method readJson.
private DeprecatedAlertPolicy readJson(String alertPolicyJson) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JodaModule());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
mapper.setDateFormat(sdf);
return mapper.readValue(alertPolicyJson, DeprecatedAlertPolicy.class);
}
use of com.fasterxml.jackson.datatype.joda.JodaModule in project opsgenie-configuration-backup by opsgenie.
the class IntegrationImporter method readJson.
private IntegrationConfig readJson(String entityJson) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JodaModule());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
mapper.setDateFormat(sdf);
return mapper.readValue(entityJson, IntegrationConfig.class);
}
use of com.fasterxml.jackson.datatype.joda.JodaModule in project oap by oaplatform.
the class Binder method initialize.
private static ObjectMapper initialize(ObjectMapper mapper, boolean defaultTyping, boolean nonNullInclusion, boolean skipInputNulls) {
if (mapper instanceof XmlMapper) {
((XmlMapper) mapper).setDefaultUseWrapper(false);
((XmlMapper) mapper).configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
}
AnnotationIntrospector introspector = new JacksonAnnotationIntrospector();
mapper.getDeserializationConfig().with(introspector);
mapper.getSerializationConfig().with(introspector);
mapper.registerModule(new AfterburnerModule());
mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(true));
mapper.registerModule(new JodaModule());
mapper.registerModule(new ExtModule());
mapper.registerModule(new JavaTimeModule());
mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.DEFAULT));
mapper.enable(DeserializationFeature.USE_LONG_FOR_INTS);
mapper.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
// todo remove after kernel cleanup
mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
if (skipInputNulls)
mapper.setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SKIP));
if (!nonNullInclusion)
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
modules.forEach(mapper::registerModule);
if (defaultTyping)
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
return mapper;
}
use of com.fasterxml.jackson.datatype.joda.JodaModule in project kylo by Teradata.
the class JerseyConfig method createJsonProvider.
private JacksonJaxbJsonProvider createJsonProvider() {
final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
final ObjectMapper om = new ObjectMapper();
om.registerModule(new JodaModule());
om.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
provider.setMapper(om);
return provider;
}
Aggregations