[gson] Fix tests
This commit is contained in:
parent
a8ab56c9f4
commit
5dd5926cb6
|
@ -1,32 +1,30 @@
|
||||||
package io.gitlab.jfronny.commons.serialize.gson.api;
|
package io.gitlab.jfronny.commons.serialize.gson.api;
|
||||||
|
|
||||||
import io.gitlab.jfronny.commons.serialize.*;
|
|
||||||
import io.gitlab.jfronny.commons.serialize.gson.impl.*;
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
|
import io.gitlab.jfronny.commons.serialize.gson.api.v1.GsonHolders;
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.Type;
|
||||||
import java.util.function.*;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class GsonHolder {
|
public class GsonHolder {
|
||||||
private static final io.gitlab.jfronny.commons.serialize.gson.api.v1.GsonHolder BACKEND = new io.gitlab.jfronny.commons.serialize.gson.api.v1.GsonHolder();
|
|
||||||
public static Gson getGson() {
|
public static Gson getGson() {
|
||||||
return BACKEND.getGson();
|
return GsonHolders.API.getGson();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerTypeAdapter(Type type, Object typeAdapter) {
|
public static void registerTypeAdapter(Type type, Object typeAdapter) {
|
||||||
BACKEND.registerTypeAdapter(type, typeAdapter);
|
GsonHolders.registerTypeAdapter(type, typeAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerTypeAdapterFactory(TypeAdapterFactory factory) {
|
public static void registerTypeAdapterFactory(TypeAdapterFactory factory) {
|
||||||
BACKEND.registerTypeAdapterFactory(factory);
|
GsonHolders.registerTypeAdapterFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void modifyBuilder(Consumer<GsonBuilder> func) {
|
public static void modifyBuilder(Consumer<GsonBuilder> func) {
|
||||||
BACKEND.modifyBuilder(func);
|
GsonHolders.API.modifyBuilder(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
Serializer.setInstance(new GsonHolderSerializer(BACKEND));
|
GsonHolders.registerSerializer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,8 @@ public class GsonTest {
|
||||||
@Test
|
@Test
|
||||||
void gsonIgnore() throws IOException {
|
void gsonIgnore() throws IOException {
|
||||||
assertEquals("null", Serializer.getInstance().serialize(new ExampleTypeHidden()));
|
assertEquals("null", Serializer.getInstance().serialize(new ExampleTypeHidden()));
|
||||||
assertEquals("""
|
assertEquals("{\"shouldShow\":\"Yes\"}", Serializer.getInstance().serialize(new TransitiveHiddenType()));
|
||||||
{
|
assertEquals("{\"id\":\"Yes\",\"shown\":{\"shouldShow\":\"Yes\"}}", Serializer.getInstance().serialize(new ExampleType()));
|
||||||
"shouldShow": "Yes"
|
|
||||||
}""", Serializer.getInstance().serialize(new TransitiveHiddenType()));
|
|
||||||
assertEquals("""
|
|
||||||
{
|
|
||||||
"id": "Yes",
|
|
||||||
"shown": {
|
|
||||||
"shouldShow": "Yes"
|
|
||||||
}
|
|
||||||
}""", Serializer.getInstance().serialize(new ExampleType()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue
Block a user