@Test public void testPushDryRunNoBatches() { List<SmartlingFile> result; ThirdPartyServiceTestData testData = new ThirdPartyServiceTestData(testIdWatcher); Repository repository = testData.repository; tmsSmartling.push(repository, "projectId", "_", null, null, Arrays.asList("dry-run=true")); result = resultProcessor.pushFiles; assertThat(result).hasSize(2); assertThat(result.stream().map(SmartlingFile::getFileName)).containsOnly( repository.getName() + "/00000_singular_source.xml", repository.getName() + "/00000_plural_source.xml"); assertThat(result.stream().map(SmartlingFile::getFileContent)).containsOnly( singularContent(testData), pluralsContent(testData)); verifyNoInteractions(smartlingClient); }
@Override public void push(Repository repository, String projectId, String pluralSeparator, String skipTextUnitsWithPattern, String skipAssetsWithPathPattern, List<String> optionList) { SmartlingOptions options = SmartlingOptions.parseList(optionList); AndroidStringDocumentMapper mapper = new AndroidStringDocumentMapper(pluralSeparator, null); Stream<SmartlingFile> singularFiles = mapWithIndex( partitionSingulars(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.SINGULAR)); Stream<SmartlingFile> pluralFiles = mapWithIndex( partitionPlurals(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.PLURAL)); List<SmartlingFile> result = Stream.concat(singularFiles, pluralFiles).collect(Collectors.toList()); resultProcessor.processPush(result, options); }
ThirdPartyTMSSmartling implements ThirdPartyTMS { @Override public void push(Repository repository, String projectId, String pluralSeparator, String skipTextUnitsWithPattern, String skipAssetsWithPathPattern, List<String> optionList) { SmartlingOptions options = SmartlingOptions.parseList(optionList); AndroidStringDocumentMapper mapper = new AndroidStringDocumentMapper(pluralSeparator, null); Stream<SmartlingFile> singularFiles = mapWithIndex( partitionSingulars(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.SINGULAR)); Stream<SmartlingFile> pluralFiles = mapWithIndex( partitionPlurals(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.PLURAL)); List<SmartlingFile> result = Stream.concat(singularFiles, pluralFiles).collect(Collectors.toList()); resultProcessor.processPush(result, options); } }
ThirdPartyTMSSmartling implements ThirdPartyTMS { @Override public void push(Repository repository, String projectId, String pluralSeparator, String skipTextUnitsWithPattern, String skipAssetsWithPathPattern, List<String> optionList) { SmartlingOptions options = SmartlingOptions.parseList(optionList); AndroidStringDocumentMapper mapper = new AndroidStringDocumentMapper(pluralSeparator, null); Stream<SmartlingFile> singularFiles = mapWithIndex( partitionSingulars(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.SINGULAR)); Stream<SmartlingFile> pluralFiles = mapWithIndex( partitionPlurals(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.PLURAL)); List<SmartlingFile> result = Stream.concat(singularFiles, pluralFiles).collect(Collectors.toList()); resultProcessor.processPush(result, options); } @Autowired  ThirdPartyTMSSmartling(SmartlingClient smartlingClient,
                                  TextUnitSearcher textUnitSearcher,
                                  AssetPathAndTextUnitNameKeys assetPathAndTextUnitNameKeys,
                                  TextUnitBatchImporterService textUnitBatchImporterService,
                                  SmartlingResultProcessor resultProcessor);  ThirdPartyTMSSmartling(SmartlingClient smartlingClient,
                                  TextUnitSearcher textUnitSearcher,
                                  AssetPathAndTextUnitNameKeys assetPathAndTextUnitNameKeys,
                                  TextUnitBatchImporterService textUnitBatchImporterService,
                                  SmartlingResultProcessor resultProcessor,
                                  int batchSize); }
ThirdPartyTMSSmartling implements ThirdPartyTMS { @Override public void push(Repository repository, String projectId, String pluralSeparator, String skipTextUnitsWithPattern, String skipAssetsWithPathPattern, List<String> optionList) { SmartlingOptions options = SmartlingOptions.parseList(optionList); AndroidStringDocumentMapper mapper = new AndroidStringDocumentMapper(pluralSeparator, null); Stream<SmartlingFile> singularFiles = mapWithIndex( partitionSingulars(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.SINGULAR)); Stream<SmartlingFile> pluralFiles = mapWithIndex( partitionPlurals(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.PLURAL)); List<SmartlingFile> result = Stream.concat(singularFiles, pluralFiles).collect(Collectors.toList()); resultProcessor.processPush(result, options); } @Autowired  ThirdPartyTMSSmartling(SmartlingClient smartlingClient,
                                  TextUnitSearcher textUnitSearcher,
                                  AssetPathAndTextUnitNameKeys assetPathAndTextUnitNameKeys,
                                  TextUnitBatchImporterService textUnitBatchImporterService,
                                  SmartlingResultProcessor resultProcessor);  ThirdPartyTMSSmartling(SmartlingClient smartlingClient,
                                  TextUnitSearcher textUnitSearcher,
                                  AssetPathAndTextUnitNameKeys assetPathAndTextUnitNameKeys,
                                  TextUnitBatchImporterService textUnitBatchImporterService,
                                  SmartlingResultProcessor resultProcessor,
                                  int batchSize); @Override ThirdPartyTMSImage uploadImage(String projectId, String name, byte[] content); @Override List<ThirdPartyTextUnit> getThirdPartyTextUnits(Repository repository, String projectId); @Override void createImageToTextUnitMappings(String projectId, List<ThirdPartyImageToTextUnit> thirdPartyImageToTextUnits); @Override void push(Repository repository,
                     String projectId,
                     String pluralSeparator,
                     String skipTextUnitsWithPattern,
                     String skipAssetsWithPathPattern,
                     List<String> optionList); @Override void pull(Repository repository,
                     String projectId,
                     String pluralSeparator,
                     Map<String, String> localeMapping,
                     String skipTextUnitsWithPattern,
                     String skipAssetsWithPathPattern,
                     List<String> optionList); @Override void pushTranslations(Repository repository,
                                 String projectId,
                                 String pluralSeparator,
                                 Map<String, String> localeMapping,
                                 String skipTextUnitsWithPattern,
                                 String skipAssetsWithPathPattern,
                                 List<String> optionList); }
ThirdPartyTMSSmartling implements ThirdPartyTMS { @Override public void push(Repository repository, String projectId, String pluralSeparator, String skipTextUnitsWithPattern, String skipAssetsWithPathPattern, List<String> optionList) { SmartlingOptions options = SmartlingOptions.parseList(optionList); AndroidStringDocumentMapper mapper = new AndroidStringDocumentMapper(pluralSeparator, null); Stream<SmartlingFile> singularFiles = mapWithIndex( partitionSingulars(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.SINGULAR)); Stream<SmartlingFile> pluralFiles = mapWithIndex( partitionPlurals(repository.getId(), LOCALE_EN, skipTextUnitsWithPattern, skipAssetsWithPathPattern), (batch, index) -> processPushBatch(batch, index, mapper, repository, projectId, options, Prefix.PLURAL)); List<SmartlingFile> result = Stream.concat(singularFiles, pluralFiles).collect(Collectors.toList()); resultProcessor.processPush(result, options); } @Autowired  ThirdPartyTMSSmartling(SmartlingClient smartlingClient,
                                  TextUnitSearcher textUnitSearcher,
                                  AssetPathAndTextUnitNameKeys assetPathAndTextUnitNameKeys,
                                  TextUnitBatchImporterService textUnitBatchImporterService,
                                  SmartlingResultProcessor resultProcessor);  ThirdPartyTMSSmartling(SmartlingClient smartlingClient,
                                  TextUnitSearcher textUnitSearcher,
                                  AssetPathAndTextUnitNameKeys assetPathAndTextUnitNameKeys,
                                  TextUnitBatchImporterService textUnitBatchImporterService,
                                  SmartlingResultProcessor resultProcessor,
                                  int batchSize); @Override ThirdPartyTMSImage uploadImage(String projectId, String name, byte[] content); @Override List<ThirdPartyTextUnit> getThirdPartyTextUnits(Repository repository, String projectId); @Override void createImageToTextUnitMappings(String projectId, List<ThirdPartyImageToTextUnit> thirdPartyImageToTextUnits); @Override void push(Repository repository,
                     String projectId,
                     String pluralSeparator,
                     String skipTextUnitsWithPattern,
                     String skipAssetsWithPathPattern,
                     List<String> optionList); @Override void pull(Repository repository,
                     String projectId,
                     String pluralSeparator,
                     Map<String, String> localeMapping,
                     String skipTextUnitsWithPattern,
                     String skipAssetsWithPathPattern,
                     List<String> optionList); @Override void pushTranslations(Repository repository,
                                 String projectId,
                                 String pluralSeparator,
                                 Map<String, String> localeMapping,
                                 String skipTextUnitsWithPattern,
                                 String skipAssetsWithPathPattern,
                                 List<String> optionList);  }