use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project graylog2-server by Graylog2.
the class InMemorySearchJobServiceTest method setup.
@Test
public void setup() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
final TypeFactory typeFactory = mapper.getTypeFactory().withClassLoader(this.getClass().getClassLoader());
this.objectMapper = mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE).setPropertyNamingStrategy(new PropertyNamingStrategy.SnakeCaseStrategy()).setTypeFactory(typeFactory).registerModule(new GuavaModule()).registerModule(new JodaModule()).registerModule(new Jdk8Module()).registerModule(new JavaTimeModule()).registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false)).registerModule(new SimpleModule("Graylog").addKeyDeserializer(Period.class, new JodaTimePeriodKeyDeserializer()).addSerializer(new RangeJsonSerializer()).addSerializer(new SizeSerializer()).addSerializer(new ObjectIdSerializer()));
// kludge because we don't have an injector in tests
ImmutableMap<String, Class> subtypes = ImmutableMap.<String, Class>builder().put(StreamFilter.NAME, StreamFilter.class).put(ElasticsearchQueryString.NAME, ElasticsearchQueryString.class).put(MessageList.NAME, MessageList.class).build();
subtypes.forEach((name, klass) -> objectMapper.registerSubtypes(new NamedType(klass, name)));
}
use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project graylog2-server by Graylog2.
the class UrlWhitelistTest method serializationRoundtrip.
@Test
public void serializationRoundtrip() throws IOException {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new Jdk8Module());
List<WhitelistEntry> entries = ImmutableList.of(LiteralWhitelistEntry.create("a", "title", "https://www.graylog.com"), RegexWhitelistEntry.create("b", "regex test title", "https://www\\.graylog\\.com/.*"));
UrlWhitelist orig = UrlWhitelist.createEnabled(entries);
String json = objectMapper.writeValueAsString(orig);
UrlWhitelist read = objectMapper.readValue(json, UrlWhitelist.class);
assertThat(read).isEqualTo(orig);
}
use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project keywhiz by square.
the class KeywhizService method customizeObjectMapper.
/**
* Customizes ObjectMapper for common settings.
*
* @param objectMapper to be customized
* @return customized input factory
*/
public static ObjectMapper customizeObjectMapper(ObjectMapper objectMapper) {
objectMapper.registerModules(new Jdk8Module());
objectMapper.registerModules(new JavaTimeModule());
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
}
use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project keywhiz by square.
the class CliModule method generalMapper.
@Provides
public ObjectMapper generalMapper() {
/**
* Customizes ObjectMapper for common settings.
*
* @param objectMapper to be customized
* @return customized input factory
*/
ObjectMapper objectMapper = Jackson.newObjectMapper();
objectMapper.registerModule(new Jdk8Module());
objectMapper.registerModules(new JavaTimeModule());
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return objectMapper;
}
use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project vespa by vespa-engine.
the class DeployOptionsTest method it_serializes_version.
@Test
public void it_serializes_version() throws IOException {
DeployOptions options = new DeployOptions(Optional.empty(), Optional.of(new Version("6.98.227")), false, false);
final ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).registerModule(new Jdk8Module());
String string = objectMapper.writeValueAsString(options);
assertEquals("{\"screwdriverBuildJob\":null,\"vespaVersion\":\"6.98.227\",\"ignoreValidationErrors\":false,\"deployCurrentVersion\":false}", string);
}
Aggregations