Fix formatting
This commit is contained in:
parent
414821e5ba
commit
feb53db0e6
@ -1,14 +1,14 @@
|
|||||||
package org.baeldung.gson.deserialization;
|
package org.baeldung.gson.deserialization;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import org.baeldung.gson.entities.ActorGson;
|
import org.baeldung.gson.entities.ActorGson;
|
||||||
import org.baeldung.gson.entities.Movie;
|
import org.baeldung.gson.entities.Movie;
|
||||||
import org.baeldung.gson.serialization.ActorGsonDeserializer;
|
import org.baeldung.gson.serialization.ActorGsonDeserializer;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import java.text.ParseException;
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
|
|
||||||
public class GsonDeserializeTest {
|
public class GsonDeserializeTest {
|
||||||
|
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
package org.baeldung.gson.serialization;
|
package org.baeldung.gson.serialization;
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.baeldung.gson.entities.ActorGson;
|
|
||||||
import org.baeldung.gson.entities.Movie;
|
|
||||||
import org.baeldung.gson.entities.MovieWithNullValue;
|
|
||||||
import org.baeldung.gson.serialization.ActorGsonDeserializer;
|
|
||||||
import org.baeldung.gson.serialization.ActorGsonSerializer;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
import org.baeldung.gson.entities.ActorGson;
|
||||||
|
import org.baeldung.gson.entities.Movie;
|
||||||
|
import org.baeldung.gson.entities.MovieWithNullValue;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class GsonSerializeTest {
|
public class GsonSerializeTest {
|
||||||
|
|
||||||
@ -40,12 +37,12 @@ public class GsonSerializeTest {
|
|||||||
MovieWithNullValue movieWithNullValue = new MovieWithNullValue(null, "Mel Gibson", Arrays.asList(rudyYoungblood));
|
MovieWithNullValue movieWithNullValue = new MovieWithNullValue(null, "Mel Gibson", Arrays.asList(rudyYoungblood));
|
||||||
|
|
||||||
String expectedOutput = new GsonBuilder()
|
String expectedOutput = new GsonBuilder()
|
||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
.serializeNulls()
|
.serializeNulls()
|
||||||
.disableHtmlEscaping()
|
.disableHtmlEscaping()
|
||||||
.create()
|
.create()
|
||||||
.toJson(new JsonParser()
|
.toJson(new JsonParser()
|
||||||
.parse("{\"imdbId\":null,\"actors\":[{\"<strong>IMDB Code</strong>\":\"nm2199632\",\"<strong>Date Of Birth</strong>\":\"21-09-1982\",\"<strong>N° Film:</strong> \":3,\"filmography\":\"Apocalypto-Beatdown-Wind Walkers\"}]}"));
|
.parse("{\"imdbId\":null,\"actors\":[{\"<strong>IMDB Code</strong>\":\"nm2199632\",\"<strong>Date Of Birth</strong>\":\"21-09-1982\",\"<strong>N° Film:</strong> \":3,\"filmography\":\"Apocalypto-Beatdown-Wind Walkers\"}]}"));
|
||||||
Assert.assertEquals(gson.toJson(movieWithNullValue), expectedOutput);
|
Assert.assertEquals(gson.toJson(movieWithNullValue), expectedOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user