@Test public void testReadingTextUnitsFromFile() throws Exception { String path = Resources.getResource("com/box/l10n/mojito/android/strings/test_resources_file.xml").getPath(); mapper = new AndroidStringDocumentMapper("_", assetDelimiter); textUnits = mapper.mapToTextUnits(AndroidStringDocumentReader.fromFile(path)); assertThat(textUnits).isNotEmpty(); assertThat(textUnits).extracting("assetPath").containsOnly("Mojito/src/main/res/values/strings.xml"); assertThat(textUnits).filteredOn(tu -> tu.getName().equalsIgnoreCase("some_string")) .extracting("target", "comment") .containsOnly(tuple("Dela...", "Some string")); assertThat(textUnits).filteredOn(tu -> tu.getName().equalsIgnoreCase("show_options")) .extracting("target", "comment") .containsOnly(tuple("Mer \" dela", "Options")); assertThat(textUnits).filteredOn(tu -> tu.getName().equalsIgnoreCase("without_comment")) .extracting("target", "comment") .containsOnly(tuple("ei ' kommentteja", null)); assertThat(textUnits).filteredOn(tu -> tu.getName().equalsIgnoreCase("line_break")) .extracting("target", "comment") .containsOnly(tuple("salto de \nlinea", null)); assertThat(textUnits).filteredOn(tu -> tu.getName().startsWith("test_plural_hindi")) .extracting("name", "pluralForm", "target") .contains(tuple("test_plural_hindi_one", "one", "%1$d @ बहुवचन")) .contains(tuple("test_plural_hindi_other", "other", "%1$d @ विलक्षण")); assertThat(textUnits).filteredOn(tu -> tu.getName().startsWith("plural_russian")) .extracting("name", "pluralForm", "target") .contains(tuple("plural_russian_one", "one", "одно слово")) .contains(tuple("plural_russian_many", "many", "больше слов")); }
public List<TextUnitDTO> mapToTextUnits(AndroidStringDocument document) { return mapToTextUnitStream(document).collect(Collectors.toList()); }
AndroidStringDocumentMapper { public List<TextUnitDTO> mapToTextUnits(AndroidStringDocument document) { return mapToTextUnitStream(document).collect(Collectors.toList()); } }
AndroidStringDocumentMapper { public List<TextUnitDTO> mapToTextUnits(AndroidStringDocument document) { return mapToTextUnitStream(document).collect(Collectors.toList()); } AndroidStringDocumentMapper(String pluralSeparator,
                                       String assetDelimiter,
                                       String locale,
                                       String repositoryName);  AndroidStringDocumentMapper(String pluralSeparator, String assetDelimiter); }
AndroidStringDocumentMapper { public List<TextUnitDTO> mapToTextUnits(AndroidStringDocument document) { return mapToTextUnitStream(document).collect(Collectors.toList()); } AndroidStringDocumentMapper(String pluralSeparator,
                                       String assetDelimiter,
                                       String locale,
                                       String repositoryName);  AndroidStringDocumentMapper(String pluralSeparator, String assetDelimiter); AndroidStringDocument readFromTextUnits(List<TextUnitDTO> textUnits, boolean useSource); AndroidStringDocument readFromSourceTextUnits(List<TextUnitDTO> textUnits); AndroidStringDocument readFromTargetTextUnits(List<TextUnitDTO> textUnits); List<TextUnitDTO> mapToTextUnits(AndroidStringDocument document); Stream<TextUnitDTO> mapToTextUnitStream(AndroidStringDocument document); }
AndroidStringDocumentMapper { public List<TextUnitDTO> mapToTextUnits(AndroidStringDocument document) { return mapToTextUnitStream(document).collect(Collectors.toList()); } AndroidStringDocumentMapper(String pluralSeparator,
                                       String assetDelimiter,
                                       String locale,
                                       String repositoryName);  AndroidStringDocumentMapper(String pluralSeparator, String assetDelimiter); AndroidStringDocument readFromTextUnits(List<TextUnitDTO> textUnits, boolean useSource); AndroidStringDocument readFromSourceTextUnits(List<TextUnitDTO> textUnits); AndroidStringDocument readFromTargetTextUnits(List<TextUnitDTO> textUnits); List<TextUnitDTO> mapToTextUnits(AndroidStringDocument document); Stream<TextUnitDTO> mapToTextUnitStream(AndroidStringDocument document);  }