@@ -65,29 +65,29 @@ public void givenIgnoringAField_whenSerializingWithCustomSerializer_thenFieldIgn
6565
6666 @ Test
6767 public void givenDate_whenSerializing_thenCorrect () {
68- Date sourceDate = new Date (1000000L );
69- Gson gson = new Gson ();
70- Type sourceDateType = new TypeToken <Date >() {
68+ final Date sourceDate = new Date (1000000L );
69+ final Gson gson = new Gson ();
70+ final Type sourceDateType = new TypeToken <Date >() {
7171 }.getType ();
7272 String jsonDate = gson .toJson (sourceDate , sourceDateType );
73- // test
73+
7474 System .out .println ("jsonDate:\n " + jsonDate );
75- String expectedResult = "\" Jan 1, 1970 3:16:40 AM\" " ;
75+ final String expectedResult = "\" Jan 1, 1970 3:16:40 AM\" " ;
7676 assertTrue (jsonDate .equals (expectedResult ));
7777 }
7878
7979 @ Test
8080 public void givenUsingCustomDeserializer_whenFieldNotMatchesCriteria_thenIgnored () {
81- SourceClass sourceObject = new SourceClass (-1 , "minus 1" );
82- GsonBuilder gsonBuildr = new GsonBuilder ();
81+ final SourceClass sourceObject = new SourceClass (-1 , "minus 1" );
82+ final GsonBuilder gsonBuildr = new GsonBuilder ();
8383 gsonBuildr .registerTypeAdapter (SourceClass .class , new IgnoringFieldsNotMatchingCriteriaSerializer ());
84- Gson gson = gsonBuildr .create ();
85- Type sourceObjectType = new TypeToken <SourceClass >() {
84+ final Gson gson = gsonBuildr .create ();
85+ final Type sourceObjectType = new TypeToken <SourceClass >() {
8686 }.getType ();
8787 String jsonString = gson .toJson (sourceObject , sourceObjectType );
88-
89- String expectedResult = "{\" stringValue\" :\" minus 1\" }" ;
88+
89+ final String expectedResult = "{\" stringValue\" :\" minus 1\" }" ;
9090 assertEquals (expectedResult , jsonString );
9191 }
92-
92+
9393}
0 commit comments