ThirdPartySyncCommand extends Command { @Override public void execute() throws CommandException { consoleWriter.newLine().a("Third party TMS synchronization for repository: ").fg(CYAN).a(repositoryParam).reset() .a(" project id: ").fg(CYAN).a(thirdPartyProjectId).reset() .a(" actions: ").fg(CYAN).a(Objects.toString(actions)).reset() .a(" plural-separator: ").fg(CYAN).a(Objects.toString(pluralSeparator)).reset() .a(" locale-mapping: ").fg(CYAN).a(Objects.toString(localeMapping)).reset() .a(" skip-text-units-with-pattern: ").fg(CYAN).a(Objects.toString(skipTextUnitsWithPattern)).reset() .a(" skip-assets-path-pattern: ").fg(CYAN).a(Objects.toString(skipAssetsWithPathPattern)).reset() .a(" options: ").fg(CYAN).a(Objects.toString(options)).println(2); Repository repository = commandHelper.findRepositoryByName(repositoryParam); PollableTask pollableTask = thirdPartyClient.sync(repository.getId(), thirdPartyProjectId, pluralSeparator, localeMapping, actions, skipTextUnitsWithPattern, skipAssetsWithPathPattern, options); commandHelper.waitForPollableTask(pollableTask.getId()); consoleWriter.fg(Ansi.Color.GREEN).newLine().a("Finished").println(2); }  @Override void execute();  }
@Test public void execute() throws Exception { String repoName = testIdWatcher.getEntityName("thirdpartysync_execute"); Repository repository = repositoryService.createRepository(repoName, repoName + " description", null, false); String projectId = testIdWatcher.getEntityName("projectId"); String pluralSeparator = "%s_"; String skipTextUnitPattern = "%skip_text_pattern"; String skipAssetPattern = "%skip_asset_pattern%"; List<String> options = Arrays.asList( "special-option=value@of%Option", "smartling-placeholder-custom=\\{\\{\\}\\}|\\{\\{?.+?\\}\\}?|\\%\\%\\(.+?\\)s|\\%\\(.+?\\)s|\\%\\(.+?\\)d|\\%\\%s|\\%s" ); getL10nJCommander().run("thirdparty-sync", "-r", repository.getName(), "-p", projectId, "-a", MAP_TEXTUNIT.name(), PUSH_SCREENSHOT.name(), "-ps", pluralSeparator, "-st", skipTextUnitPattern, "-sa", skipAssetPattern, "-o", options.get(0), options.get(1)); String output = outputCapture.toString(); assertThat(output).contains("repository: " + repository.getName()); assertThat(output).contains("project id: " + projectId); assertThat(output).contains("actions: " + Arrays.asList(ThirdPartySyncAction.MAP_TEXTUNIT, ThirdPartySyncAction.PUSH_SCREENSHOT).toString()); assertThat(output).contains("skip-text-units-with-pattern: " + skipTextUnitPattern); assertThat(output).contains("skip-assets-path-pattern: " + skipAssetPattern); assertThat(output).contains("options: " + options.toString()); waitForCondition("Ensure ThirdPartySyncJob gets executed", () -> testingJobListener.getExecuted().size() > 0); ThirdPartySyncJobInput jobInput = testingJobListener.getFirstInputMapAs(ThirdPartySyncJobInput.class); assertThat(jobInput).isNotNull(); assertThat(jobInput.getRepositoryId()).isEqualTo(repository.getId()); assertThat(jobInput.getThirdPartyProjectId()).isEqualTo(projectId); assertThat(jobInput.getActions()).containsExactlyInAnyOrder(MAP_TEXTUNIT, PUSH_SCREENSHOT); assertThat(jobInput.getPluralSeparator()).isEqualTo(pluralSeparator); assertThat(jobInput.getSkipTextUnitsWithPattern()).isEqualTo(skipTextUnitPattern); assertThat(jobInput.getSkipAssetsWithPathPattern()).isEqualTo(skipAssetPattern); assertThat(jobInput.getOptions()).containsExactlyInAnyOrderElementsOf(options); }