diff --git a/build.gradle b/build.gradle index 026901e94..1e0a4bc44 100755 --- a/build.gradle +++ b/build.gradle @@ -53,7 +53,7 @@ dependencies { testCompileOnly 'org.projectlombok:lombok:1.18.12' testAnnotationProcessor 'org.projectlombok:lombok:1.18.12' - implementation 'info.picocli:picocli:4.5.0' + implementation 'info.picocli:picocli:4.6.1' implementation 'com.github.crowdin:crowdin-api-client-java:1.3.2' diff --git a/src/main/java/com/crowdin/cli/client/CrowdinClientCore.java b/src/main/java/com/crowdin/cli/client/CrowdinClientCore.java index bb9614f1e..391803246 100644 --- a/src/main/java/com/crowdin/cli/client/CrowdinClientCore.java +++ b/src/main/java/com/crowdin/cli/client/CrowdinClientCore.java @@ -104,6 +104,13 @@ protected static T executeRequest(Map"; + String message = (error.message != null) ? error.message : ""; + searchErrorHandler(errorHandlers, error.getCode(), error.getMessage()); + } + } String errorMessage = "Wrong parameters: \n" + e.getErrors() .stream() .flatMap(holder -> holder.getError().getErrors() @@ -114,22 +121,26 @@ protected static T executeRequest(Map"; String message = (e.getError().message != null) ? e.getError().message : ""; - for (Map.Entry, R> errorHandler : errorHandlers.entrySet()) { - if (errorHandler.getKey().test(code, message)) { - throw errorHandler.getValue(); - } - } - for (Map.Entry, RuntimeException> errorHandler : standardErrorHandlers.entrySet()) { - if (errorHandler.getKey().test(code, message)) { - throw errorHandler.getValue(); - } - } + searchErrorHandler(errorHandlers, code, message); throw new RuntimeException(String.format("Error from server: ", code, message)); } catch (Exception e) { throw e; } } + private static void searchErrorHandler(Map, R> errorHandlers, String code, String message) throws R { + for (Map.Entry, R> errorHandler : errorHandlers.entrySet()) { + if (errorHandler.getKey().test(code, message)) { + throw errorHandler.getValue(); + } + } + for (Map.Entry, RuntimeException> errorHandler : standardErrorHandlers.entrySet()) { + if (errorHandler.getKey().test(code, message)) { + throw errorHandler.getValue(); + } + } + } + private static List unwrap(ResponseList list) { return list .getData() diff --git a/src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java b/src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java index 5d4c85665..c8b605f4a 100644 --- a/src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java +++ b/src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java @@ -159,9 +159,15 @@ public void editSource(Long fileId, List request) { } @Override - public void uploadTranslations(String languageId, UploadTranslationsRequest request) { + public void uploadTranslations(String languageId, UploadTranslationsRequest request) throws ResponseException { + Map, ResponseException> errorhandlers = new LinkedHashMap, ResponseException>() {{ + put((code, message) -> code.equals("0") && message.equals("File is not allowed for language"), + new WrongLanguageException()); + put((code, message) -> message.contains("File from storage with id #" + request.getStorageId() + " was not found"), + new RepeatException()); + }}; executeRequestWithPossibleRetry( - (code, message) -> message.contains("File from storage with id #" + request.getStorageId() + " was not found"), + errorhandlers, () -> this.client.getTranslationsApi() .uploadTranslations(this.projectId, languageId, request)); } diff --git a/src/main/java/com/crowdin/cli/client/CrowdinProjectInfo.java b/src/main/java/com/crowdin/cli/client/CrowdinProjectInfo.java index 1457dce31..e507ee423 100644 --- a/src/main/java/com/crowdin/cli/client/CrowdinProjectInfo.java +++ b/src/main/java/com/crowdin/cli/client/CrowdinProjectInfo.java @@ -46,6 +46,10 @@ void setLanguageMapping(LanguageMapping languageMapping) { this.languageMapping = languageMapping; } + /** + * Should be checked with isManagerAccess + * @return language mapping + */ public LanguageMapping getLanguageMapping() { return this.languageMapping; } diff --git a/src/main/java/com/crowdin/cli/client/ProjectClient.java b/src/main/java/com/crowdin/cli/client/ProjectClient.java index d02af78e8..4baa2e91e 100644 --- a/src/main/java/com/crowdin/cli/client/ProjectClient.java +++ b/src/main/java/com/crowdin/cli/client/ProjectClient.java @@ -41,7 +41,7 @@ public interface ProjectClient extends Client { void editSource(Long fileId, List request); - void uploadTranslations(String languageId, UploadTranslationsRequest request); + void uploadTranslations(String languageId, UploadTranslationsRequest request) throws ResponseException; ProjectBuild startBuildingTranslation(BuildProjectTranslationRequest request); diff --git a/src/main/java/com/crowdin/cli/client/WrongLanguageException.java b/src/main/java/com/crowdin/cli/client/WrongLanguageException.java new file mode 100644 index 000000000..ba2e3b71b --- /dev/null +++ b/src/main/java/com/crowdin/cli/client/WrongLanguageException.java @@ -0,0 +1,5 @@ +package com.crowdin.cli.client; + +public class WrongLanguageException extends ResponseException { + +} \ No newline at end of file diff --git a/src/main/java/com/crowdin/cli/commands/Actions.java b/src/main/java/com/crowdin/cli/commands/Actions.java index 81489df93..40c818ff9 100644 --- a/src/main/java/com/crowdin/cli/commands/Actions.java +++ b/src/main/java/com/crowdin/cli/commands/Actions.java @@ -21,7 +21,7 @@ public interface Actions { NewAction download( FilesInterface files, boolean noProgress, String languageId, boolean pseudo, String branchName, - boolean ignoreMatch, boolean isVerbose, boolean plainView + boolean ignoreMatch, boolean isVerbose, boolean plainView, boolean userServerSources ); NewAction generate(FilesInterface files, Path destinationPath, boolean skipGenerateDescription); @@ -35,7 +35,7 @@ NewAction listSources( boolean noProgress, boolean treeView, boolean plainView); NewAction listTranslations( - boolean noProgress, boolean treeView, boolean isLocal, boolean plainView); + boolean noProgress, boolean treeView, boolean isLocal, boolean plainView, boolean useServerSources, boolean withInContextLang); NewAction status( boolean noProgress, String languageId, boolean isVerbose, boolean showTranslated, boolean showApproved); @@ -78,7 +78,7 @@ NewAction tmDownload( NewAction downloadTargets( List targetNames, FilesInterface files, boolean noProgress, - List langIds, boolean isVerbose, boolean plainView, boolean debug); + List langIds, boolean isVerbose, boolean plainView, boolean debug, String branchName); NewAction checkNewVersion(); diff --git a/src/main/java/com/crowdin/cli/commands/actions/CliActions.java b/src/main/java/com/crowdin/cli/commands/actions/CliActions.java index 3e3e0db76..c1f5e3d9b 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/CliActions.java +++ b/src/main/java/com/crowdin/cli/commands/actions/CliActions.java @@ -24,9 +24,9 @@ public class CliActions implements Actions { @Override public NewAction download( FilesInterface files, boolean noProgress, String languageId, boolean pseudo, String branchName, - boolean ignoreMatch, boolean isVerbose, boolean plainView + boolean ignoreMatch, boolean isVerbose, boolean plainView, boolean useServerSources ) { - return new DownloadAction(files, noProgress, languageId, pseudo, branchName, ignoreMatch, isVerbose, plainView); + return new DownloadAction(files, noProgress, languageId, pseudo, branchName, ignoreMatch, isVerbose, plainView, useServerSources); } @Override @@ -55,9 +55,9 @@ public NewAction listSources( @Override public NewAction listTranslations( - boolean noProgress, boolean treeView, boolean isLocal, boolean plainView + boolean noProgress, boolean treeView, boolean isLocal, boolean plainView, boolean useServerSources, boolean withInContextLang ) { - return new ListTranslationsAction(noProgress, treeView, isLocal, plainView); + return new ListTranslationsAction(noProgress, treeView, isLocal, plainView, useServerSources, withInContextLang); } @Override @@ -157,9 +157,9 @@ public NewAction checkNewVersion() { @Override public NewAction downloadTargets( List targetNames, FilesInterface files, boolean noProgress, - List langIds, boolean isVerbose, boolean plainView, boolean debug + List langIds, boolean isVerbose, boolean plainView, boolean debug, String branchName ) { - return new DownloadTargetsAction(targetNames, files, noProgress, langIds, isVerbose, plainView, debug); + return new DownloadTargetsAction(targetNames, files, noProgress, langIds, isVerbose, plainView, debug, branchName); } diff --git a/src/main/java/com/crowdin/cli/commands/actions/DownloadAction.java b/src/main/java/com/crowdin/cli/commands/actions/DownloadAction.java index c258bf508..bce320035 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/DownloadAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/DownloadAction.java @@ -19,6 +19,7 @@ import com.crowdin.cli.utils.console.ConsoleSpinner; import com.crowdin.client.languages.model.Language; import com.crowdin.client.sourcefiles.model.Branch; +import com.crowdin.client.sourcefiles.model.FileInfo; import com.crowdin.client.translations.model.BuildProjectTranslationRequest; import com.crowdin.client.translations.model.CrowdinTranslationCreateProjectBuildForm; import com.crowdin.client.translations.model.ProjectBuild; @@ -56,12 +57,13 @@ class DownloadAction implements NewAction { private boolean ignoreMatch; private boolean isVerbose; private boolean plainView; + private boolean useServerSources; private Outputter out; public DownloadAction( FilesInterface files, boolean noProgress, String languageId, boolean pseudo, String branchName, - boolean ignoreMatch, boolean isVerbose, boolean plainView + boolean ignoreMatch, boolean isVerbose, boolean plainView, boolean useServerSources ) { this.files = files; this.noProgress = noProgress || plainView; @@ -71,6 +73,7 @@ public DownloadAction( this.ignoreMatch = ignoreMatch; this.isVerbose = isVerbose; this.plainView = plainView; + this.useServerSources = useServerSources; } @Override @@ -91,6 +94,10 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) { } } + if (useServerSources && !pb.getPreserveHierarchy() && !plainView) { + out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.download_translations.preserve_hierarchy_warning"))); + } + PlaceholderUtil placeholderUtil = new PlaceholderUtil( project.getSupportedLanguages(), project.getProjectLanguages(true), pb.getBasePath()); @@ -103,6 +110,8 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) { .map(br -> project.findBranchByName(br) .orElseThrow(() -> new RuntimeException(RESOURCE_BUNDLE.getString("error.not_found_branch")))); + Map serverSources = ProjectFilesUtils.buildFilePaths(project.getDirectories(), project.getFiles()); + LanguageMapping serverLanguageMapping = project.getLanguageMapping(); Map>, List>> fileBeansWithDownloadedFiles = new TreeMap<>(); @@ -120,7 +129,7 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) { : RequestBuilder.crowdinTranslationCreateProjectPseudoBuildForm(true, null, null, null, null); Pair> downloadedFiles = this.download(request, client, pb.getBasePath()); for (FileBean fb : pb.getFiles()) { - Map filesWithMapping = this.getFiles(fb, pb.getBasePath(), serverLanguageMapping, forLanguages, placeholderUtil); + Map filesWithMapping = this.getFiles(fb, pb.getBasePath(), serverLanguageMapping, forLanguages, placeholderUtil, new ArrayList<>(serverSources.keySet()), pb.getPreserveHierarchy()); fileBeansWithDownloadedFiles.putIfAbsent(downloadedFiles, new ArrayList<>()); fileBeansWithDownloadedFiles.get(downloadedFiles).add(filesWithMapping); } @@ -163,7 +172,7 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) { && fb.getExportApprovedOnly() == downloadConfiguration.getRight()) { Map filesWithMapping = - this.getFiles(fb, pb.getBasePath(), serverLanguageMapping, forLanguages, placeholderUtil); + this.getFiles(fb, pb.getBasePath(), serverLanguageMapping, forLanguages, placeholderUtil, new ArrayList<>(serverSources.keySet()), pb.getPreserveHierarchy()); fileBeansWithDownloadedFiles.putIfAbsent(downloadedFiles, new ArrayList<>()); fileBeansWithDownloadedFiles.get(downloadedFiles).add(filesWithMapping); } @@ -297,12 +306,20 @@ private Pair> download(BuildProjectTranslationRequest request } private Map getFiles( - FileBean fb, String basePath, LanguageMapping serverLanguageMapping, List forLanguages, PlaceholderUtil placeholderUtil + FileBean fb, String basePath, LanguageMapping serverLanguageMapping, List forLanguages, PlaceholderUtil placeholderUtil, List allServerSources, boolean preserveHierarchy ) { List sources = SourcesUtils.getFiles(basePath, fb.getSource(), fb.getIgnore(), placeholderUtil) .map(File::getAbsolutePath) .collect(Collectors.toList()); + if (useServerSources) { + List serverSources = SourcesUtils.filterProjectFiles(allServerSources, fb.getSource(), fb.getIgnore(), preserveHierarchy, placeholderUtil) + .stream() + .map(s -> Utils.joinPaths(basePath, s)) + .filter(s -> !sources.contains(s)) + .collect(Collectors.toList()); + sources.addAll(serverSources); + } LanguageMapping localLanguageMapping = LanguageMapping.fromConfigFileLanguageMapping(fb.getLanguagesMapping()); LanguageMapping languageMapping = LanguageMapping.populate(localLanguageMapping, serverLanguageMapping); Map translationReplace = diff --git a/src/main/java/com/crowdin/cli/commands/actions/DownloadTargetsAction.java b/src/main/java/com/crowdin/cli/commands/actions/DownloadTargetsAction.java index b4aefca4f..b43dd60a2 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/DownloadTargetsAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/DownloadTargetsAction.java @@ -21,6 +21,7 @@ import com.crowdin.client.translations.model.ExportProjectTranslationRequest; import lombok.NonNull; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import java.io.IOException; @@ -29,6 +30,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; @@ -46,10 +48,11 @@ class DownloadTargetsAction implements NewAction targetNames, FilesInterface files, boolean noProgress, - List langIds, boolean isVerbose, boolean plainView, boolean debug + List langIds, boolean isVerbose, boolean plainView, boolean debug, String branchName ) { this.targetNames = targetNames; this.files = files; @@ -58,6 +61,7 @@ public DownloadTargetsAction( this.isVerbose = isVerbose; this.plainView = plainView; this.debug = debug; + this.branchName = branchName; } @Override @@ -72,12 +76,26 @@ public void act(Outputter out, PropertiesWithTargets pb, ProjectClient client) { new PlaceholderUtil( project.getSupportedLanguages(), project.getProjectLanguages(true), pb.getBasePath()); - Map projectFiles = ProjectFilesUtils.buildFilePaths(project.getDirectories(), project.getBranches(), project.getFileInfos()) + if (StringUtils.isNotEmpty(branchName) && !project.findBranchByName(branchName).isPresent()) { + throw new RuntimeException(RESOURCE_BUNDLE.getString("error.not_found_branch")); + } + Optional branchId = project.findBranchByName(branchName).map(Branch::getId); + + Map projectFiles = (branchId.isPresent() + ? ProjectFilesUtils + .buildFilePaths(project.getDirectories(), ProjectFilesUtils.filterFilesByBranch(project.getFileInfos(), branchId.get())) + : ProjectFilesUtils.buildFilePaths(project.getDirectories(), project.getBranches(), project.getFileInfos())) .entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getId())); - Map projectDirs = ProjectFilesUtils.buildDirectoryPaths(project.getDirectories(), project.getBranches()) - .entrySet().stream() + + Map projectDirs = (branchId.isPresent() + ? ProjectFilesUtils.buildDirectoryPaths(project.getDirectories()) + .entrySet().stream() + .filter(entry -> branchId.get().equals(project.getDirectories().get(entry.getKey()).getBranchId())) + : ProjectFilesUtils.buildDirectoryPaths(project.getDirectories(), project.getBranches()) + .entrySet().stream()) .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); + Map projectBranches = project.getBranches() .values().stream() .collect(Collectors.toMap(Branch::getName, Branch::getId)); @@ -188,7 +206,7 @@ public void act(Outputter out, PropertiesWithTargets pb, ProjectClient client) { for (String langId : specifiedLangs) { ExportProjectTranslationRequest request = RequestBuilder.exportProjectTranslation(templateRequest); request.setTargetLanguageId(langId); - String targetFileLang = placeholderUtil.replaceLanguageDependentPlaceholders(fb.getFile(), projectLanguages.get(langId)); + String targetFileLang = placeholderUtil.replaceLanguageDependentPlaceholders(fb.getFile(), project.getLanguageMapping(), projectLanguages.get(langId)); builtRequests.add(Pair.of(targetFileLang, request)); } diff --git a/src/main/java/com/crowdin/cli/commands/actions/GlossaryListAction.java b/src/main/java/com/crowdin/cli/commands/actions/GlossaryListAction.java index 1d5e5b1ad..8a8ba6e74 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/GlossaryListAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/GlossaryListAction.java @@ -31,12 +31,13 @@ public void act(Outputter out, BaseProperties pb, ClientGlossary client) { if (!plainView) { out.println(OK.withIcon( String.format(RESOURCE_BUNDLE.getString("message.glossary.list"), glossary.getName(), glossary.getId(), glossary.getTerms()))); - if (isVerbose && (glossary.getTerms() == null || glossary.getTerms() > 0)) { + if (isVerbose && mayHaveTerms(glossary)) { try { List terms = client.listTerms(glossary.getId()); for (Term term : terms) { + String description = (term.getDescription() != null) ? term.getDescription() : ""; out.println(String.format( - RESOURCE_BUNDLE.getString("message.glossary.list_term"), term.getId(), term.getText(), term.getDescription())); + RESOURCE_BUNDLE.getString("message.glossary.list_term"), term.getId(), term.getText(), description)); } } catch (Exception e) { out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("error.glossary.no_permission"))); @@ -47,4 +48,8 @@ public void act(Outputter out, BaseProperties pb, ClientGlossary client) { } } } + + private boolean mayHaveTerms(Glossary glossary) { + return glossary != null && (glossary.getTerms() == null || glossary.getTerms() > 0); + } } diff --git a/src/main/java/com/crowdin/cli/commands/actions/ListTranslationsAction.java b/src/main/java/com/crowdin/cli/commands/actions/ListTranslationsAction.java index 5fead1ca8..803d59a34 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/ListTranslationsAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/ListTranslationsAction.java @@ -1,15 +1,17 @@ package com.crowdin.cli.commands.actions; -import com.crowdin.cli.client.CrowdinProject; +import com.crowdin.cli.client.CrowdinProjectFull; import com.crowdin.cli.client.ProjectClient; import com.crowdin.cli.commands.NewAction; import com.crowdin.cli.commands.Outputter; import com.crowdin.cli.commands.functionality.DryrunTranslations; +import com.crowdin.cli.commands.functionality.ProjectFilesUtils; import com.crowdin.cli.properties.PropertiesWithFiles; import com.crowdin.cli.utils.PlaceholderUtil; import com.crowdin.cli.utils.console.ConsoleSpinner; +import com.crowdin.client.sourcefiles.model.File; -import java.util.Optional; +import java.util.Map; import static com.crowdin.cli.BaseCli.RESOURCE_BUNDLE; import static com.crowdin.cli.utils.console.ExecutionStatus.WARNING; @@ -20,18 +22,22 @@ class ListTranslationsAction implements NewAction files = ProjectFilesUtils.buildFilePaths(project.getDirectories(), project.getBranches(), project.getFiles()); + PlaceholderUtil placeholderUtil = new PlaceholderUtil( project.getSupportedLanguages(), project.getProjectLanguages(!isLocal), pb.getBasePath()); - (new DryrunTranslations(pb, project.getLanguageMapping(), placeholderUtil, Optional.empty(), false)) + (new DryrunTranslations(pb, project.getLanguageMapping(), placeholderUtil, project.getProjectLanguages(withInContextLang), false, files, useServerSources)) .run(out, treeView, plainView); } } diff --git a/src/main/java/com/crowdin/cli/commands/actions/UploadTranslationsAction.java b/src/main/java/com/crowdin/cli/commands/actions/UploadTranslationsAction.java index c40ef26c6..c780220e8 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/UploadTranslationsAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/UploadTranslationsAction.java @@ -3,6 +3,7 @@ import com.crowdin.cli.client.CrowdinProjectFull; import com.crowdin.cli.client.LanguageMapping; import com.crowdin.cli.client.ProjectClient; +import com.crowdin.cli.client.WrongLanguageException; import com.crowdin.cli.commands.NewAction; import com.crowdin.cli.commands.Outputter; import com.crowdin.cli.commands.functionality.ProjectFilesUtils; @@ -17,6 +18,7 @@ import com.crowdin.cli.utils.concurrency.ConcurrencyUtil; import com.crowdin.cli.utils.console.ConsoleSpinner; import com.crowdin.client.languages.model.Language; +import com.crowdin.client.sourcefiles.model.File; import com.crowdin.client.sourcefiles.model.FileInfo; import com.crowdin.client.translations.model.UploadTranslationsRequest; import org.apache.commons.lang3.StringUtils; @@ -78,7 +80,7 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) { LanguageMapping serverLanguageMapping = project.getLanguageMapping(); - Map paths = ProjectFilesUtils.buildFilePaths(project.getDirectories(), project.getBranches(), project.getFiles()); + Map paths = ProjectFilesUtils.buildFilePaths(project.getDirectories(), project.getBranches(), project.getFiles()); List languages = (languageId != null) ? project.findLanguageById(languageId, true) @@ -177,7 +179,13 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) { } try { for (Language lang : langs) { - client.uploadTranslations(lang.getId(), request); + try { + client.uploadTranslations(lang.getId(), request); + } catch (WrongLanguageException e) { + out.println(WARNING.withIcon(String.format( + RESOURCE_BUNDLE.getString("message.warning.file_not_uploaded_cause_of_language"), + StringUtils.removeStart(translationFile.getAbsolutePath(), pb.getBasePath()), lang.getName()))); + } } } catch (Exception e) { containsErrors.set(true); diff --git a/src/main/java/com/crowdin/cli/commands/functionality/DryrunTranslations.java b/src/main/java/com/crowdin/cli/commands/functionality/DryrunTranslations.java index d092b8918..862ac276c 100644 --- a/src/main/java/com/crowdin/cli/commands/functionality/DryrunTranslations.java +++ b/src/main/java/com/crowdin/cli/commands/functionality/DryrunTranslations.java @@ -5,12 +5,13 @@ import com.crowdin.cli.utils.PlaceholderUtil; import com.crowdin.cli.utils.Utils; import com.crowdin.client.languages.model.Language; +import com.crowdin.client.sourcefiles.model.File; import org.apache.commons.lang3.StringUtils; +import java.util.ArrayList; import java.util.List; -import java.util.Optional; +import java.util.Map; import java.util.stream.Collectors; -import java.util.stream.Stream; public class DryrunTranslations extends Dryrun { @@ -18,42 +19,60 @@ public class DryrunTranslations extends Dryrun { private PlaceholderUtil placeholderUtil; private boolean filesMustExist; private LanguageMapping projectLanguageMapping; - private Optional language; + private List languages; + private Map projectSources; + private boolean useServerSources; public DryrunTranslations( - PropertiesWithFiles pb, LanguageMapping projectLanguageMapping, - PlaceholderUtil placeholderUtil, Optional language, boolean filesMustExist + PropertiesWithFiles pb, LanguageMapping projectLanguageMapping, PlaceholderUtil placeholderUtil, + List languages, boolean filesMustExist, Map projectSources, boolean useServerSources ) { super("message.translation_file"); this.pb = pb; this.placeholderUtil = placeholderUtil; this.filesMustExist = filesMustExist; this.projectLanguageMapping = projectLanguageMapping; - this.language = language; + this.languages = languages; + this.projectSources = projectSources; + this.useServerSources = useServerSources; } @Override protected List getFiles() { return pb.getFiles() .stream() - .flatMap(file -> SourcesUtils.getFiles(pb.getBasePath(), file.getSource(), file.getIgnore(), placeholderUtil) - .map(source -> { - String fileSource = StringUtils.removeStart(source.getAbsolutePath(), pb.getBasePath()); - String translation = TranslationsUtils.replaceDoubleAsterisk(file.getSource(), file.getTranslation(), fileSource); - return placeholderUtil.replaceFileDependentPlaceholders(translation, source); - }) - .flatMap(translation -> { - LanguageMapping localLanguageMapping = LanguageMapping.fromConfigFileLanguageMapping(file.getLanguagesMapping()); - LanguageMapping languageMapping = LanguageMapping.populate(localLanguageMapping, projectLanguageMapping); - return language - .map(l -> Stream.of(placeholderUtil.replaceLanguageDependentPlaceholders(translation, languageMapping, l))) - .orElseGet(() -> placeholderUtil.replaceLanguageDependentPlaceholders(translation, languageMapping).stream()); - }) - .map(translation -> PropertiesBeanUtils.useTranslationReplace(translation, file.getTranslationReplace())) - ) + .flatMap(fileBean -> { + List foundSources = SourcesUtils.getFiles(pb.getBasePath(), fileBean.getSource(), fileBean.getIgnore(), placeholderUtil) + .collect(Collectors.toList()); + if (useServerSources) { + List serverSources = SourcesUtils.filterProjectFiles(new ArrayList<>(projectSources.keySet()), fileBean.getSource(), fileBean.getIgnore(), pb.getPreserveHierarchy(), placeholderUtil) + .stream() + .map(s -> new java.io.File(Utils.joinPaths(pb.getBasePath(), s))) + .filter(s -> !foundSources.contains(s)) + .collect(Collectors.toList()); + foundSources.addAll(serverSources); + } + return foundSources.stream() + .flatMap(source -> { + String fileSource = StringUtils.removeStart(source.getAbsolutePath(), pb.getBasePath()); + String translation = TranslationsUtils.replaceDoubleAsterisk(fileBean.getSource(), fileBean.getTranslation(), fileSource); + String translation2 = placeholderUtil.replaceFileDependentPlaceholders(translation, source); + LanguageMapping localLanguageMapping = LanguageMapping.fromConfigFileLanguageMapping(fileBean.getLanguagesMapping()); + LanguageMapping languageMapping = LanguageMapping.populate(localLanguageMapping, projectLanguageMapping); + File projectSource = projectSources.get(fileSource); + return languages.stream() + .filter(l -> containsExcludedLanguage(projectSource, l)) + .map(l -> placeholderUtil.replaceLanguageDependentPlaceholders(translation2, languageMapping, l)) + .map(file -> PropertiesBeanUtils.useTranslationReplace(file, fileBean.getTranslationReplace())); + }); + }) .distinct() .filter(file -> (!filesMustExist) || new java.io.File(pb.getBasePath() + StringUtils.removeStart(file, Utils.PATH_SEPARATOR)).exists()) .map(source -> StringUtils.removeStart(source, pb.getBasePath())) .collect(Collectors.toList()); } + + private boolean containsExcludedLanguage(File sourceFile, Language language) { + return sourceFile == null || sourceFile.getExcludedTargetLanguages() == null || !sourceFile.getExcludedTargetLanguages().contains(language.getId()); + } } diff --git a/src/main/java/com/crowdin/cli/commands/functionality/ProjectFilesUtils.java b/src/main/java/com/crowdin/cli/commands/functionality/ProjectFilesUtils.java index d30526958..582ebbd67 100644 --- a/src/main/java/com/crowdin/cli/commands/functionality/ProjectFilesUtils.java +++ b/src/main/java/com/crowdin/cli/commands/functionality/ProjectFilesUtils.java @@ -14,26 +14,27 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; public class ProjectFilesUtils { - public static Map buildFilePaths( - Map directories, Map branchNames, List files + public static Map buildFilePaths( + Map directories, Map branchNames, List files ) { Map directoryPaths = buildDirectoryPaths(directories, branchNames); - Map filePathsToId = new HashMap<>(); + Map filePathsToId = new HashMap<>(); files.forEach(fe -> filePathsToId.put(getParentId(fe).map(directoryPaths::get).orElse("") + fe.getName(), fe)); return filePathsToId; } - public static Map buildFilePaths( - Map directories, List files + public static Map buildFilePaths( + Map directories, List files ) { Map directoryPaths = buildDirectoryPaths(directories); - Map filePathsToId = new HashMap<>(); + Map filePathsToId = new HashMap<>(); files.forEach(fe -> filePathsToId.put(Optional.ofNullable(fe.getDirectoryId()).map(directoryPaths::get).orElse("") + fe.getName(), fe)); return filePathsToId; } @@ -96,6 +97,12 @@ public static String buildBranchPath(Long branchId, Map branchName return ((branchId != null) ? branchNames.get(branchId).getName() + Utils.PATH_SEPARATOR : ""); } + public static List filterFilesByBranch(List files, Long branchId) { + return files.stream() + .filter(f -> Objects.equals(branchId, f.getBranchId())) + .collect(Collectors.toList()); + } + private static Optional getParentId(FileInfo fe) { return (fe.getDirectoryId() != null) ? Optional.of(fe.getDirectoryId()) : Optional.ofNullable(fe.getBranchId()); } diff --git a/src/main/java/com/crowdin/cli/commands/functionality/SourcesUtils.java b/src/main/java/com/crowdin/cli/commands/functionality/SourcesUtils.java index aaf49e715..fd3b5fec0 100644 --- a/src/main/java/com/crowdin/cli/commands/functionality/SourcesUtils.java +++ b/src/main/java/com/crowdin/cli/commands/functionality/SourcesUtils.java @@ -143,6 +143,8 @@ private static String translateToRegex(String node) { .replace(ROUND_BRACKET_OPEN, ESCAPE_ROUND_BRACKET_OPEN); node = node .replace(ROUND_BRACKET_CLOSE, ESCAPE_ROUND_BRACKET_CLOSE); + node = node + .replace(".+/", "(.+/)?"); node = "^" + node + "$"; return node; } diff --git a/src/main/java/com/crowdin/cli/commands/picocli/DownloadSubcommand.java b/src/main/java/com/crowdin/cli/commands/picocli/DownloadSubcommand.java index 5b1e39d13..20109fe34 100644 --- a/src/main/java/com/crowdin/cli/commands/picocli/DownloadSubcommand.java +++ b/src/main/java/com/crowdin/cli/commands/picocli/DownloadSubcommand.java @@ -50,11 +50,14 @@ class DownloadSubcommand extends ActCommandWithFiles { @CommandLine.Option(names = {"--export-only-approved"}, descriptionKey = "params.exportOnlyApproved") protected Boolean exportApprovedOnly; + @CommandLine.Option(names = {"--all"}) + protected boolean all; + @Override protected NewAction getAction(Actions actions) { return (dryrun) - ? actions.listTranslations(noProgress, treeView, false, plainView) - : actions.download(new FsFiles(), noProgress, languageId, pseudo, branchName, ignoreMatch, isVerbose, plainView); + ? actions.listTranslations(noProgress, treeView, false, plainView, all, true) + : actions.download(new FsFiles(), noProgress, languageId, pseudo, branchName, ignoreMatch, isVerbose, plainView, all); } @CommandLine.Option(names = {"--plain"}, descriptionKey = "crowdin.list.usage.plain") diff --git a/src/main/java/com/crowdin/cli/commands/picocli/DownloadTargetsSubcommand.java b/src/main/java/com/crowdin/cli/commands/picocli/DownloadTargetsSubcommand.java index 367faa533..91cd4c693 100644 --- a/src/main/java/com/crowdin/cli/commands/picocli/DownloadTargetsSubcommand.java +++ b/src/main/java/com/crowdin/cli/commands/picocli/DownloadTargetsSubcommand.java @@ -9,7 +9,6 @@ import com.crowdin.cli.properties.PropertiesWithTargets; import picocli.CommandLine; -import java.util.ArrayList; import java.util.List; @CommandLine.Command( @@ -33,10 +32,13 @@ public class DownloadTargetsSubcommand extends ActCommandWithTargets { @CommandLine.Option(names = {"--export-only-approved"}, descriptionKey = "params.exportOnlyApproved") protected Boolean exportApprovedOnly; + @CommandLine.Option(names = {"--branch", "-b"}, paramLabel = "...", descriptionKey = "branch") + protected String branchName; + @Override protected NewAction getAction(Actions actions) { return actions.downloadTargets( - targetNames, new FsFiles(), noProgress, langIds, isVerbose, plainView, debug); + targetNames, new FsFiles(), noProgress, langIds, isVerbose, plainView, debug, branchName); } @CommandLine.Option(names = {"--plain"}, descriptionKey = "crowdin.list.usage.plain") diff --git a/src/main/java/com/crowdin/cli/commands/picocli/ListTranslationsSubcommand.java b/src/main/java/com/crowdin/cli/commands/picocli/ListTranslationsSubcommand.java index bd6784642..112545f89 100644 --- a/src/main/java/com/crowdin/cli/commands/picocli/ListTranslationsSubcommand.java +++ b/src/main/java/com/crowdin/cli/commands/picocli/ListTranslationsSubcommand.java @@ -16,7 +16,7 @@ class ListTranslationsSubcommand extends ActCommandWithFiles { @Override protected NewAction getAction(Actions actions) { - return actions.listTranslations(this.noProgress, this.treeView, false, this.plainView); + return actions.listTranslations(this.noProgress, this.treeView, false, this.plainView, false, true); } @CommandLine.Option(names = {"--plain"}, descriptionKey = "crowdin.list.usage.plain") diff --git a/src/main/java/com/crowdin/cli/commands/picocli/UploadTranslationsSubcommand.java b/src/main/java/com/crowdin/cli/commands/picocli/UploadTranslationsSubcommand.java index 3d2813dd8..feb4146c8 100644 --- a/src/main/java/com/crowdin/cli/commands/picocli/UploadTranslationsSubcommand.java +++ b/src/main/java/com/crowdin/cli/commands/picocli/UploadTranslationsSubcommand.java @@ -33,7 +33,7 @@ class UploadTranslationsSubcommand extends ActCommandWithFiles { @Override protected NewAction getAction(Actions actions) { return (dryrun) - ? actions.listTranslations(noProgress, treeView, true, plainView) + ? actions.listTranslations(noProgress, treeView, true, plainView, false, false) : actions.uploadTranslations(noProgress, languageId, branch, importEqSuggestions, autoApproveImported, debug, plainView); } diff --git a/src/main/resources/messages/messages.properties b/src/main/resources/messages/messages.properties index b56d83c40..1fe45aee9 100755 --- a/src/main/resources/messages/messages.properties +++ b/src/main/resources/messages/messages.properties @@ -39,6 +39,7 @@ crowdin.download.usage.customSynopsis=@|fg(green) crowdin |@(@|fg(green) downloa crowdin.download.ignore-match=Ignore warning message about a configuration change crowdin.download.language=Use this option to download translations for a single specified language. Default: all crowdin.download.pseudo=Download pseudo-localized translation files +crowdin.download.all=Download files even if local sources are absent # CROWDIN DOWNLOAD TARGETS COMMAND crowdin.download.targets.usage.description=Download latest translation from Crowdin to the specified target file @@ -375,6 +376,7 @@ message.no_targets_to_exec=Couldn't find any targets to download message.no_target_to_exec=Couldn't find @|bold '%s'|@ target to download message.download_sources.preserve_hierarchy_warning=Because the @|bold 'preserve_hierarchy'|@ parameter is set to 'false':\n\t- CLI might download some unexpected files that match the pattern;\n\t- Source file hierarchy may not be preserved and will be the same as in Crowdin. +message.download_translations.preserve_hierarchy_warning=Because the @|bold 'preserve_hierarchy'|@ parameter is set to 'false' CLI might download some unexpected files that match the pattern message.source_string_uploaded=Source string uploaded successfully message.source_string_for_file_uploaded=Source string uploaded successfully to the file @|bold '%s'|@ @@ -407,6 +409,7 @@ message.no_manager_access_for_excluded_languages=You need to have @|yellow manag message.warning.not_yml=File @|bold '%s'|@ is not a YAML or YML file message.warning.browser_not_found=Error opening web browser. Please open the following link manually:\n@|bold %s|@ +message.warning.file_not_uploaded_cause_of_language=Translation file @|yellow,bold '%s'|@ @|yellow hasn't been uploaded|@ since @|bold %s|@ is not enabled as a target language for the source file in your Crowdin project message.spinner.fetching_project_info=Fetching project info message.spinner.building_translation=Building translation diff --git a/src/test/java/com/crowdin/cli/client/CrowdinProjectClientTest.java b/src/test/java/com/crowdin/cli/client/CrowdinProjectClientTest.java index 898e66806..faf185d65 100644 --- a/src/test/java/com/crowdin/cli/client/CrowdinProjectClientTest.java +++ b/src/test/java/com/crowdin/cli/client/CrowdinProjectClientTest.java @@ -405,7 +405,7 @@ public void testAddSource() throws ResponseException { } @Test - public void testUploadTranslations() { + public void testUploadTranslations() throws ResponseException { UploadTranslationsResponseObject response = new UploadTranslationsResponseObject() {{ setData(new UploadTranslationsResponse()); }}; @@ -420,7 +420,7 @@ public void testUploadTranslations() { } @Test - public void testUploadTranslationsWithRepeat() { + public void testUploadTranslationsWithRepeat() throws ResponseException { UploadTranslationsResponseObject response = new UploadTranslationsResponseObject() {{ setData(new UploadTranslationsResponse()); }}; diff --git a/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java b/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java index a3197f843..56a66b64e 100644 --- a/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java +++ b/src/test/java/com/crowdin/cli/commands/actions/CliActionsTest.java @@ -14,7 +14,7 @@ public class CliActionsTest { @Test public void testDownload() { - assertNotNull(actions.download(new FsFiles(), false, null, false, null, false, false, false)); + assertNotNull(actions.download(new FsFiles(), false, null, false, null, false, false, false, false)); } @Test @@ -39,7 +39,7 @@ public void testListSources() { @Test public void testListTranslations() { - assertNotNull(actions.listTranslations(false, false, false, false)); + assertNotNull(actions.listTranslations(false, false, false, false, false, false)); } @Test diff --git a/src/test/java/com/crowdin/cli/commands/actions/DownloadActionTest.java b/src/test/java/com/crowdin/cli/commands/actions/DownloadActionTest.java index 00993d3aa..80c6d4d43 100644 --- a/src/test/java/com/crowdin/cli/commands/actions/DownloadActionTest.java +++ b/src/test/java/com/crowdin/cli/commands/actions/DownloadActionTest.java @@ -87,7 +87,7 @@ public void testEmptyProject() throws ResponseException, IOException { })); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -137,7 +137,7 @@ public void testProjectOneFittingFile() throws ResponseException, IOException { })); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -198,7 +198,7 @@ public void testProjectOneFittingFile_WithExportApprovedOnly_WithSkipUntranslate })); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -258,7 +258,7 @@ public void testProjectOneFittingFile_LongBuild() throws ResponseException, IOEx })); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -319,7 +319,7 @@ public void testProjectOneFittingOneUnfittingFile_LongBuild() throws ResponseExc })); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -380,7 +380,7 @@ public void testProjectOneFittingOneUnfittingOneWithUnfoundSourceFile_LongBuild( })); NewAction action = - new DownloadAction(files, false, null, false, null, false, true, false); + new DownloadAction(files, false, null, false, null, false, true, false, false); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -442,7 +442,7 @@ public void testProjectOneFittingFile_WithLanguageMapping() throws ResponseExcep })); NewAction action = - new DownloadAction(files, false, null, false, null, false, true, false); + new DownloadAction(files, false, null, false, null, false, true, false, false); action.act(Outputter.getDefault(), pb, client); verify(client).downloadFullProject(); @@ -487,7 +487,7 @@ public void testProjectOneFittingFile_FailBuild() throws ResponseException, IOEx FilesInterface files = mock(FilesInterface.class); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), pb, client)); verify(client).downloadFullProject(); @@ -513,7 +513,7 @@ public void testProjectOneFittingFile_failDownloadProject() throws ResponseExcep FilesInterface files = mock(FilesInterface.class); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), pb, client)); verify(client).downloadFullProject(); @@ -561,7 +561,7 @@ public void testProjectOneFittingFile_failDeleteFile() throws ResponseException, .when(files).deleteFile(any()); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); // assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), pb, client)); action.act(Outputter.getDefault(), pb, client); @@ -606,7 +606,7 @@ public void testProjectOneFittingFile_failDownloadingException() throws Response FilesInterface files = mock(FilesInterface.class); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), pb, client)); verify(client).downloadFullProject(); @@ -644,7 +644,7 @@ public void testProjectOneFittingFile_failWritingFile() throws ResponseException .writeToFile(any(), any()); NewAction action = - new DownloadAction(files, false, null, false, null, false, false, false); + new DownloadAction(files, false, null, false, null, false, false, false, false); assertThrows(RuntimeException.class, () -> action.act(Outputter.getDefault(), pb, client)); verify(client).downloadFullProject(); diff --git a/src/test/java/com/crowdin/cli/commands/actions/ListTranslationsActionTest.java b/src/test/java/com/crowdin/cli/commands/actions/ListTranslationsActionTest.java index 7837bedaa..bbf85ca09 100644 --- a/src/test/java/com/crowdin/cli/commands/actions/ListTranslationsActionTest.java +++ b/src/test/java/com/crowdin/cli/commands/actions/ListTranslationsActionTest.java @@ -42,14 +42,14 @@ public void testForServerInteraction() throws ResponseException { .setBasePath(project.getBasePath()); PropertiesWithFiles pb = pbBuilder.build(); ProjectClient client = mock(ProjectClient.class); - when(client.downloadProjectWithLanguages()) + when(client.downloadFullProject()) .thenReturn(ProjectBuilder.emptyProject(Long.parseLong(pb.getProjectId())) .addFile("first.po", "gettext", 101L, null, null).build()); - NewAction action = new ListTranslationsAction(false, false, false, false); + NewAction action = new ListTranslationsAction(false, false, false, false, false, false); action.act(Outputter.getDefault(), pb, client); - verify(client).downloadProjectWithLanguages(); + verify(client).downloadFullProject(); verifyNoMoreInteractions(client); } } diff --git a/src/test/java/com/crowdin/cli/commands/picocli/DownloadSubcommandTest.java b/src/test/java/com/crowdin/cli/commands/picocli/DownloadSubcommandTest.java index d92ec4b6e..6e9a38bb1 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/DownloadSubcommandTest.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/DownloadSubcommandTest.java @@ -12,7 +12,7 @@ public class DownloadSubcommandTest extends PicocliTestUtils { public void testDownload() { this.execute(CommandNames.DOWNLOAD, "--debug"); verify(actionsMock) - .download(any(), anyBoolean(), any(), anyBoolean(), any(), anyBoolean(), anyBoolean(), anyBoolean()); + .download(any(), anyBoolean(), any(), anyBoolean(), any(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()); this.check(true); } @@ -20,7 +20,7 @@ public void testDownload() { public void testDownloadDryrun() { this.execute(CommandNames.DOWNLOAD, "--dryrun"); verify(actionsMock) - .listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()); + .listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()); this.check(true); } } diff --git a/src/test/java/com/crowdin/cli/commands/picocli/ListTranslationsSubcommandTest.java b/src/test/java/com/crowdin/cli/commands/picocli/ListTranslationsSubcommandTest.java index 3f39c1dc4..13f4edfb9 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/ListTranslationsSubcommandTest.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/ListTranslationsSubcommandTest.java @@ -11,7 +11,7 @@ public class ListTranslationsSubcommandTest extends PicocliTestUtils { public void testListTranslations() { this.execute(CommandNames.LIST, CommandNames.LIST_TRANSLATIONS); verify(actionsMock) - .listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()); + .listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()); this.check(true); } } diff --git a/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java b/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java index 382ba93f4..830a9991a 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/PicocliTestUtils.java @@ -58,7 +58,7 @@ void mockActions() { actionsMock = mock(Actions.class); actionMock = mock(NewAction.class); - when(actionsMock.download(any(), anyBoolean(), any(), anyBoolean(), any(), anyBoolean(), anyBoolean(), anyBoolean())) + when(actionsMock.download(any(), anyBoolean(), any(), anyBoolean(), any(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean())) .thenReturn(actionMock); when(actionsMock.generate(any(), any(), anyBoolean())) .thenReturn(actionMock); @@ -68,7 +68,7 @@ void mockActions() { .thenReturn(actionMock); when(actionsMock.listSources(anyBoolean(), anyBoolean(), anyBoolean())) .thenReturn(actionMock); - when(actionsMock.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean())) + when(actionsMock.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean())) .thenReturn(actionMock); when(actionsMock.status(anyBoolean(), any(), anyBoolean(), anyBoolean(), anyBoolean())) .thenReturn(actionMock); diff --git a/src/test/java/com/crowdin/cli/commands/picocli/UploadTranslationsSubcommandTest.java b/src/test/java/com/crowdin/cli/commands/picocli/UploadTranslationsSubcommandTest.java index ba7254b2e..263fccfb3 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/UploadTranslationsSubcommandTest.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/UploadTranslationsSubcommandTest.java @@ -22,7 +22,7 @@ public void testUploadTranslations() { public void testUploadTranslationsDryrun() { this.execute(CommandNames.UPLOAD, CommandNames.UPLOAD_TRANSLATIONS, "--dryrun"); verify(actionsMock) - .listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()); + .listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()); this.check(true); } } \ No newline at end of file