AstrixApiProviderClassScanner implements ApiProviders { @Override public Stream<ApiProviderClass> getAll() { return basePackages.stream() .flatMap(this::scanPackage); } AstrixApiProviderClassScanner(List<Class<? extends Annotation>> providerAnnotationsToScanFor, String basePackage, String... otherBasePackages); @Override Stream<ApiProviderClass> getAll();  }
@Test public void scansDefinedPackagesForDefinedAnnotations() throws Exception { List<ApiProviderClass> apiDescriptors = new AstrixApiProviderClassScanner(asList(DummyDescriptor.class), "com.avanza.astrix.context").getAll().collect(toList()); assertEquals(2, apiDescriptors.size()); Assert.assertThat(apiDescriptors, hasItem(equalTo(ApiProviderClass.create(DescriptorA.class)))); Assert.assertThat(apiDescriptors, hasItem(equalTo(ApiProviderClass.create(DescriptorB.class)))); }
@Test public void doesNotFinedDescriptorsOutsideDefinedPackge() throws Exception { List<ApiProviderClass> apiDescriptors = new AstrixApiProviderClassScanner(asList(DummyDescriptor.class), "com.avanza.astrix.context.foo.bar").getAll().collect(toList()); assertEquals(0, apiDescriptors.size()); }