diff options
Diffstat (limited to 'auth/cli-editor/src/test')
3 files changed, 32 insertions, 1 deletions
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorTest.java index b75199ac3..51659c2ea 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorTest.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorTest.java @@ -24,9 +24,12 @@ package org.onap.policy.apex.auth.clieditor.tosca; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -42,6 +45,7 @@ public class ApexCliToscaEditorTest { private File tempOutputToscaFile; private File tempLogFile; String[] sampleArgs; + private File tempNodeTemplateFile; /** * Initialise args. @@ -52,6 +56,7 @@ public class ApexCliToscaEditorTest { public void initialiseArgs() throws IOException { tempOutputToscaFile = File.createTempFile("ToscaPolicyOutput", ".json"); + tempNodeTemplateFile = File.createTempFile("ToscaNodeTemplate", ".json"); tempLogFile = File.createTempFile("ApexCliTosca", ".log"); sampleArgs = new String[] { "-c", CommonTestData.COMMAND_FILE_NAME, @@ -69,6 +74,7 @@ public class ApexCliToscaEditorTest { public void removeGeneratedFiles() { tempOutputToscaFile.delete(); tempLogFile.delete(); + tempNodeTemplateFile.delete(); } @Test @@ -110,4 +116,28 @@ public class ApexCliToscaEditorTest { }; assertThatThrownBy(() -> new ApexCliToscaEditorMain(sampleArgs)).hasMessage("Insufficient arguments provided."); } + + @Test + public void testGenerateToscaPolicyMetadataSet() throws Exception { + // @formatter:off + final String[] cliArgs = new String[] { + "-c", CommonTestData.COMMAND_FILE_NAME, + "-l", tempLogFile.getAbsolutePath(), + "-ac", CommonTestData.APEX_CONFIG_FILE_NAME, + "-t", CommonTestData.INPUT_TOSCA_TEMPLATE_FILE_NAME, + "-ot", tempOutputToscaFile.getAbsolutePath(), + "-on", tempNodeTemplateFile.getAbsolutePath(), + "-nt", CommonTestData.NODE_TYPE + }; + // @formatter:on + + new ApexCliToscaEditorMain(cliArgs); + + assertTrue(tempOutputToscaFile.length() > 0); + assertTrue(Files.lines(Paths.get(tempOutputToscaFile.toString())) + .noneMatch(l -> l.contains("policy_type_impl"))); + assertTrue(tempNodeTemplateFile.length() > 0); + assertTrue(Files.lines(Paths.get(tempNodeTemplateFile.toString())) + .anyMatch(l -> l.contains("policyModel"))); + } } diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/CommonTestData.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/CommonTestData.java index 23d927e24..a3b4bcd44 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/CommonTestData.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/CommonTestData.java @@ -36,4 +36,5 @@ public final class CommonTestData { public static final String APEX_CONFIG_FILE_NAME = "src/test/resources/tosca/ApexConfig.json"; public static final String COMMAND_FILE_NAME = "src/test/resources/tosca/PolicyModel.apex"; public static final String POLICY_MODEL_FILE_NAME = "src/test/resources/tosca/PolicyModel.json"; + public static final String NODE_TYPE = "org.onap.nodetypes.policy.MetadataSet"; } diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/utils/CliUtilsTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/utils/CliUtilsTest.java index 2ce34e148..ba3ab7627 100644 --- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/utils/CliUtilsTest.java +++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/utils/CliUtilsTest.java @@ -79,7 +79,7 @@ public class CliUtilsTest { @Test public void testCreateToscaServiceTemplate() throws IOException, CoderException { ApexCliToscaParameters params = new ApexCliToscaParameterParser().parse(sampleArgs); - CliUtils.createToscaServiceTemplate(params, policyModelFilePath); + CliUtils.createToscaPolicy(params, policyModelFilePath, null); String outputTosca = TextFileUtils.getTextFileAsString(tempOutputToscaFile.getAbsolutePath()); String outputToscaCompare = TextFileUtils.getTextFileAsString("src/test/resources/tosca/ToscaPolicyOutput_compare_1.json").trim(); |