@Test void cachesScopeAwareComponentsOnceProvisioned() { when(configuration.findModules(AggregateConfiguration.class)).thenCallRealMethod(); when(configuration.getModules()) .thenReturn(singletonList(new WrappingModuleConfiguration(aggregateConfiguration))); when(aggregateConfiguration.repository()).thenReturn(aggregateRepository); List<ScopeAware> first = scopeAwareProvider.provideScopeAwareStream(anyScopeDescriptor()) .collect(toList()); reset(configuration, aggregateConfiguration); List<ScopeAware> second = scopeAwareProvider.provideScopeAwareStream(anyScopeDescriptor()).collect(toList()); verifyZeroInteractions(configuration); verifyZeroInteractions(aggregateConfiguration); assertEquals(first, second); }
@Override public Stream<ScopeAware> provideScopeAwareStream(ScopeDescriptor scopeDescriptor) { if (scopeAwareComponents == null) { scopeAwareComponents = retrieveScopeAwareComponents(); } return scopeAwareComponents.stream(); }
ConfigurationScopeAwareProvider implements ScopeAwareProvider { @Override public Stream<ScopeAware> provideScopeAwareStream(ScopeDescriptor scopeDescriptor) { if (scopeAwareComponents == null) { scopeAwareComponents = retrieveScopeAwareComponents(); } return scopeAwareComponents.stream(); } }
ConfigurationScopeAwareProvider implements ScopeAwareProvider { @Override public Stream<ScopeAware> provideScopeAwareStream(ScopeDescriptor scopeDescriptor) { if (scopeAwareComponents == null) { scopeAwareComponents = retrieveScopeAwareComponents(); } return scopeAwareComponents.stream(); } ConfigurationScopeAwareProvider(Configuration configuration); }
ConfigurationScopeAwareProvider implements ScopeAwareProvider { @Override public Stream<ScopeAware> provideScopeAwareStream(ScopeDescriptor scopeDescriptor) { if (scopeAwareComponents == null) { scopeAwareComponents = retrieveScopeAwareComponents(); } return scopeAwareComponents.stream(); } ConfigurationScopeAwareProvider(Configuration configuration); @Override Stream<ScopeAware> provideScopeAwareStream(ScopeDescriptor scopeDescriptor); }
ConfigurationScopeAwareProvider implements ScopeAwareProvider { @Override public Stream<ScopeAware> provideScopeAwareStream(ScopeDescriptor scopeDescriptor) { if (scopeAwareComponents == null) { scopeAwareComponents = retrieveScopeAwareComponents(); } return scopeAwareComponents.stream(); } ConfigurationScopeAwareProvider(Configuration configuration); @Override Stream<ScopeAware> provideScopeAwareStream(ScopeDescriptor scopeDescriptor);  }