@@ -0,0 +1,2755 @@
+package de.terrestris.shogun2.util.json;%0A%0Aimport static org.hamcrest.CoreMatchers.instanceOf;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport java.text.DateFormat;%0Aimport java.util.List;%0Aimport java.util.TimeZone;%0A%0Aimport org.junit.Test;%0A%0Aimport com.fasterxml.jackson.databind.DeserializationConfig;%0Aimport com.fasterxml.jackson.databind.Module;%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.fasterxml.jackson.databind.SerializationConfig;%0Aimport com.fasterxml.jackson.databind.SerializationFeature;%0Aimport com.fasterxml.jackson.databind.util.ISO8601DateFormat;%0Aimport com.fasterxml.jackson.datatype.joda.JodaModule;%0A%0A/**%0A * @author Nils B%C3%BChner%0A *%0A */%0Apublic class Shogun2JsonObjectMapperTest %7B%0A%0A%09/**%0A%09 * The object mapper to test.%0A%09 */%0A%09private final ObjectMapper objectMapper = new Shogun2JsonObjectMapper();%0A%0A%09/**%0A%09 * Tests whether the JodaModule is registered.%0A%09 */%0A%09@Test%0A%09public void testModules() %7B%0A%0A%09%09List%3CModule%3E modules = Shogun2JsonObjectMapper.findModules();%0A%0A%09%09assertEquals(1, modules.size());%0A%09%09assertThat(modules.get(0), instanceOf(JodaModule.class));%0A%09%7D%0A%0A%09/**%0A%09 * Tests whether the dateFormat is ISO8601%0A%09 */%0A%09@Test%0A%09public void testDateFormat() %7B%0A%0A%09%09SerializationConfig serializationConfig = objectMapper.getSerializationConfig();%0A%09%09DeserializationConfig deserializationConfig = objectMapper.getDeserializationConfig();%0A%0A%09%09DateFormat serializationDateFormat = serializationConfig.getDateFormat();%0A%09%09DateFormat deserializationDateFormat = deserializationConfig.getDateFormat();%0A%0A%09%09assertThat(serializationDateFormat, instanceOf(ISO8601DateFormat.class));%0A%09%09assertThat(deserializationDateFormat, instanceOf(ISO8601DateFormat.class));%0A%09%7D%0A%0A%09/**%0A%09 * Tests whether the correct TimeZone is set.%0A%09 */%0A%09@Test%0A%09public void testTimezone() %7B%0A%0A%09%09TimeZone expectedTimeZone = TimeZone.getDefault();%0A%0A%09%09SerializationConfig serializationConfig = objectMapper.getSerializationConfig();%0A%09%09DeserializationConfig deserializationConfig = objectMapper.getDeserializationConfig();%0A%0A%09%09TimeZone serializationTimeZone = serializationConfig.getTimeZone();%0A%09%09TimeZone deserializationTimeZone = deserializationConfig.getTimeZone();%0A%0A%09%09assertEquals(expectedTimeZone, serializationTimeZone);%0A%09%09assertEquals(expectedTimeZone, deserializationTimeZone);%0A%09%7D%0A%0A%09/**%0A%09 * Tests whether the dates are not serialized as timestamps, but as%0A%09 * their textual representation.%0A%09 */%0A%09@Test%0A%09public void testDateSerialization() %7B%0A%0A%09%09SerializationConfig serializationConfig = objectMapper.getSerializationConfig();%0A%0A%09%09boolean writesDatesAsTimestamps = serializationConfig.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);%0A%0A%09%09assertFalse(writesDatesAsTimestamps);%0A%09%7D%0A%0A%7D%0A

Add tests for the Shogun2JsonObjectMapper