Skip to content

Commit

Permalink
Add an integration test covering animal sniffer signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
ogolberg authored Mar 18, 2024
1 parent 41329bd commit 7d56022
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "test"
Original file line number Diff line number Diff line change
@@ -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<String, String> map = new ConcurrentHashMap<>();

map.put("a", "b");

map.computeIfAbsent("a", k -> "b");

map.hashCode();

ObjectMapper mapper = new ObjectMapper();
}
}

0 comments on commit 7d56022

Please sign in to comment.