-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from LachlanMcKee/develop
Update master to 3.7.2
- Loading branch information
Showing
11 changed files
with
197 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
POM_ARTIFACT_ID=gsonpath-compiler | ||
POM_NAME=gsonpath-compiler | ||
VERSION_NAME=3.7.1 | ||
VERSION_NAME=3.7.2 | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
compiler/standard/src/main/resources/META-INF/gradle/incremental.annotation.processors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
gsonpath.GsonProcessor,aggregating | ||
gsonpath.GsonProcessor,dynamic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 111 additions & 12 deletions
123
...esting/integration/src/test/java/gsonpath/generator/standard/CustomAutoGsonAdapterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,122 @@ | ||
package gsonpath.generator.standard | ||
|
||
import gsonpath.generator.GeneratorTester.assertGeneratedContent | ||
import gsonpath.generator.TestCriteria | ||
import com.google.common.truth.Truth.assertAbout | ||
import com.google.testing.compile.* | ||
import com.google.testing.compile.CompileTester.GeneratedPredicateClause | ||
import com.google.testing.compile.CompileTester.SuccessfulCompilationClause | ||
import gsonpath.GsonProcessor | ||
import org.hamcrest.CoreMatchers | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.ExpectedException | ||
import javax.tools.JavaFileObject | ||
import javax.tools.StandardLocation | ||
|
||
class CustomAutoGsonAdapterTest { | ||
@JvmField | ||
@Rule | ||
val expectedException: ExpectedException = ExpectedException.none() | ||
|
||
private fun standardGeneratorTester(relativePath: String): GeneratorTester { | ||
return GeneratorTester(relativePath) | ||
.absoluteInputFiles("generator/standard/TestGsonTypeFactory.java") | ||
} | ||
|
||
@Test | ||
fun testCustomAutoGsonAdapterAnnotation() { | ||
assertGeneratedContent(TestCriteria("generator/standard/custom_adapter_annotation", | ||
fun testCustomAutoGsonAdapterAnnotationWithoutIncrementalProcessing() { | ||
standardGeneratorTester("generator/standard/custom_adapter_annotation") | ||
.relativeInputFiles("CustomAutoGsonAdapter.java", "TestCustomAutoGsonAdapterModel.java") | ||
.compilesWithoutError { relativePath -> | ||
generatesFiles("$relativePath/TestCustomAutoGsonAdapterModel_GsonTypeAdapter.java") | ||
} | ||
} | ||
|
||
absoluteSourceNames = listOf( | ||
"generator/standard/TestGsonTypeFactory.java"), | ||
@Test | ||
fun testCustomAutoGsonAdapterAnnotationWithIncrementalProcessingAndAdditionalAnnotations() { | ||
standardGeneratorTester("generator/standard/custom_adapter_annotation") | ||
.relativeInputFiles("CustomAutoGsonAdapter.java", "TestCustomAutoGsonAdapterModel.java") | ||
.isIncremental(true) | ||
.additionalAnnotations("generator.standard.custom_adapter_annotation.CustomAutoGsonAdapter") | ||
.compilesWithoutError { relativePath -> | ||
generatesFiles("$relativePath/TestCustomAutoGsonAdapterModel_GsonTypeAdapter.java") | ||
} | ||
} | ||
|
||
relativeSourceNames = listOf( | ||
"CustomAutoGsonAdapter.java", | ||
"TestCustomAutoGsonAdapterModel.java"), | ||
@Test | ||
fun testCustomAutoGsonAdapterAnnotationWithIncrementalProcessingAndNoAdditionalAnnotations() { | ||
expectedException.expect(AssertionError::class.java) | ||
expectedException.expectMessage(CoreMatchers.containsString("expected to generate file: " + | ||
"/generator/standard/custom_adapter_annotation/TestCustomAutoGsonAdapterModel_GsonTypeAdapter.java")) | ||
|
||
relativeGeneratedNames = listOf( | ||
"TestCustomAutoGsonAdapterModel_GsonTypeAdapter.java") | ||
), "-Agsonpath.additionalAnnotations=generator.standard.custom_adapter_annotation.CustomAutoGsonAdapter") | ||
standardGeneratorTester("generator/standard/custom_adapter_annotation") | ||
.relativeInputFiles("CustomAutoGsonAdapter.java", "TestCustomAutoGsonAdapterModel.java") | ||
.isIncremental(true) | ||
.compilesWithoutError { | ||
generatesFileNamed(StandardLocation.SOURCE_OUTPUT, | ||
"generator.standard.custom_adapter_annotation", | ||
"TestCustomAutoGsonAdapterModel_GsonTypeAdapter.java") | ||
} | ||
} | ||
} | ||
|
||
class GeneratorTester(private val relativePath: String) { | ||
private val javaFileObjects = mutableListOf<JavaFileObject>() | ||
private val additionalAnnotations = mutableListOf<String>() | ||
private var incremental = false | ||
|
||
fun relativeInputFiles(vararg files: String): GeneratorTester { | ||
files.forEach { javaFileObjects.add(JavaFileObjects.forResource("$relativePath/$it")) } | ||
return this | ||
} | ||
|
||
fun absoluteInputFiles(vararg files: String): GeneratorTester { | ||
files.forEach { javaFileObjects.add(JavaFileObjects.forResource(it)) } | ||
return this | ||
} | ||
|
||
fun isIncremental(incremental: Boolean): GeneratorTester { | ||
this.incremental = incremental | ||
return this | ||
} | ||
|
||
fun additionalAnnotations(vararg annotations: String): GeneratorTester { | ||
annotations.forEach { additionalAnnotations.add(it) } | ||
return this | ||
} | ||
|
||
private fun buildTester(): CompileTester { | ||
val compileTesterFactory: ProcessedCompileTesterFactory = if (javaFileObjects.size == 1) { | ||
assertAbout(JavaSourceSubjectFactory.javaSource()).that(javaFileObjects.first()) | ||
|
||
} else { | ||
// Since we have multiple sources, we need to use a slightly different assert. | ||
assertAbout(JavaSourcesSubjectFactory.javaSources()).that(javaFileObjects) | ||
} | ||
return compileTesterFactory | ||
.builderTransformIf(incremental) { | ||
withCompilerOptions("-Agsonpath.incremental=true") | ||
} | ||
.builderTransformIf(additionalAnnotations.size > 0) { | ||
withCompilerOptions("-Agsonpath.additionalAnnotations=${additionalAnnotations.joinToString()}") | ||
} | ||
.processedWith(GsonProcessor()) | ||
} | ||
|
||
fun compilesWithoutError(func: GeneratedPredicateClause<SuccessfulCompilationClause>.(String) -> Unit) { | ||
func(buildTester().compilesWithoutError().and(), relativePath) | ||
} | ||
} | ||
|
||
fun <T> GeneratedPredicateClause<T>.generatesFiles(vararg files: String): T { | ||
val generatedSources = files.map { JavaFileObjects.forResource(it) } | ||
return if (files.size == 1) { | ||
generatesSources(generatedSources.first()) | ||
|
||
} else { | ||
generatesSources(generatedSources.first(), | ||
*generatedSources.subList(1, generatedSources.size).toTypedArray()) | ||
} | ||
} | ||
|
||
private inline fun <T> T.builderTransformIf(predicate: Boolean, f: T.() -> T): T = | ||
if (predicate) f(this) else this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
POM_ARTIFACT_ID=gsonpath-kt | ||
POM_NAME=gsonpath-kt | ||
VERSION_NAME=3.7.1 | ||
VERSION_NAME=3.7.2 | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
POM_ARTIFACT_ID=gsonpath | ||
POM_NAME=gsonpath | ||
VERSION_NAME=3.7.1 | ||
VERSION_NAME=3.7.2 | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters