small gson test changes

This commit is contained in:
eugenp 2014-09-11 18:41:00 +03:00
parent 42d17c1c4d
commit ee27f3d75a
1 changed files with 6 additions and 6 deletions

View File

@ -72,12 +72,12 @@ public class GsonSerializationTest {
String jsonDate = gson.toJson(sourceDate, sourceDateType); String jsonDate = gson.toJson(sourceDate, sourceDateType);
// test // test
System.out.println("jsonDate:\n" + jsonDate); System.out.println("jsonDate:\n" + jsonDate);
String estimatedResult = "\"Jan 1, 1970 3:16:40 AM\""; String expectedResult = "\"Jan 1, 1970 3:16:40 AM\"";
assertTrue(jsonDate.equals(estimatedResult)); assertTrue(jsonDate.equals(expectedResult));
} }
@Test @Test
public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnoringIt() { public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnored() {
SourceClass sourceObject = new SourceClass(-1, "minus 1"); SourceClass sourceObject = new SourceClass(-1, "minus 1");
GsonBuilder gsonBuildr = new GsonBuilder(); GsonBuilder gsonBuildr = new GsonBuilder();
gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsNotMatchingCriteriaSerializer()); gsonBuildr.registerTypeAdapter(SourceClass.class, new IgnoringFieldsNotMatchingCriteriaSerializer());
@ -85,9 +85,9 @@ public class GsonSerializationTest {
Type sourceObjectType = new TypeToken<SourceClass>() { Type sourceObjectType = new TypeToken<SourceClass>() {
}.getType(); }.getType();
String jsonString = gson.toJson(sourceObject, sourceObjectType); String jsonString = gson.toJson(sourceObject, sourceObjectType);
// test
String estimatedResult = "{\"stringValue\":\"minus 1\"}"; String expectedResult = "{\"stringValue\":\"minus 1\"}";
assertEquals(estimatedResult, jsonString); assertEquals(expectedResult, jsonString);
} }
} }