From f77a6e26f955119565a0cb604c6c41ef9d953fb2 Mon Sep 17 00:00:00 2001 From: yzerk Date: Mon, 28 Aug 2023 13:07:29 +0300 Subject: [PATCH] feat: new command: distribution (fix unit tests) --- .../DistributionAddSubcommandTest.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/crowdin/cli/commands/picocli/DistributionAddSubcommandTest.java b/src/test/java/com/crowdin/cli/commands/picocli/DistributionAddSubcommandTest.java index 37e44b157..1752788b3 100644 --- a/src/test/java/com/crowdin/cli/commands/picocli/DistributionAddSubcommandTest.java +++ b/src/test/java/com/crowdin/cli/commands/picocli/DistributionAddSubcommandTest.java @@ -21,16 +21,17 @@ public class DistributionAddSubcommandTest extends PicocliTestUtils { @Test public void testDistributionAddInvalidOptions() { - this.executeInvalidParams(CommandNames.DISTRIBUTION, CommandNames.DISTRIBUTION_ADD, "Test Distribution1", "--file", "stringId"); + this.executeInvalidParams(CommandNames.DISTRIBUTION, CommandNames.DISTRIBUTION_ADD, "Test Distribution1", "--file", null); } @ParameterizedTest @MethodSource - public void testSubCommandCheckValidOptions(String name, ExportMode exportMode, List files) { + public void testSubCommandCheckValidOptions(String name, ExportMode exportMode, List files, List bundleIds) { DistributionAddSubcommand distributionAddSubcommand = new DistributionAddSubcommand(); distributionAddSubcommand.name = name; distributionAddSubcommand.exportMode = exportMode; distributionAddSubcommand.files = files; + distributionAddSubcommand.bundleIds = bundleIds; List errors = distributionAddSubcommand.checkOptions(); assertEquals(Collections.emptyList(), errors); @@ -38,18 +39,20 @@ public void testSubCommandCheckValidOptions(String name, ExportMode exportMode, public static Stream testSubCommandCheckValidOptions() { return Stream.of( - arguments("Distribution 1", ExportMode.DEFAULT, Arrays.asList("strings.xml", "strings2.xml")), - arguments("Distribution 2", ExportMode.BUNDLE, Arrays.asList("strings.xml", "strings2.xml")), - arguments("Distribution 3", null, Arrays.asList("strings.xml", "strings2.xml"))); + arguments("Distribution 1", ExportMode.DEFAULT, Arrays.asList("strings.xml", "strings2.xml"), null), + arguments("Distribution 2", ExportMode.BUNDLE, null, Arrays.asList(1l, 2l)), + arguments("Distribution 3", null, Arrays.asList("strings.xml", "strings2.xml"), null)); } @ParameterizedTest @MethodSource - public void testSubCommandCheckInvalidOptions(String name, ExportMode exportMode, List files, List expErrors) { + public void testSubCommandCheckInvalidOptions(String name, ExportMode exportMode, List files, + List bundleIds, List expErrors) { DistributionAddSubcommand distributionAddSubcommand = new DistributionAddSubcommand(); distributionAddSubcommand.name = name; distributionAddSubcommand.exportMode = exportMode; distributionAddSubcommand.files = files; + distributionAddSubcommand.bundleIds = bundleIds; List errors = distributionAddSubcommand.checkOptions(); assertThat(errors, Matchers.equalTo(expErrors)); @@ -57,6 +60,10 @@ public void testSubCommandCheckInvalidOptions(String name, ExportMode exportMode public static Stream testSubCommandCheckInvalidOptions() { return Stream.of( - arguments("Distribution 1", ExportMode.DEFAULT, null, Arrays.asList(RESOURCE_BUNDLE.getString("error.distribution.empty_fileId")))); + arguments("Distribution 1", ExportMode.DEFAULT, null, null, Arrays.asList(RESOURCE_BUNDLE.getString("error.distribution.empty_file"))), + arguments("Distribution 2", ExportMode.BUNDLE, null, null, Arrays.asList(RESOURCE_BUNDLE.getString("error.distribution.empty_bundle_ids"))), + arguments("Distribution 3", ExportMode.BUNDLE, Arrays.asList("file.json"), Arrays.asList(1l), Arrays.asList(RESOURCE_BUNDLE.getString("error.distribution.incorrect_file_command_usage"))), + arguments("Distribution 4", ExportMode.DEFAULT, Arrays.asList("file.json"), Arrays.asList(1l), Arrays.asList(RESOURCE_BUNDLE.getString("error.distribution.incorrect_bundle_id_command_usage"))) + ); } }