XlsFile { public Map<I18nBundleKey, Collection<Translation>> getContent() { final Multimap<I18nBundleKey, Translation> contentMap= LinkedHashMultimap.create(); for (int i= this.i18nSheet.getFirstRowNum() + 1; i < this.i18nSheet.getLastRowNum() + 1; i++) { final Row row= this.i18nSheet.getRow(i); if (row == null) { continue; } final Optional<String> baseBundleName= this.i18nSheet.getStringValue(i, 0); final Optional<String> key= this.i18nSheet.getStringValue(i, 1); final I18nBundleKey i18nKey= new I18nBundleKey(baseBundleName.orElse(""), key.orElse("")); for (final Map.Entry<Language, Integer> entry : this.languageColumnMap.entrySet()) { final Language language = entry.getKey(); final Integer columnIdx = entry.getValue(); final Cell cell= row.getCell(columnIdx); if (cell != null) { contentMap.put(i18nKey, new Translation(language, cell.getStringCellValue())); } } } return contentMap.asMap(); } XlsFile(final File file); CharSequence getContentAsString(); void setValue(final I18nBundleKey i18nKey, final Language language, final String value); void setValue(final I18nBundleKey i18nKey, final Translation translation); void setValue(final I18nBundleKey i18nKey, final Collection<Translation> translations); void save(); void saveTo(final File file); Map<I18nBundleKey, Collection<Translation>> getContent();  }
@Test public void testRead_WithEmptyDefaultLanguage() throws Exception { final File file= new File(Resources.getResource("i18n_expected.xlsx").toURI()); final XlsFile xlsFile= new XlsFile(file); final Map<I18nBundleKey, Collection<Translation>> content= xlsFile.getContent(); assertThat(content).containsOnlyKeys(new I18nBundleKey("i18n/messages", "ok"), new I18nBundleKey("i18n/messages", "cancel")); assertThat(content.get(new I18nBundleKey("i18n/messages", "ok"))).containsOnly( new Translation(Language.of("de"), "OK"), new Translation(Language.of(""), "OK") ); assertThat(content.get(new I18nBundleKey("i18n/messages", "cancel"))).containsOnly( new Translation(Language.of("de"), "Abbrechen"), new Translation(Language.of(""), "Cancel") ); }