### Question:
MultisourceBeanLocator implements ConfiguredBeanLocator { @Override public List<String> getBeanNamesOfType(Class<?> type) { return locators.stream() .map(beanLocator -> beanLocator.getBeanNamesOfType(type)) .filter(Objects::nonNull) .flatMap(Collection::stream) .collect(Collectors.toList()); } MultisourceBeanLocator(ConfiguredBeanLocator... locators); @Override List<String> getBeanNamesOfType(Class<?> type); @Override T getBeanOfType(String name, Class<T> type); @Override Collection<? extends T> getBeansOfType(Class<T> type); @Override boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener); @Override boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value); @Override boolean hasBeanOfName(String name);  }### Answer:
@Test public void testGetBeanNamesOfType_emptySource() { when(source1.getBeanNamesOfType(eq(Long.class))).thenReturn(emptyList()); when(source2.getBeanNamesOfType(eq(Long.class))).thenReturn(asList("test", "test2")); List<String> names = multisourceBeanLocator.getBeanNamesOfType(Long.class); Assert.assertArrayEquals(asList("test", "test2").toArray(), names.toArray()); }
@Test public void testGetBeanNamesOfType_nullSource() { when(source1.getBeanNamesOfType(eq(Long.class))).thenReturn(null); when(source2.getBeanNamesOfType(eq(Long.class))).thenReturn(asList("test", "test2")); List<String> names = multisourceBeanLocator.getBeanNamesOfType(Long.class); Assert.assertArrayEquals(asList("test", "test2").toArray(), names.toArray()); }
@Test public void testGetBeanNamesOfType_mergeResults() { when(source1.getBeanNamesOfType(eq(Long.class))).thenReturn(asList("_test", "_test2")); when(source2.getBeanNamesOfType(eq(Long.class))).thenReturn(asList("test", "test2")); List<String> names = multisourceBeanLocator.getBeanNamesOfType(Long.class); Assert.assertArrayEquals(asList("_test", "_test2", "test", "test2").toArray(), names.toArray()); }