From aa69c8950c4cd779b4113a95d28547d9db360176 Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:25:31 +0200 Subject: [PATCH] chore: Add SSC & FoD action tests --- .../cli/fod/_common/action/FoDActionTest.java | 39 +++++++++++++++++++ .../cli/ssc/_common/action/SSCActionTest.java | 39 +++++++++++++++++++ .../rest/query/SSCQParamGeneratorTest.java | 2 +- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 fcli-core/fcli-fod/src/test/java/com/fortify/cli/fod/_common/action/FoDActionTest.java create mode 100644 fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/_common/action/SSCActionTest.java rename fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/{ => _common}/rest/query/SSCQParamGeneratorTest.java (98%) diff --git a/fcli-core/fcli-fod/src/test/java/com/fortify/cli/fod/_common/action/FoDActionTest.java b/fcli-core/fcli-fod/src/test/java/com/fortify/cli/fod/_common/action/FoDActionTest.java new file mode 100644 index 0000000000..141232fdc7 --- /dev/null +++ b/fcli-core/fcli-fod/src/test/java/com/fortify/cli/fod/_common/action/FoDActionTest.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 2021, 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.fod._common.action; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import com.fortify.cli.common.action.helper.ActionHelper; + +public class FoDActionTest { + private static final String TYPE = "FoD"; + @ParameterizedTest + @MethodSource("getActions") + public void testLoadAction(String name) { + try { + ActionHelper.load(TYPE, name); + } catch ( Exception e ) { + System.err.println(String.format("Error loading %s action %s:\n%s", TYPE, name, e)); + Assertions.fail(String.format("Error loading %s action %s", TYPE, name), e); + } + } + + public static final String[] getActions() { + return ActionHelper.list(TYPE) + .map(a->a.get("name").asText()) + .toArray(String[]::new); + } +} diff --git a/fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/_common/action/SSCActionTest.java b/fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/_common/action/SSCActionTest.java new file mode 100644 index 0000000000..5d12e86855 --- /dev/null +++ b/fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/_common/action/SSCActionTest.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 2021, 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.ssc._common.action; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import com.fortify.cli.common.action.helper.ActionHelper; + +public class SSCActionTest { + private static final String TYPE = "SSC"; + @ParameterizedTest + @MethodSource("getActions") + public void testLoadAction(String name) { + try { + ActionHelper.load(TYPE, name); + } catch ( Exception e ) { + System.err.println(String.format("Error loading %s action %s:\n%s", TYPE, name, e)); + Assertions.fail(String.format("Error loading %s action %s", TYPE, name), e); + } + } + + public static final String[] getActions() { + return ActionHelper.list(TYPE) + .map(a->a.get("name").asText()) + .toArray(String[]::new); + } +} diff --git a/fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/rest/query/SSCQParamGeneratorTest.java b/fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/_common/rest/query/SSCQParamGeneratorTest.java similarity index 98% rename from fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/rest/query/SSCQParamGeneratorTest.java rename to fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/_common/rest/query/SSCQParamGeneratorTest.java index 5644420202..d7760c7d86 100644 --- a/fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/rest/query/SSCQParamGeneratorTest.java +++ b/fcli-core/fcli-ssc/src/test/java/com/fortify/cli/ssc/_common/rest/query/SSCQParamGeneratorTest.java @@ -10,7 +10,7 @@ * herein. The information contained herein is subject to change * without notice. *******************************************************************************/ -package com.fortify.cli.ssc.rest.query; +package com.fortify.cli.ssc._common.rest.query; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest;