diff --git a/compiler/standard/src/test/java/gsonpath/integration/array/ArrayTest.kt b/compiler/standard/src/test/java/gsonpath/integration/array/ArrayTest.kt index 0cb7f62a..6f99bb90 100644 --- a/compiler/standard/src/test/java/gsonpath/integration/array/ArrayTest.kt +++ b/compiler/standard/src/test/java/gsonpath/integration/array/ArrayTest.kt @@ -1,17 +1,286 @@ package gsonpath.integration.array -import gsonpath.integration.common.GeneratorTester.assertGeneratedContent -import gsonpath.integration.common.TestCriteria +import gsonpath.integration.common.IntegrationTester import org.junit.Test class ArrayTest { @Test - fun testArray() { - assertGeneratedContent(TestCriteria("generator/standard/array", - absoluteSourceNames = listOf("generator/standard/TestGsonTypeFactory.java"), - relativeSourceNames = listOf("TestArray.java"), - relativeGeneratedNames = listOf("TestArray_GsonTypeAdapter.java") - )) - } + fun testArray() = IntegrationTester.integrationTest( + IntegrationTester.testGsonTypeFactory, + + IntegrationTester.inputSource("TestInheritanceBase", """ + import com.google.gson.annotations.SerializedName; + + import gsonpath.AutoGsonAdapter; + + @AutoGsonAdapter + class TestArray { + @SerializedName("test1[1]") + int plainArray; + + @SerializedName("test2[2].child") + int arrayWithNestedObject; + + @SerializedName("test2[2].child2") + int arrayWithNestedObject2; + + @SerializedName("test3[3].child[1]") + int arrayWithNestedArray; + + @SerializedName("test4.child[1]") + int objectWithNestedArray; + } + """ + ), + + IntegrationTester.outputSource("TestInheritance_GsonTypeAdapter", """ + import com.google.gson.Gson; + import com.google.gson.stream.JsonReader; + import com.google.gson.stream.JsonWriter; + import gsonpath.GsonPathGenerated; + import gsonpath.GsonPathTypeAdapter; + import gsonpath.JsonReaderHelper; + import java.io.IOException; + import java.lang.Integer; + import java.lang.Override; + + @GsonPathGenerated + public final class TestArray_GsonTypeAdapter extends GsonPathTypeAdapter { + public TestArray_GsonTypeAdapter(Gson gson) { + super(gson); + } + + @Override + public TestArray readImpl(JsonReader in) throws IOException { + TestArray result = new TestArray(); + JsonReaderHelper jsonReaderHelper = new JsonReaderHelper(in, 4, 5); + + while (jsonReaderHelper.handleObject(0, 4)) { + switch (in.nextName()) { + case "test1": + while (jsonReaderHelper.handleArray(0)) { + switch (jsonReaderHelper.getArrayIndex(0)) { + case 1: + Integer value_test1_1_ = gson.getAdapter(Integer.class).read(in); + if (value_test1_1_ != null) { + result.plainArray = value_test1_1_; + } + break; + + default: + jsonReaderHelper.onArrayFieldNotFound(0); + break; + + } + } + break; + + case "test2": + while (jsonReaderHelper.handleArray(1)) { + switch (jsonReaderHelper.getArrayIndex(1)) { + case 2: + while (jsonReaderHelper.handleObject(1, 2)) { + switch (in.nextName()) { + case "child": + Integer value_test2_2__child = gson.getAdapter(Integer.class).read(in); + if (value_test2_2__child != null) { + result.arrayWithNestedObject = value_test2_2__child; + } + break; + + case "child2": + Integer value_test2_2__child2 = gson.getAdapter(Integer.class).read(in); + if (value_test2_2__child2 != null) { + result.arrayWithNestedObject2 = value_test2_2__child2; + } + break; + + default: + jsonReaderHelper.onObjectFieldNotFound(1); + break; + + } + } + break; + + default: + jsonReaderHelper.onArrayFieldNotFound(1); + break; + + } + } + break; + + case "test3": + while (jsonReaderHelper.handleArray(2)) { + switch (jsonReaderHelper.getArrayIndex(2)) { + case 3: + while (jsonReaderHelper.handleObject(2, 1)) { + switch (in.nextName()) { + case "child": + while (jsonReaderHelper.handleArray(3)) { + switch (jsonReaderHelper.getArrayIndex(3)) { + case 1: + Integer value_test3_3__child_1_ = gson.getAdapter(Integer.class).read(in); + if (value_test3_3__child_1_ != null) { + result.arrayWithNestedArray = value_test3_3__child_1_; + } + break; + + default: + jsonReaderHelper.onArrayFieldNotFound(3); + break; + + } + } + break; + + default: + jsonReaderHelper.onObjectFieldNotFound(2); + break; + + } + } + break; + + default: + jsonReaderHelper.onArrayFieldNotFound(2); + break; + + } + } + break; + + case "test4": + while (jsonReaderHelper.handleObject(3, 1)) { + switch (in.nextName()) { + case "child": + while (jsonReaderHelper.handleArray(4)) { + switch (jsonReaderHelper.getArrayIndex(4)) { + case 1: + Integer value_test4_child_1_ = gson.getAdapter(Integer.class).read(in); + if (value_test4_child_1_ != null) { + result.objectWithNestedArray = value_test4_child_1_; + } + break; + + default: + jsonReaderHelper.onArrayFieldNotFound(4); + break; + + } + } + break; + + default: + jsonReaderHelper.onObjectFieldNotFound(3); + break; + + } + } + break; + + default: + jsonReaderHelper.onObjectFieldNotFound(0); + break; + + } + } + return result; + } + + @Override + public void writeImpl(JsonWriter out, TestArray value) throws IOException { + // Begin + out.beginObject(); + + // Begin Array: '.test1' + out.name("test1"); + out.beginArray(); + + out.nullValue(); // Set Value: 'test1[0]' + + // Set Value: 'test1[1]' + int obj0 = value.plainArray; + gson.getAdapter(Integer.class).write(out, obj0); + + // End Array: 'test1' + out.endArray(); + + // Begin Array: '.test2' + out.name("test2"); + out.beginArray(); + + out.nullValue(); // Set Value: 'test2[0]' + out.nullValue(); // Set Value: 'test2[1]' + + // Begin Object: 'test2[2]' + out.beginObject(); + int obj1 = value.arrayWithNestedObject; + out.name("child"); + gson.getAdapter(Integer.class).write(out, obj1); + + int obj2 = value.arrayWithNestedObject2; + out.name("child2"); + gson.getAdapter(Integer.class).write(out, obj2); + + // End test2[2] + out.endObject(); + // End Array: 'test2' + out.endArray(); + + // Begin Array: '.test3' + out.name("test3"); + out.beginArray(); + + out.nullValue(); // Set Value: 'test3[0]' + out.nullValue(); // Set Value: 'test3[1]' + out.nullValue(); // Set Value: 'test3[2]' + + // Begin Object: 'test3[3]' + out.beginObject(); + + // Begin Array: 'test3[3].child' + out.name("child"); + out.beginArray(); + + out.nullValue(); // Set Value: 'test3[3].child[0]' + + // Set Value: 'test3[3].child[1]' + int obj3 = value.arrayWithNestedArray; + gson.getAdapter(Integer.class).write(out, obj3); + + // End Array: 'child' + out.endArray(); + // End test3[3] + out.endObject(); + // End Array: 'test3' + out.endArray(); + + // Begin test4 + out.name("test4"); + out.beginObject(); + + // Begin Array: 'test4.child' + out.name("child"); + out.beginArray(); + + out.nullValue(); // Set Value: 'test4.child[0]' + + // Set Value: 'test4.child[1]' + int obj4 = value.objectWithNestedArray; + gson.getAdapter(Integer.class).write(out, obj4); + + // End Array: 'child' + out.endArray(); + // End test4 + out.endObject(); + // End + out.endObject(); + } + } + """ + ) + ) } diff --git a/compiler/standard/src/test/java/gsonpath/integration/common/IntegrationTester.kt b/compiler/standard/src/test/java/gsonpath/integration/common/IntegrationTester.kt new file mode 100644 index 00000000..6bffe06f --- /dev/null +++ b/compiler/standard/src/test/java/gsonpath/integration/common/IntegrationTester.kt @@ -0,0 +1,66 @@ +package gsonpath.integration.common + +import com.google.common.truth.Truth +import com.google.testing.compile.JavaFileObjects +import com.google.testing.compile.JavaSourcesSubjectFactory +import gsonpath.GsonProcessor +import javax.tools.JavaFileObject + +object IntegrationTester { + + fun integrationTest(vararg javaFileAndSourceType: JavaFileAndSourceType) { + val input: List = javaFileAndSourceType + .filter { it.sourceType == SourceType.INPUT } + .map { it.fileObject } + + val output: List = javaFileAndSourceType + .filter { it.sourceType == SourceType.OUTPUT } + .map { it.fileObject } + + Truth.assertAbout(JavaSourcesSubjectFactory.javaSources()) + .that(input) + .processedWith(GsonProcessor()) + .compilesWithoutError() + .and() + .run { + if (output.size == 1) { + generatesSources(output.first()) + + } else { + generatesSources(output.first(), *output.subList(1, output.size).toTypedArray()) + } + } + } + + class JavaFileAndSourceType( + val sourceType: SourceType, + val fileObject: JavaFileObject + ) + + enum class SourceType { + INPUT, OUTPUT + } + + private fun source(className: String, sourceType: SourceType, foo: String): JavaFileAndSourceType { + val trimIndent = foo.trimIndent() + return JavaFileAndSourceType(sourceType, JavaFileObjects.forSourceString( + "gsonpath.testing.$className", "package gsonpath.testing;\n\n$trimIndent")) + } + + fun inputSource(className: String, foo: String): JavaFileAndSourceType { + return source(className, SourceType.INPUT, foo) + } + + fun outputSource(className: String, foo: String): JavaFileAndSourceType { + return source(className, SourceType.OUTPUT, foo) + } + + val testGsonTypeFactory = inputSource("TestGsonTypeFactory", """ + import com.google.gson.TypeAdapterFactory; + import gsonpath.AutoGsonAdapterFactory; + + @AutoGsonAdapterFactory + public interface TestGsonTypeFactory extends TypeAdapterFactory {} + """ + ) +} diff --git a/compiler/standard/src/test/java/gsonpath/integration/enums/EnumTest.kt b/compiler/standard/src/test/java/gsonpath/integration/enums/EnumTest.kt index ad41b6a0..5b299362 100644 --- a/compiler/standard/src/test/java/gsonpath/integration/enums/EnumTest.kt +++ b/compiler/standard/src/test/java/gsonpath/integration/enums/EnumTest.kt @@ -1,17 +1,94 @@ package gsonpath.integration.enums -import gsonpath.integration.common.GeneratorTester.assertGeneratedContent -import gsonpath.integration.common.TestCriteria +import gsonpath.integration.common.IntegrationTester.inputSource +import gsonpath.integration.common.IntegrationTester.integrationTest +import gsonpath.integration.common.IntegrationTester.outputSource +import gsonpath.integration.common.IntegrationTester.testGsonTypeFactory import org.junit.Test class EnumTest { @Test - fun testEnum() { - assertGeneratedContent(TestCriteria("generator/enums", - absoluteSourceNames = listOf("generator/standard/TestGsonTypeFactory.java"), - relativeSourceNames = listOf("TestEnum.java"), - relativeGeneratedNames = listOf("TestEnum_GsonTypeAdapter.java") - )) - } + fun testEnum() = integrationTest( + testGsonTypeFactory, + + inputSource("TestEnum", """ + import com.google.gson.FieldNamingPolicy; + import com.google.gson.annotations.SerializedName; + import gsonpath.AutoGsonAdapter; + + @AutoGsonAdapter(fieldNamingPolicy = FieldNamingPolicy.LOWER_CASE_WITH_DASHES) + enum TestEnum { + VALUE_ABC, + VALUE_DEF, + @SerializedName("custom") + VALUE_GHI, + VALUE_1 + } + """ + ), + + outputSource("TestEnum_GsonTypeAdapter", """ + import static gsonpath.GsonUtil.*; + + import com.google.gson.Gson; + import com.google.gson.stream.JsonReader; + import com.google.gson.stream.JsonWriter; + import gsonpath.GsonPathGenerated; + import gsonpath.GsonPathTypeAdapter; + import java.io.IOException; + import java.lang.Override; + + @GsonPathGenerated + public final class TestEnum_GsonTypeAdapter extends GsonPathTypeAdapter { + public TestEnum_GsonTypeAdapter(Gson gson) { + super(gson); + } + + @Override + public TestEnum readImpl(JsonReader in) throws IOException { + switch (in.nextString()) { + case "value-abc": + return gsonpath.testing.TestEnum.VALUE_ABC; + + case "value-def": + return gsonpath.testing.TestEnum.VALUE_DEF; + + case "custom": + return gsonpath.testing.TestEnum.VALUE_GHI; + + case "value-1": + return gsonpath.testing.TestEnum.VALUE_1; + + default: + return null; + + } + } + + @Override + public void writeImpl(JsonWriter out, TestEnum value) throws IOException { + switch (value) { + case VALUE_ABC: + out.value("value-abc"); + break; + + case VALUE_DEF: + out.value("value-def"); + break; + + case VALUE_GHI: + out.value("custom"); + break; + + case VALUE_1: + out.value("value-1"); + break; + + } + } + } + """ + ) + ) } diff --git a/compiler/standard/src/test/java/gsonpath/integration/misc/InheritanceTest.kt b/compiler/standard/src/test/java/gsonpath/integration/misc/InheritanceTest.kt index 61f23f56..1bdd4c5b 100644 --- a/compiler/standard/src/test/java/gsonpath/integration/misc/InheritanceTest.kt +++ b/compiler/standard/src/test/java/gsonpath/integration/misc/InheritanceTest.kt @@ -1,23 +1,88 @@ package gsonpath.integration.misc -import gsonpath.integration.common.GeneratorTester.assertGeneratedContent -import gsonpath.integration.common.TestCriteria +import gsonpath.integration.common.IntegrationTester.inputSource +import gsonpath.integration.common.IntegrationTester.integrationTest +import gsonpath.integration.common.IntegrationTester.outputSource +import gsonpath.integration.common.IntegrationTester.testGsonTypeFactory import org.junit.Test class InheritanceTest { + @Test - fun testInheritance() { - assertGeneratedContent(TestCriteria("generator/standard/inheritance", + fun testInheritance() = integrationTest( + testGsonTypeFactory, + + inputSource("TestInheritanceBase", """ + import com.google.gson.annotations.SerializedName; - absoluteSourceNames = listOf( - "generator/standard/TestGsonTypeFactory.java"), + public class TestInheritanceBase { + @SerializedName("Json1") + public int value1; + } + """ + ), - relativeSourceNames = listOf( - "TestInheritanceBase.java", - "TestInheritance.java"), + inputSource("TestInheritance", """ + import gsonpath.AutoGsonAdapter; + + @AutoGsonAdapter + public class TestInheritance extends TestInheritanceBase {} + """ + ), - relativeGeneratedNames = listOf( - "TestInheritance_GsonTypeAdapter.java") - )) - } + outputSource("TestInheritance_GsonTypeAdapter", """ + import com.google.gson.Gson; + import com.google.gson.stream.JsonReader; + import com.google.gson.stream.JsonWriter; + import gsonpath.GsonPathGenerated; + import gsonpath.GsonPathTypeAdapter; + import gsonpath.JsonReaderHelper; + import java.io.IOException; + import java.lang.Integer; + import java.lang.Override; + + @GsonPathGenerated + public final class TestInheritance_GsonTypeAdapter extends GsonPathTypeAdapter { + public TestInheritance_GsonTypeAdapter(Gson gson) { + super(gson); + } + + @Override + public TestInheritance readImpl(JsonReader in) throws IOException { + TestInheritance result = new TestInheritance(); + JsonReaderHelper jsonReaderHelper = new JsonReaderHelper(in, 1, 0); + + while (jsonReaderHelper.handleObject(0, 1)) { + switch (in.nextName()) { + case "Json1": + Integer value_Json1 = gson.getAdapter(Integer.class).read(in); + if (value_Json1 != null) { + result.value1 = value_Json1; + } + break; + + default: + jsonReaderHelper.onObjectFieldNotFound(0); + break; + + } + } + return result; + } + + @Override + public void writeImpl(JsonWriter out, TestInheritance value) throws IOException { + // Begin + out.beginObject(); + int obj0 = value.value1; + out.name("Json1"); + gson.getAdapter(Integer.class).write(out, obj0); + + // End + out.endObject(); + } + } + """ + ) + ) } diff --git a/compiler/standard/src/test/resources/generator/enums/TestEnum.java b/compiler/standard/src/test/resources/generator/enums/TestEnum.java deleted file mode 100644 index ef50d7e7..00000000 --- a/compiler/standard/src/test/resources/generator/enums/TestEnum.java +++ /dev/null @@ -1,14 +0,0 @@ -package generator.enums; - -import com.google.gson.FieldNamingPolicy; -import com.google.gson.annotations.SerializedName; -import gsonpath.AutoGsonAdapter; - -@AutoGsonAdapter(fieldNamingPolicy = FieldNamingPolicy.LOWER_CASE_WITH_DASHES) -enum TestEnum { - VALUE_ABC, - VALUE_DEF, - @SerializedName("custom") - VALUE_GHI, - VALUE_1 -} \ No newline at end of file diff --git a/compiler/standard/src/test/resources/generator/enums/TestEnum_GsonTypeAdapter.java b/compiler/standard/src/test/resources/generator/enums/TestEnum_GsonTypeAdapter.java deleted file mode 100644 index b4b23df5..00000000 --- a/compiler/standard/src/test/resources/generator/enums/TestEnum_GsonTypeAdapter.java +++ /dev/null @@ -1,52 +0,0 @@ -package generator.enums; - -import static gsonpath.GsonUtil.*; - -import com.google.gson.Gson; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import gsonpath.GsonPathGenerated; -import gsonpath.GsonPathTypeAdapter; -import java.io.IOException; -import java.lang.Override; - -@GsonPathGenerated -public final class TestEnum_GsonTypeAdapter extends GsonPathTypeAdapter { - public TestEnum_GsonTypeAdapter(Gson gson) { - super(gson); - } - - @Override - public TestEnum readImpl(JsonReader in) throws IOException { - switch (in.nextString()) { - case "value-abc": - return generator.enums.TestEnum.VALUE_ABC; - case "value-def": - return generator.enums.TestEnum.VALUE_DEF; - case "custom": - return generator.enums.TestEnum.VALUE_GHI; - case "value-1": - return generator.enums.TestEnum.VALUE_1; - default: - return null; - } - } - - @Override - public void writeImpl(JsonWriter out, TestEnum value) throws IOException { - switch (value) { - case VALUE_ABC: - out.value("value-abc"); - break; - case VALUE_DEF: - out.value("value-def"); - break; - case VALUE_GHI: - out.value("custom"); - break; - case VALUE_1: - out.value("value-1"); - break; - } - } -} \ No newline at end of file diff --git a/compiler/standard/src/test/resources/generator/standard/array/TestArray.java b/compiler/standard/src/test/resources/generator/standard/array/TestArray.java deleted file mode 100644 index 5d4c7c68..00000000 --- a/compiler/standard/src/test/resources/generator/standard/array/TestArray.java +++ /dev/null @@ -1,23 +0,0 @@ -package generator.standard.array; - -import com.google.gson.annotations.SerializedName; - -import gsonpath.AutoGsonAdapter; - -@AutoGsonAdapter -class TestArray { - @SerializedName("test1[1]") - int plainArray; - - @SerializedName("test2[2].child") - int arrayWithNestedObject; - - @SerializedName("test2[2].child2") - int arrayWithNestedObject2; - - @SerializedName("test3[3].child[1]") - int arrayWithNestedArray; - - @SerializedName("test4.child[1]") - int objectWithNestedArray; -} \ No newline at end of file diff --git a/compiler/standard/src/test/resources/generator/standard/array/TestArray_GsonTypeAdapter.java b/compiler/standard/src/test/resources/generator/standard/array/TestArray_GsonTypeAdapter.java deleted file mode 100644 index 23a9dda8..00000000 --- a/compiler/standard/src/test/resources/generator/standard/array/TestArray_GsonTypeAdapter.java +++ /dev/null @@ -1,247 +0,0 @@ -package generator.standard.array; - -import com.google.gson.Gson; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import gsonpath.GsonPathGenerated; -import gsonpath.GsonPathTypeAdapter; -import gsonpath.JsonReaderHelper; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Override; - -@GsonPathGenerated -public final class TestArray_GsonTypeAdapter extends GsonPathTypeAdapter { - public TestArray_GsonTypeAdapter(Gson gson) { - super(gson); - } - - @Override - public TestArray readImpl(JsonReader in) throws IOException { - TestArray result = new TestArray(); - JsonReaderHelper jsonReaderHelper = new JsonReaderHelper(in, 4, 5); - - while (jsonReaderHelper.handleObject(0, 4)) { - switch (in.nextName()) { - case "test1": - while (jsonReaderHelper.handleArray(0)) { - switch (jsonReaderHelper.getArrayIndex(0)) { - case 1: - Integer value_test1_1_ = gson.getAdapter(Integer.class).read(in); - if (value_test1_1_ != null) { - result.plainArray = value_test1_1_; - } - break; - - default: - jsonReaderHelper.onArrayFieldNotFound(0); - break; - - } - } - break; - - case "test2": - while (jsonReaderHelper.handleArray(1)) { - switch (jsonReaderHelper.getArrayIndex(1)) { - case 2: - while (jsonReaderHelper.handleObject(1, 2)) { - switch (in.nextName()) { - case "child": - Integer value_test2_2__child = gson.getAdapter(Integer.class).read(in); - if (value_test2_2__child != null) { - result.arrayWithNestedObject = value_test2_2__child; - } - break; - - case "child2": - Integer value_test2_2__child2 = gson.getAdapter(Integer.class).read(in); - if (value_test2_2__child2 != null) { - result.arrayWithNestedObject2 = value_test2_2__child2; - } - break; - - default: - jsonReaderHelper.onObjectFieldNotFound(1); - break; - - } - } - break; - - default: - jsonReaderHelper.onArrayFieldNotFound(1); - break; - - } - } - break; - - case "test3": - while (jsonReaderHelper.handleArray(2)) { - switch (jsonReaderHelper.getArrayIndex(2)) { - case 3: - while (jsonReaderHelper.handleObject(2, 1)) { - switch (in.nextName()) { - case "child": - while (jsonReaderHelper.handleArray(3)) { - switch (jsonReaderHelper.getArrayIndex(3)) { - case 1: - Integer value_test3_3__child_1_ = gson.getAdapter(Integer.class).read(in); - if (value_test3_3__child_1_ != null) { - result.arrayWithNestedArray = value_test3_3__child_1_; - } - break; - - default: - jsonReaderHelper.onArrayFieldNotFound(3); - break; - - } - } - break; - - default: - jsonReaderHelper.onObjectFieldNotFound(2); - break; - - } - } - break; - - default: - jsonReaderHelper.onArrayFieldNotFound(2); - break; - - } - } - break; - - case "test4": - while (jsonReaderHelper.handleObject(3, 1)) { - switch (in.nextName()) { - case "child": - while (jsonReaderHelper.handleArray(4)) { - switch (jsonReaderHelper.getArrayIndex(4)) { - case 1: - Integer value_test4_child_1_ = gson.getAdapter(Integer.class).read(in); - if (value_test4_child_1_ != null) { - result.objectWithNestedArray = value_test4_child_1_; - } - break; - - default: - jsonReaderHelper.onArrayFieldNotFound(4); - break; - - } - } - break; - - default: - jsonReaderHelper.onObjectFieldNotFound(3); - break; - - } - } - break; - - default: - jsonReaderHelper.onObjectFieldNotFound(0); - break; - - } - } - return result; - } - - @Override - public void writeImpl(JsonWriter out, TestArray value) throws IOException { - // Begin - out.beginObject(); - - // Begin Array: '.test1' - out.name("test1"); - out.beginArray(); - - out.nullValue(); // Set Value: 'test1[0]' - - // Set Value: 'test1[1]' - int obj0 = value.plainArray; - gson.getAdapter(Integer.class).write(out, obj0); - - // End Array: 'test1' - out.endArray(); - - // Begin Array: '.test2' - out.name("test2"); - out.beginArray(); - - out.nullValue(); // Set Value: 'test2[0]' - out.nullValue(); // Set Value: 'test2[1]' - - // Begin Object: 'test2[2]' - out.beginObject(); - int obj1 = value.arrayWithNestedObject; - out.name("child"); - gson.getAdapter(Integer.class).write(out, obj1); - - int obj2 = value.arrayWithNestedObject2; - out.name("child2"); - gson.getAdapter(Integer.class).write(out, obj2); - - // End test2[2] - out.endObject(); - // End Array: 'test2' - out.endArray(); - - // Begin Array: '.test3' - out.name("test3"); - out.beginArray(); - - out.nullValue(); // Set Value: 'test3[0]' - out.nullValue(); // Set Value: 'test3[1]' - out.nullValue(); // Set Value: 'test3[2]' - - // Begin Object: 'test3[3]' - out.beginObject(); - - // Begin Array: 'test3[3].child' - out.name("child"); - out.beginArray(); - - out.nullValue(); // Set Value: 'test3[3].child[0]' - - // Set Value: 'test3[3].child[1]' - int obj3 = value.arrayWithNestedArray; - gson.getAdapter(Integer.class).write(out, obj3); - - // End Array: 'child' - out.endArray(); - // End test3[3] - out.endObject(); - // End Array: 'test3' - out.endArray(); - - // Begin test4 - out.name("test4"); - out.beginObject(); - - // Begin Array: 'test4.child' - out.name("child"); - out.beginArray(); - - out.nullValue(); // Set Value: 'test4.child[0]' - - // Set Value: 'test4.child[1]' - int obj4 = value.objectWithNestedArray; - gson.getAdapter(Integer.class).write(out, obj4); - - // End Array: 'child' - out.endArray(); - // End test4 - out.endObject(); - // End - out.endObject(); - } -} \ No newline at end of file diff --git a/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritance.java b/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritance.java deleted file mode 100644 index 1fd1ad89..00000000 --- a/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritance.java +++ /dev/null @@ -1,7 +0,0 @@ -package generator.standard.inheritance; - -import gsonpath.AutoGsonAdapter; - -@AutoGsonAdapter -public class TestInheritance extends TestInheritanceBase { -} \ No newline at end of file diff --git a/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritanceBase.java b/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritanceBase.java deleted file mode 100644 index a71ba007..00000000 --- a/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritanceBase.java +++ /dev/null @@ -1,8 +0,0 @@ -package generator.standard.inheritance; - -import com.google.gson.annotations.SerializedName; - -public class TestInheritanceBase { - @SerializedName("Json1") - public int value1; -} \ No newline at end of file diff --git a/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritance_GsonTypeAdapter.java b/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritance_GsonTypeAdapter.java deleted file mode 100644 index e076cf91..00000000 --- a/compiler/standard/src/test/resources/generator/standard/inheritance/TestInheritance_GsonTypeAdapter.java +++ /dev/null @@ -1,53 +0,0 @@ -package generator.standard.inheritance; - -import com.google.gson.Gson; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import gsonpath.GsonPathGenerated; -import gsonpath.GsonPathTypeAdapter; -import gsonpath.JsonReaderHelper; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Override; - -@GsonPathGenerated -public final class TestInheritance_GsonTypeAdapter extends GsonPathTypeAdapter { - public TestInheritance_GsonTypeAdapter(Gson gson) { - super(gson); - } - - @Override - public TestInheritance readImpl(JsonReader in) throws IOException { - TestInheritance result = new TestInheritance(); - JsonReaderHelper jsonReaderHelper = new JsonReaderHelper(in, 1, 0); - - while (jsonReaderHelper.handleObject(0, 1)) { - switch (in.nextName()) { - case "Json1": - Integer value_Json1 = gson.getAdapter(Integer.class).read(in); - if (value_Json1 != null) { - result.value1 = value_Json1; - } - break; - - default: - jsonReaderHelper.onObjectFieldNotFound(0); - break; - } - } - - return result; - } - - @Override - public void writeImpl(JsonWriter out, TestInheritance value) throws IOException { - // Begin - out.beginObject(); - int obj0 = value.value1; - out.name("Json1"); - gson.getAdapter(Integer.class).write(out, obj0); - - // End - out.endObject(); - } -} \ No newline at end of file