### Question:
ExtensionInitializer implements ApplicationContextInitializer<AnnotationConfigApplicationContext> { @Override public void initialize(AnnotationConfigApplicationContext context) { Set<String> packageNames = provider.getPackageNames(context.getEnvironment()); if (packageNames.size() > 0) { LOG.info("Adding packageNames '{}' to component scan.", packageNames); context.scan(packageNames.toArray(new String[packageNames.size()])); } } ExtensionInitializer(); @VisibleForTesting  ExtensionInitializer(ExtensionPackageProvider provider); @Override void initialize(AnnotationConfigApplicationContext context);  }### Answer:
@Test public void noPackage() { when(provider.getPackageNames(env)).thenReturn(Collections.<String> emptySet()); underTest.initialize(context); verify(context, never()).scan(any(String[].class)); }
@Test public void singlePackages() { when(provider.getPackageNames(env)).thenReturn(Collections.singleton("com.foo.bar")); underTest.initialize(context); verify(context).scan(new String[] { "com.foo.bar" }); }