1 /* 2 * Copyright (C) 2023 The Dagger Authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package app 18 19 import com.google.common.truth.Truth.assertThat 20 import library1.Dep 21 import library1.MyComponentDependency 22 import library1.MyComponentModule 23 import library1.MySubcomponentBinding 24 import library1.MySubcomponentModule 25 import library1.MySubcomponentWithBuilder 26 import org.junit.Before 27 import org.junit.Test 28 import org.junit.runner.RunWith 29 import org.junit.runners.JUnit4 30 31 @RunWith(JUnit4::class) 32 class MySubcomponentWithBuilderTest { 33 private lateinit var subcomponentWithBuilder: MySubcomponentWithBuilder 34 35 @Before setupnull36 fun setup() { 37 subcomponentWithBuilder = DaggerMyComponent.factory() 38 .create(MyComponentModule(Dep()), MyComponentDependency()) 39 .mySubcomponentWithBuilder() 40 .mySubcomponentModule(MySubcomponentModule(3)) 41 .qualifiedMySubcomponentBinding(MySubcomponentBinding()) 42 .unqualifiedMySubcomponentBinding(MySubcomponentBinding()) 43 .build() 44 } 45 46 // Test that the qualified and unqualified bindings are two separate objects 47 @Test testMySubcomponentBindingnull48 fun testMySubcomponentBinding() { 49 assertThat(subcomponentWithBuilder.qualifiedMySubcomponentBinding()) 50 .isNotEqualTo(subcomponentWithBuilder.unqualifiedMySubcomponentBinding()) 51 } 52 }