diff --git a/javatests/dagger/functional/kotlinsrc/multibindings/BUILD b/javatests/dagger/functional/kotlinsrc/multibindings/BUILD index 40c2329efbc..64e5dfb0073 100644 --- a/javatests/dagger/functional/kotlinsrc/multibindings/BUILD +++ b/javatests/dagger/functional/kotlinsrc/multibindings/BUILD @@ -25,10 +25,24 @@ load("//:test_defs.bzl", "GenKtTests") package(default_visibility = ["//:src"]) GenKtTests( - name = "multibindings", - srcs = glob(["*.kt"]), + name = "MultibindingTest", + srcs = [ + "BooleanKey.kt", + "ByteKey.kt", + "CharKey.kt", + "MultibindingComponent.kt", + "MultibindingDependency.kt", + "MultibindingModule.kt", + "MultibindingTest.kt", + "MultibindsModule.kt", + "NestedAnnotationContainer.kt", + "NumberClassKey.kt", + "ShortKey.kt", + "UnwrappedAnnotationKey.kt", + "WrappedAnnotationKey.kt", + ], gen_library_deps = [ - "//javatests/dagger/functional/kotlinsrc/multibindings/subpackage", + "//javatests/dagger/functional/kotlinsrc/multibindings/subpackage:ContributionsModule", ], javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, deps = [ @@ -38,3 +52,66 @@ GenKtTests( "//third_party/java/truth", ], ) + +GenKtTests( + name = "BindsInaccessibleMapKeyTest", + srcs = ["BindsInaccessibleMapKeyTest.kt"], + gen_library_deps = [ + "//javatests/dagger/functional/kotlinsrc/multibindings/subpackage:BindsInaccessibleMapKeyModule", + ], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) + +GenKtTests( + name = "ClassKeyWithGenericsTest", + srcs = ["ClassKeyWithGenericsTest.kt"], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) + +GenKtTests( + name = "ComplexMapKeysInDifferentOrderTest", + srcs = ["ComplexMapKeysInDifferentOrderTest.kt"], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/auto:value", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) + +GenKtTests( + name = "MapKeyWithDefaultTest", + srcs = ["MapKeyWithDefaultTest.kt"], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/auto:value", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) + +GenKtTests( + name = "LazyMapsTest", + srcs = [ + "LazyMaps.kt", + "LazyMapsTest.kt", + ], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) diff --git a/javatests/dagger/functional/kotlinsrc/multibindings/BindsInaccessibleMapKey.kt b/javatests/dagger/functional/kotlinsrc/multibindings/BindsInaccessibleMapKeyTest.kt similarity index 51% rename from javatests/dagger/functional/kotlinsrc/multibindings/BindsInaccessibleMapKey.kt rename to javatests/dagger/functional/kotlinsrc/multibindings/BindsInaccessibleMapKeyTest.kt index 1b602500de4..6076e233ed8 100644 --- a/javatests/dagger/functional/kotlinsrc/multibindings/BindsInaccessibleMapKey.kt +++ b/javatests/dagger/functional/kotlinsrc/multibindings/BindsInaccessibleMapKeyTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Dagger Authors. + * Copyright (C) 2024 The Dagger Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,26 @@ package dagger.functional.kotlinsrc.multibindings +import com.google.common.truth.Truth.assertThat import dagger.Component import dagger.functional.kotlinsrc.multibindings.subpackage.BindsInaccessibleMapKeyModule +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 // b/73820357 -@Component(modules = [BindsInaccessibleMapKeyModule::class]) -internal interface BindsInaccessibleMapKey { - fun mapWithAnInaccessibleMapKey(): Map, Any> +@RunWith(JUnit4::class) +class BindsInaccessibleMapKeyTest { + @Component(modules = [BindsInaccessibleMapKeyModule::class]) + internal interface TestComponent { + fun mapWithAnInaccessibleMapKey(): Map, Any> + } + + @Test + fun test() { + val map = DaggerBindsInaccessibleMapKeyTest_TestComponent.create().mapWithAnInaccessibleMapKey() + assertThat(map).hasSize(1) + assertThat(map.keys.single().canonicalName) + .isEqualTo("dagger.functional.kotlinsrc.multibindings.subpackage.Inaccessible"); + } } diff --git a/javatests/dagger/functional/kotlinsrc/multibindings/subpackage/BUILD b/javatests/dagger/functional/kotlinsrc/multibindings/subpackage/BUILD index d85fe395a15..3442486e08b 100644 --- a/javatests/dagger/functional/kotlinsrc/multibindings/subpackage/BUILD +++ b/javatests/dagger/functional/kotlinsrc/multibindings/subpackage/BUILD @@ -25,8 +25,17 @@ load("//:test_defs.bzl", "GenKtLibrary") package(default_visibility = ["//:src"]) GenKtLibrary( - name = "subpackage", - srcs = glob(["*.kt"]), + name = "ContributionsModule", + srcs = ["ContributionsModule.kt"], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + ], +) + +GenKtLibrary( + name = "BindsInaccessibleMapKeyModule", + srcs = ["BindsInaccessibleMapKeyModule.kt"], javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, deps = [ "//:dagger_with_compiler", diff --git a/javatests/dagger/functional/multibindings/BUILD b/javatests/dagger/functional/multibindings/BUILD index 63a7bfd2728..60f04a40f98 100644 --- a/javatests/dagger/functional/multibindings/BUILD +++ b/javatests/dagger/functional/multibindings/BUILD @@ -25,17 +25,94 @@ load("//:test_defs.bzl", "GenJavaTests") package(default_visibility = ["//:src"]) GenJavaTests( - name = "multibindings", - srcs = glob(["*.java"]), + name = "MultibindingTest", + srcs = [ + "BooleanKey.java", + "ByteKey.java", + "CharKey.java", + "MultibindingComponent.java", + "MultibindingDependency.java", + "MultibindingModule.java", + "MultibindingTest.java", + "MultibindsModule.java", + "NestedAnnotationContainer.java", + "NumberClassKey.java", + "ShortKey.java", + "UnwrappedAnnotationKey.java", + "WrappedAnnotationKey.java", + ], gen_library_deps = [ - "//javatests/dagger/functional/multibindings/subpackage", + "//javatests/dagger/functional/multibindings/subpackage:ContributionsModule", ], javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, deps = [ "//:dagger_with_compiler", "//third_party/java/auto:value", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) + +GenJavaTests( + name = "BindsInaccessibleMapKeyTest", + srcs = ["BindsInaccessibleMapKeyTest.java"], + gen_library_deps = [ + "//javatests/dagger/functional/multibindings/subpackage:BindsInaccessibleMapKeyModule", + ], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", "//third_party/java/guava/collect", "//third_party/java/junit", "//third_party/java/truth", ], ) + +GenJavaTests( + name = "ClassKeyWithGenericsTest", + srcs = ["ClassKeyWithGenericsTest.java"], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) + +GenJavaTests( + name = "ComplexMapKeysInDifferentOrderTest", + srcs = ["ComplexMapKeysInDifferentOrderTest.java"], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/auto:value", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) + +GenJavaTests( + name = "MapKeyWithDefaultTest", + srcs = ["MapKeyWithDefaultTest.java"], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/auto:value", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) + +GenJavaTests( + name = "LazyMapsTest", + srcs = [ + "LazyMaps.java", + "LazyMapsTest.java", + ], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + "//third_party/java/junit", + "//third_party/java/truth", + ], +) diff --git a/javatests/dagger/functional/multibindings/BindsInaccessibleMapKey.java b/javatests/dagger/functional/multibindings/BindsInaccessibleMapKey.java deleted file mode 100644 index 6256812eab9..00000000000 --- a/javatests/dagger/functional/multibindings/BindsInaccessibleMapKey.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2018 The Dagger Authors. - * - * 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 dagger.functional.multibindings; - -import dagger.Component; -import dagger.functional.multibindings.subpackage.BindsInaccessibleMapKeyModule; -import java.util.Map; - -// b/73820357 -@Component(modules = BindsInaccessibleMapKeyModule.class) -interface BindsInaccessibleMapKey { - Map, Object> mapWithAnInaccessibleMapKey(); -} diff --git a/javatests/dagger/functional/multibindings/BindsInaccessibleMapKeyTest.java b/javatests/dagger/functional/multibindings/BindsInaccessibleMapKeyTest.java new file mode 100644 index 00000000000..470f644fc30 --- /dev/null +++ b/javatests/dagger/functional/multibindings/BindsInaccessibleMapKeyTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2018 The Dagger Authors. + * + * 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 dagger.functional.multibindings; + +import static com.google.common.collect.Iterables.getOnlyElement; +import static com.google.common.truth.Truth.assertThat; + +import dagger.Component; +import dagger.functional.multibindings.subpackage.BindsInaccessibleMapKeyModule; +import java.util.Map; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +// b/73820357 +@RunWith(JUnit4.class) +public class BindsInaccessibleMapKeyTest { + @Component(modules = BindsInaccessibleMapKeyModule.class) + interface TestComponent { + Map, Object> mapWithAnInaccessibleMapKey(); + } + + @Test + public void test() { + Map, Object> map = + DaggerBindsInaccessibleMapKeyTest_TestComponent.create().mapWithAnInaccessibleMapKey(); + assertThat(map).hasSize(1); + assertThat(getOnlyElement(map.keySet()).getCanonicalName()) + .isEqualTo( + "dagger.functional.multibindings.subpackage." + + "BindsInaccessibleMapKeyModule.Inaccessible"); + } +} diff --git a/javatests/dagger/functional/multibindings/subpackage/BUILD b/javatests/dagger/functional/multibindings/subpackage/BUILD index fe3abef080e..1485b04254d 100644 --- a/javatests/dagger/functional/multibindings/subpackage/BUILD +++ b/javatests/dagger/functional/multibindings/subpackage/BUILD @@ -25,8 +25,17 @@ load("//:test_defs.bzl", "GenJavaLibrary") package(default_visibility = ["//:src"]) GenJavaLibrary( - name = "subpackage", - srcs = glob(["*.java"]), + name = "ContributionsModule", + srcs = ["ContributionsModule.java"], + javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, + deps = [ + "//:dagger_with_compiler", + ], +) + +GenJavaLibrary( + name = "BindsInaccessibleMapKeyModule", + srcs = ["BindsInaccessibleMapKeyModule.java"], javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES, deps = [ "//:dagger_with_compiler",