Skip to content

Commit

Permalink
Java-2136 Fix Unit tests + remove unnecessary println
Browse files Browse the repository at this point in the history
  • Loading branch information
mikr committed Sep 15, 2020
1 parent 6927cc7 commit 27aa7c4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
7 changes: 7 additions & 0 deletions jackson-modules/jackson-custom-conversions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.1</version>
</dependency>


</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public void whenDeserialisingZonedDateTimeWithDefaults_thenTimeZoneIsNotPreserve
String converted = objectMapper.writeValueAsString(now);
// restore an instance of ZonedDateTime from String
ZonedDateTime restored = objectMapper.readValue(converted, ZonedDateTime.class);
System.out.println("serialized: " + now);
System.out.println("restored: " + restored);
assertThat(now, is(not(restored)));
}

Expand All @@ -70,15 +68,14 @@ public void whenDeserialisingZonedDateTimeWithFeaturesDisabled_thenTimeZoneIsPre
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.findAndRegisterModules();
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID);
objectMapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
// construct a new instance of ZonedDateTime
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Europe/Berlin"));
String converted = objectMapper.writeValueAsString(now);
// restore an instance of ZonedDateTime from String
ZonedDateTime restored = objectMapper.readValue(converted, ZonedDateTime.class);
System.out.println("serialized: " + now);
System.out.println("restored: " + restored);
assertThat(now, is(restored));
assertThat(restored, is(now));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class CustomSerializationUnitTest {
public final void whenSerializing_thenNoExceptions() throws JsonGenerationException, JsonMappingException, IOException {
final Item myItem = new Item(1, "theItem", new User(2, "theUser"));
final String serialized = new ObjectMapper().writeValueAsString(myItem);
System.out.println(serialized);
}

@Test
Expand All @@ -38,15 +37,13 @@ public final void whenSerializingWithCustomSerializer_thenNoExceptions() throws
mapper.registerModule(simpleModule);

final String serialized = mapper.writeValueAsString(myItem);
System.out.println(serialized);
}

@Test
public final void givenSerializerRegisteredOnClass_whenSerializingWithCustomSerializer_thenNoExceptions() throws JsonGenerationException, JsonMappingException, IOException {
final ItemWithSerializer myItem = new ItemWithSerializer(1, "theItem", new User(2, "theUser"));

final String serialized = new ObjectMapper().writeValueAsString(myItem);
System.out.println(serialized);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public final void givenTypeHasFilterThatIgnoresFieldByName_whenDtoIsSerialized_t
assertThat(dtoAsString, not(containsString("intValue")));
assertThat(dtoAsString, containsString("booleanValue"));
assertThat(dtoAsString, containsString("stringValue"));
System.out.println(dtoAsString);
}

@Test
Expand Down Expand Up @@ -83,7 +82,6 @@ protected final boolean include(final PropertyWriter writer) {
assertThat(dtoAsString, not(containsString("intValue")));
assertThat(dtoAsString, containsString("booleanValue"));
assertThat(dtoAsString, containsString("stringValue"));
System.out.println(dtoAsString);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public void whenNotHidden_thenCorrect() throws JsonProcessingException {
assertTrue(result.contains("john"));
assertTrue(result.contains("address"));
assertTrue(result.contains("usa"));

System.out.println("Not Hidden = " + result);
}

@Test
Expand All @@ -65,8 +63,6 @@ public void whenAddressHidden_thenCorrect() throws JsonProcessingException {
assertTrue(result.contains("john"));
assertFalse(result.contains("address"));
assertFalse(result.contains("usa"));

System.out.println("Address Hidden = " + result);
}

@Test
Expand All @@ -76,8 +72,6 @@ public void whenAllHidden_thenCorrect() throws JsonProcessingException {
final String result = mapper.writeValueAsString(person);

assertTrue(result.length() == 0);

System.out.println("All Hidden = " + result);
}

@Test
Expand All @@ -90,7 +84,5 @@ public void whenSerializeList_thenCorrect() throws JsonProcessingException {
final Person p3 = new Person("adam", ad3, false);

final String result = mapper.writeValueAsString(Arrays.asList(p1, p2, p3));

System.out.println(result);
}
}

0 comments on commit 27aa7c4

Please sign in to comment.