1 /* 2 * Copyright (C) 2021 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 dagger.functional.assisted; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import dagger.Component; 22 import dagger.assisted.Assisted; 23 import dagger.assisted.AssistedFactory; 24 import dagger.assisted.AssistedInject; 25 import org.junit.Test; 26 import org.junit.runner.RunWith; 27 import org.junit.runners.JUnit4; 28 29 @RunWith(JUnit4.class) 30 public final class AssistedFactoryWithArrayTypesTest { 31 @Component 32 interface TestComponent { fooFactory()33 FooFactory fooFactory(); 34 } 35 36 @AssistedFactory 37 interface FooFactory { create(Dep[] depArray)38 Foo create(Dep[] depArray); 39 } 40 41 static class Dep {} 42 43 static class Foo { 44 private final Dep[] depArray; 45 46 @AssistedInject Foo(@ssisted Dep[] depArray)47 Foo(@Assisted Dep[] depArray) { 48 this.depArray = depArray; 49 } 50 } 51 52 @Test testFooFactory()53 public void testFooFactory() { 54 Dep[] depArray = {new Dep(), new Dep()}; 55 Foo foo = 56 DaggerAssistedFactoryWithArrayTypesTest_TestComponent.create() 57 .fooFactory() 58 .create(depArray); 59 assertThat(foo.depArray).isEqualTo(depArray); 60 } 61 } 62