From 98e8a3bdc662dcaaf00ade03f371fe1d204accf1 Mon Sep 17 00:00:00 2001 From: psmf22 <117990501+psmf22@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:59:37 +0200 Subject: [PATCH 1/2] chore: delete test --- .../ftest/tool/ToolVersionHandlingSpec.groovy | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolVersionHandlingSpec.groovy diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolVersionHandlingSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolVersionHandlingSpec.groovy deleted file mode 100644 index 8d7461b0f8..0000000000 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolVersionHandlingSpec.groovy +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2023 Open Text. - * - * The only warranties for products and services of Open Text - * and its affiliates and licensors ("Open Text") are as may - * be set forth in the express warranty statements accompanying - * such products and services. Nothing herein should be construed - * as constituting an additional warranty. Open Text shall not be - * liable for technical or editorial errors or omissions contained - * herein. The information contained herein is subject to change - * without notice. - */ -package com.fortify.cli.ftest.tool - -import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC - -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory -import com.fortify.cli.ftest._common.Fcli -import com.fortify.cli.ftest._common.spec.FcliBaseSpec -import com.fortify.cli.ftest._common.spec.FcliSession -import com.fortify.cli.ftest._common.spec.Prefix -import com.fortify.cli.ftest.ssc._common.SSCRoleSupplier -import com.fortify.cli.ftest.ssc._common.SSCRoleSupplier.SSCRole -import spock.lang.AutoCleanup -import spock.lang.Requires -import spock.lang.Shared -import spock.lang.Stepwise - -import com.fortify.cli.tool._common.helper.ToolDownloadDescriptor -import com.fortify.cli.tool._common.helper.ToolHelper; - -@Prefix("tool.VersionHandling") @Stepwise -class ToolVersionHandlingSpec extends FcliBaseSpec { - private static final ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory()); - - def "testVersionHandling"() { - String toolName = "sc-client" - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - String resourceFile = ToolHelper.getResourceFile(toolName, String.format("%s.yaml", toolName)); - InputStream file = classLoader.getResourceAsStream(resourceFile); - def downloadDescriptor = yamlObjectMapper.readValue(file, ToolDownloadDescriptor.class); - file.close(); - when: - def d = downloadDescriptor.getVersion("20"); - def d2 = downloadDescriptor.getVersion("20."); - def d3 = downloadDescriptor.getVersion("22.2"); - def d4 = downloadDescriptor.getVersion("22.2.0"); - then: - d.version == "20.2.4"; - d2.version == "20.2.4"; - d3.version == "22.2.1"; - d4.version == "22.2.0"; - - } - - -} From a934e492c0f3e30b800d301cc2845a194af35668 Mon Sep 17 00:00:00 2001 From: psmf22 <117990501+psmf22@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:47:45 +0200 Subject: [PATCH 2/2] Create VersionHandlingTest.java --- .../versionHandling/VersionHandlingTest.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 fcli-core/fcli-tool/src/test/java/com/fortify/cli/tool/versionHandling/VersionHandlingTest.java diff --git a/fcli-core/fcli-tool/src/test/java/com/fortify/cli/tool/versionHandling/VersionHandlingTest.java b/fcli-core/fcli-tool/src/test/java/com/fortify/cli/tool/versionHandling/VersionHandlingTest.java new file mode 100644 index 0000000000..d610b39119 --- /dev/null +++ b/fcli-core/fcli-tool/src/test/java/com/fortify/cli/tool/versionHandling/VersionHandlingTest.java @@ -0,0 +1,40 @@ +package com.fortify.cli.tool.versionHandling; + +import java.io.InputStream; + +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fortify.cli.tool._common.helper.ToolDownloadDescriptor; +import com.fortify.cli.tool._common.helper.ToolHelper; + +import org.junit.jupiter.api.Assertions; + + +public class VersionHandlingTest { + private static final ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory()); + String toolName = "sc-client"; + + @Test + public void testVersionHandling() throws Exception { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + String resourceFile = ToolHelper.getResourceFile(toolName, String.format("%s.yaml", toolName)); + try (InputStream file = classLoader.getResourceAsStream(resourceFile)) { + + var downloadDescriptor = yamlObjectMapper.readValue(file, ToolDownloadDescriptor.class); + var d = downloadDescriptor.getVersion("20"); + var d2 = downloadDescriptor.getVersion("20."); + var d3 = downloadDescriptor.getVersion("21.1"); + var d4 = downloadDescriptor.getVersion("21.1.2"); + + Assertions.assertEquals(d.getVersion(), "20.2.4"); + Assertions.assertEquals(d2.getVersion(), "20.2.4"); + Assertions.assertEquals(d3.getVersion(), "21.1.4"); + Assertions.assertEquals(d4.getVersion(), "21.1.2"); + } catch(Exception e) { + throw e; + } + } +} +