diff --git a/plugin/src/test/kotlin/com/toasttab/expediter/gradle/ExpediterPluginIntegrationTest.kt b/plugin/src/test/kotlin/com/toasttab/expediter/gradle/ExpediterPluginIntegrationTest.kt index bf2a77d..3eafb8e 100644 --- a/plugin/src/test/kotlin/com/toasttab/expediter/gradle/ExpediterPluginIntegrationTest.kt +++ b/plugin/src/test/kotlin/com/toasttab/expediter/gradle/ExpediterPluginIntegrationTest.kt @@ -61,6 +61,35 @@ class ExpediterPluginIntegrationTest { ) } + @Test + fun `android compat animal sniffer`(project: TestProject) { + project.createRunner() + .withArguments("check") + .buildAndFail() + + val report = IssueReport.fromJson(project.dir.resolve("build/expediter.json").readText()) + + expectThat(report.issues).contains( + Issue.MissingMember( + "test/Caller", + MemberAccess.MethodAccess( + "java/util/concurrent/ConcurrentHashMap", + null, + MemberSymbolicReference( + "computeIfAbsent", + "(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;" + ), + MethodAccessType.VIRTUAL + ) + ), + + Issue.MissingType( + "com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder", + "java/util/stream/Collectors" + ) + ) + } + @Test fun `android compat source only`(project: TestProject) { project.createRunner() diff --git a/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/build.gradle.kts b/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/build.gradle.kts new file mode 100644 index 0000000..2323030 --- /dev/null +++ b/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + java + id("com.toasttab.expediter") + id("com.toasttab.testkit.coverage") version "@TESTKIT_PLUGIN_VERSION@" +} + +repositories { + mavenCentral() +} + +expediter { + failOnIssues = true + + platform { + animalSnifferConfiguration("_animal_sniffer_descriptors_") + } +} + +configurations.create("_animal_sniffer_descriptors_") + +dependencies { + implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2") + add("_animal_sniffer_descriptors_", "com.toasttab.android:gummy-bears-api-21:0.8.0@signature") +} diff --git a/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/settings.gradle.kts b/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/settings.gradle.kts new file mode 100644 index 0000000..dd508ac --- /dev/null +++ b/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "test" \ No newline at end of file diff --git a/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/src/main/java/test/Caller.java b/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/src/main/java/test/Caller.java new file mode 100644 index 0000000..bd5c76a --- /dev/null +++ b/plugin/src/test/projects/ExpediterPluginIntegrationTest/android compat animal sniffer/src/main/java/test/Caller.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Toast Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package test; + +import java.util.concurrent.ConcurrentHashMap; +import com.fasterxml.jackson.databind.ObjectMapper; +public class Caller { + void f() { + ConcurrentHashMap map = new ConcurrentHashMap<>(); + + map.put("a", "b"); + + map.computeIfAbsent("a", k -> "b"); + + map.hashCode(); + + ObjectMapper mapper = new ObjectMapper(); + } +} \ No newline at end of file