### Question:
ExtenderUtils { public static List<I18nExtension> analyze(String path, Bundle bundle) { List<I18nExtension> list = new ArrayList<>(); Enumeration<String> paths = bundle.getEntryPaths(path); if (paths != null) { while (paths.hasMoreElements()) { String entry = paths.nextElement(); if (! entry.endsWith("/")) { String file = entry.substring(path.length() - 1); Locale locale = getLocaleFromResourceName(file); URL url = bundle.getEntry(entry); if (url != null) { I18nExtension extension = new I18nExtension(url, locale, bundle); try { extension.load(); list.add(extension); } catch (IOException e) { LOGGER.error("Cannot load resource bundle from " + path + " within " + bundle.getSymbolicName(), e); } } else { LOGGER.error("Cannot open " + entry + " from " + bundle.getSymbolicName()); } } } } return list; } private  ExtenderUtils(); static List<I18nExtension> analyze(String path, Bundle bundle); static Locale getLocaleFromResourceName(String name);  }### Answer:
@Test public void testTraverseOnMockBundle() { List<String> structure = Arrays.asList( "i18n/messages.properties", "i18n/messages_fr.properties" ); Enumeration<String> paths = Iterators.asEnumeration(structure.iterator()); Bundle bundle = mock(Bundle.class); when(bundle.getEntryPaths(anyString())).thenReturn(paths); when(bundle.getEntry("i18n/messages.properties")) .thenReturn(this.getClass().getClassLoader().getResource("i18n/messages.properties")); when(bundle.getEntry("i18n/messages_fr.properties")) .thenReturn(this.getClass().getClassLoader().getResource("i18n/messages_fr.properties")); List<I18nExtension> list; list = ExtenderUtils.analyze("/i18n/", bundle); assertThat(list.size()).isEqualTo(2); assertThat(list.get(0).locale()).isEqualTo(InternationalizationService.DEFAULT_LOCALE); assertThat(list.get(0).get("welcome")).isEqualTo("hello"); assertThat(list.get(0).get("lang")).isEqualTo("english"); assertThat(list.get(1).locale()).isEqualTo(Locale.FRENCH); assertThat(list.get(1).get("welcome")).isEqualTo("bonjour"); assertThat(list.get(1).get("lang")).isEqualTo("français"); }
@Test public void testTraverseOnEmptyBundle() { List<String> structure = Arrays.asList(); Enumeration<String> paths = Iterators.asEnumeration(structure.iterator()); Bundle bundle = mock(Bundle.class); when(bundle.getEntryPaths(anyString())).thenReturn(paths); List<I18nExtension> list; list = ExtenderUtils.analyze("/i18n/", bundle); assertThat(list.size()).isEqualTo(0); }
@Test public void testTraverseOnEmptyBundleWhenReturningNull() { Bundle bundle = mock(Bundle.class); when(bundle.getEntryPaths(anyString())).thenReturn(null); List<I18nExtension> list; list = ExtenderUtils.analyze("/i18n/", bundle); assertThat(list.size()).isEqualTo(0); }