diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/ToolCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/ToolCommandletTest.java index a279403fd..d39169215 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/ToolCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/ToolCommandletTest.java @@ -12,9 +12,7 @@ import com.devonfw.tools.ide.version.VersionIdentifier; import com.devonfw.tools.ide.version.VersionRange; -/** - * Test of {@link ToolCommandlet}. - */ +/** Test of {@link ToolCommandlet} */ public class ToolCommandletTest extends AbstractIdeContextTest { /** @@ -32,12 +30,18 @@ public void testSecurityRiskInteractionAllVersionAffectedBySingleWarning() { UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of(">")); // should get ignored - securityFile.addSecurityWarning(VersionRange.of("0>11")); // should get ignored - securityFile.addSecurityWarning(VersionRange.of("2>5")); + securityFile.addSecurityWarning(VersionRange.of("(,)")); // should get ignored + securityFile.addSecurityWarning(VersionRange.of("[0,11]")); // should get ignored + securityFile.addSecurityWarning(VersionRange.of("[2,5]")); // act & assert // no answer required + + // TODO move + // version of 1 to var namend current + // then save this also to stay + // extract method that calcs next safe, latest save + // and introduce var named latest and make it to * assertThat(tool.securityRiskInteraction(VersionIdentifier.of("1"))).isEqualTo(VersionIdentifier.of("1")); // answer to the interaction is 1 assertThat(tool.securityRiskInteraction(VersionIdentifier.of("2"))).isEqualTo(VersionIdentifier.of("2")); @@ -60,8 +64,8 @@ public void testSecurityRiskInteractionAllVersionAffectedByMultipleWarning() { ToolCommandlet tool = context.getCommandletManager().getCommandlet(dummyTool); UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of("1>5")); - securityFile.addSecurityWarning(VersionRange.of("6>")); + securityFile.addSecurityWarning(VersionRange.of("[1,5]")); + securityFile.addSecurityWarning(VersionRange.of("[6,)")); // act & assert assertThat(tool.securityRiskInteraction(VersionIdentifier.of("6"))).isEqualTo(VersionIdentifier.of("6")); @@ -84,8 +88,8 @@ public void testSecurityRiskInteractionCurrentIsLatest() { ToolCommandlet tool = context.getCommandletManager().getCommandlet(dummyTool); UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of("2>5")); - securityFile.addSecurityWarning(VersionRange.of("7>9")); + securityFile.addSecurityWarning(VersionRange.of("[2,5]")); + securityFile.addSecurityWarning(VersionRange.of("[7,9]")); // act & assert // answer to the interaction is 1 @@ -108,9 +112,9 @@ public void testSecurityRiskInteractionNextSafeIsNull() { ToolCommandlet tool = context.getCommandletManager().getCommandlet(dummyTool); UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of("3>3")); - securityFile.addSecurityWarning(VersionRange.of("6>7")); - securityFile.addSecurityWarning(VersionRange.of("8>")); + securityFile.addSecurityWarning(VersionRange.of("[3,3]")); + securityFile.addSecurityWarning(VersionRange.of("[6,7]")); + securityFile.addSecurityWarning(VersionRange.of("[8,)")); // act & assert // answer to the interaction is 1 @@ -133,9 +137,9 @@ public void testSecurityRiskInteractionNextSafeIsLatest() { ToolCommandlet tool = context.getCommandletManager().getCommandlet(dummyTool); UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of("3>3")); - securityFile.addSecurityWarning(VersionRange.of("6>7")); - securityFile.addSecurityWarning(VersionRange.of("8>8")); + securityFile.addSecurityWarning(VersionRange.of("[3,3]")); + securityFile.addSecurityWarning(VersionRange.of("[6,7]")); + securityFile.addSecurityWarning(VersionRange.of("[8,8]")); // act & assert // answer to the interaction is 1 @@ -158,9 +162,9 @@ public void testSecurityRiskInteractionNextSafeIsLatestSafe() { ToolCommandlet tool = context.getCommandletManager().getCommandlet(dummyTool); UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of("3>3")); - securityFile.addSecurityWarning(VersionRange.of("5>6")); - securityFile.addSecurityWarning(VersionRange.of("8>9")); + securityFile.addSecurityWarning(VersionRange.of("[3,3]")); + securityFile.addSecurityWarning(VersionRange.of("[5,6]")); + securityFile.addSecurityWarning(VersionRange.of("[8,9]")); // act & assert // answer to the interaction is 1 @@ -183,9 +187,9 @@ public void testSecurityRiskInteractionLatestSafeDiffersFromNextSafeButIsLatest( ToolCommandlet tool = context.getCommandletManager().getCommandlet(dummyTool); UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of("3>3")); - securityFile.addSecurityWarning(VersionRange.of("5>6")); - securityFile.addSecurityWarning(VersionRange.of("8>8")); + securityFile.addSecurityWarning(VersionRange.of("[3,3]")); + securityFile.addSecurityWarning(VersionRange.of("[5,6]")); + securityFile.addSecurityWarning(VersionRange.of("[8,8]")); // act & assert // answer to the interaction is 1 @@ -210,9 +214,9 @@ public void testSecurityRiskInteractionLatestSafeDiffersFromNextSafeAndLatest() ToolCommandlet tool = context.getCommandletManager().getCommandlet(dummyTool); UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of("3>3")); - securityFile.addSecurityWarning(VersionRange.of("6>6")); - securityFile.addSecurityWarning(VersionRange.of("8>9")); + securityFile.addSecurityWarning(VersionRange.of("[3,3]")); + securityFile.addSecurityWarning(VersionRange.of("[6,6]")); + securityFile.addSecurityWarning(VersionRange.of("[8,9]")); // act & assert // answer to the interaction is 1 @@ -223,9 +227,7 @@ public void testSecurityRiskInteractionLatestSafeDiffersFromNextSafeAndLatest() assertThat(tool.securityRiskInteraction(VersionIdentifier.of("3"))).isEqualTo(VersionIdentifier.of("7")); } - /** - * Test of {@link ToolCommandlet#securityRiskInteraction(VersionIdentifier)} where set version is safe. - */ + /** Test of {@link ToolCommandlet#securityRiskInteraction(VersionIdentifier)} where set version is safe. */ @Test public void testSecurityRiskInteractionCurrentVersionIsSafe() { @@ -235,8 +237,8 @@ public void testSecurityRiskInteractionCurrentVersionIsSafe() { ToolCommandlet tool = context.getCommandletManager().getCommandlet(dummyTool); UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool.getName(), tool.getEdition()) .getSecurityJsonFile(); - securityFile.addSecurityWarning(VersionRange.of("1>5")); - securityFile.addSecurityWarning(VersionRange.of("7>8")); + securityFile.addSecurityWarning(VersionRange.of("[1,5]")); + securityFile.addSecurityWarning(VersionRange.of("[7,8]")); // act & assert assertThat(tool.securityRiskInteraction(VersionIdentifier.of("6"))).isEqualTo(VersionIdentifier.of("6")); @@ -261,7 +263,8 @@ private IdeContext getContextForSecurityJsonTests(Class