@Test public void constructorInjectionWithProviders() { Provider<Seat> p1 = getField(car, "constructorPlainSeatProvider"); assertNotNull(p1.get()); Provider<Tire> p2 = getField(car, "constructorPlainTireProvider"); assertNotNull(p2.get()); }
@Test public void constructorInjectedProviderYieldsDistinctValues() { Provider<Seat> p1 = getField(car, "constructorDriversSeatProvider"); assertNotSame(p1.get(), p1.get()); Provider<Tire> p2 = getField(car, "constructorPlainTireProvider"); assertNotSame(p2.get(), p2.get()); Provider<Tire> p3 = getField(car, "constructorSpareTireProvider"); assertNotSame(p3.get(), p3.get()); }
@Test public void fieldInjectedProviderYieldsSingleton() { Provider<Seat> p = car.fieldPlainSeatProvider; assertSame(p.get(), p.get()); }
@Test public void constructorInjectedProviderYieldsSingleton() { Provider<Seat> p = getField(car, "constructorPlainSeatProvider"); assertSame(p.get(), p.get()); }