aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java109
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/DummyStErrorListener.java24
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportGenerationTest.java56
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportKeyInfoGetter.java5
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorMain.java12
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java56
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java60
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java68
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java28
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java33
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java33
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java42
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorTest.java56
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/utils/CliUtilsTest.java44
14 files changed, 304 insertions, 322 deletions
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
index f0cb1d879..1b44f66e7 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -24,7 +24,7 @@
package org.onap.policy.apex.auth.clicodegen;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.FileInputStream;
@@ -36,7 +36,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -60,13 +60,13 @@ import org.stringtemplate.v4.ST;
/**
* Test CLI code generation.
*/
-public class CodeGeneratorCliEditorTest {
+class CodeGeneratorCliEditorTest {
private SupportKeyInfoGetter kig;
private File outFile = null;
@Test
- public void test() throws IOException, ApexModelException {
+ void test() throws IOException, ApexModelException {
final CodeGeneratorCliEditor codeGen = new CodeGeneratorCliEditor();
outFile = File.createTempFile("ApexTestGenerated", ".apex");
@@ -76,8 +76,7 @@ public class CodeGeneratorCliEditorTest {
modelReader.setValidate(false);
AxPolicyModel apexPolicyModel = null;
- apexPolicyModel = modelReader
- .read(new FileInputStream(new File("src/test/resources/models/TestPolicyModel.json")));
+ apexPolicyModel = modelReader.read(new FileInputStream("src/test/resources/models/TestPolicyModel.json"));
assertEquals(0, generateCli(codeGen, apexPolicyModel));
}
@@ -85,9 +84,9 @@ public class CodeGeneratorCliEditorTest {
/**
* Generate the CLI from the model.
*
- * @param codeGen the code generator
+ * @param codeGen the code generator
* @param policyModel the policy model
- * @throws IOException on generation exceptions
+ * @throws IOException on generation exceptions
*/
private int generateCli(final CodeGeneratorCliEditor codeGen, final AxPolicyModel policyModel) throws IOException {
kig = new SupportKeyInfoGetter(policyModel);
@@ -102,7 +101,7 @@ public class CodeGeneratorCliEditorTest {
final AxArtifactKey key = s.getKey();
codeGen.addSchemaDeclaration(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- s.getSchemaFlavour(), s.getSchema());
+ s.getSchemaFlavour(), s.getSchema());
}
// 2: tasks
@@ -123,16 +122,16 @@ public class CodeGeneratorCliEditorTest {
final List<ST> fields = getParametersForEvent(codeGen, e);
codeGen.addEventDeclaration(
- EventDeclaration.builder()
- .name(kig.getName(key))
- .version(kig.getVersion(key))
- .uuid(kig.getUuid(key))
- .description(kig.getDesc(key))
- .nameSpace(e.getNameSpace())
- .source(e.getSource())
- .target(e.getTarget())
- .fields(fields)
- .build());
+ EventDeclaration.builder()
+ .name(kig.getName(key))
+ .version(kig.getVersion(key))
+ .uuid(kig.getUuid(key))
+ .description(kig.getDesc(key))
+ .nameSpace(e.getNameSpace())
+ .source(e.getSource())
+ .target(e.getTarget())
+ .fields(fields)
+ .build());
}
// 4: context albums
@@ -140,16 +139,16 @@ public class CodeGeneratorCliEditorTest {
final AxArtifactKey key = a.getKey();
codeGen.addContextAlbumDeclaration(
- CodeGenCliEditor.builder()
- .name(kig.getName(key))
- .version(kig.getVersion(key))
- .uuid(kig.getUuid(key))
- .description(kig.getDesc(key))
- .scope(a.getScope())
- .writable(a.isWritable())
- .schemaName(kig.getName(a.getItemSchema()))
- .schemaVersion(kig.getVersion(a.getItemSchema()))
- .build());
+ CodeGenCliEditor.builder()
+ .name(kig.getName(key))
+ .version(kig.getVersion(key))
+ .uuid(kig.getUuid(key))
+ .description(kig.getDesc(key))
+ .scope(a.getScope())
+ .writable(a.isWritable())
+ .schemaName(kig.getName(a.getItemSchema()))
+ .schemaVersion(kig.getVersion(a.getItemSchema()))
+ .build());
}
// 5: policies
@@ -157,7 +156,7 @@ public class CodeGeneratorCliEditorTest {
final AxArtifactKey key = p.getKey();
final List<ST> states = getStatesForPolicy(codeGen, p);
codeGen.addPolicyDefinition(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- p.getTemplate(), p.getFirstState(), states);
+ p.getTemplate(), p.getFirstState(), states);
}
final String out = codeGen.getModel().render();
@@ -172,7 +171,7 @@ public class CodeGeneratorCliEditorTest {
/**
* Gets the parameters for event.
*
- * @param cg the code generator
+ * @param cg the code generator
* @param event the event
* @return the parameters for event
*/
@@ -183,7 +182,7 @@ public class CodeGeneratorCliEditorTest {
final AxReferenceKey fkey = f.getKey();
final ST val = cg.createEventFieldDefinition(kig.getPName(fkey), kig.getPVersion(fkey), kig.getLName(fkey),
- kig.getName(f.getSchema()), kig.getVersion(f.getSchema()), f.getOptional());
+ kig.getName(f.getSchema()), kig.getVersion(f.getSchema()), f.getOptional());
ret.add(val);
}
@@ -193,7 +192,7 @@ public class CodeGeneratorCliEditorTest {
/**
* Gets the context references for task.
*
- * @param cg the code generator
+ * @param cg the code generator
* @param task the task
* @return the context references for task
*/
@@ -204,7 +203,7 @@ public class CodeGeneratorCliEditorTest {
for (final AxArtifactKey ckey : ctxs) {
final ST val = cg.createTaskDefinitionContextRef(kig.getName(tkey), kig.getVersion(tkey), kig.getName(ckey),
- kig.getVersion(ckey));
+ kig.getVersion(ckey));
ret.add(val);
}
@@ -214,7 +213,7 @@ public class CodeGeneratorCliEditorTest {
/**
* Gets the parameters for task.
*
- * @param cg the code generator
+ * @param cg the code generator
* @param task the task
* @return the parameters for task
*/
@@ -225,7 +224,7 @@ public class CodeGeneratorCliEditorTest {
final AxReferenceKey pkey = p.getKey();
final ST val = cg.createTaskDefinitionParameters(kig.getPName(pkey), kig.getPVersion(pkey),
- kig.getLName(pkey), p.getTaskParameterValue());
+ kig.getLName(pkey), p.getTaskParameterValue());
ret.add(val);
}
@@ -235,7 +234,7 @@ public class CodeGeneratorCliEditorTest {
/**
* Gets the logic for task.
*
- * @param cg the code generator
+ * @param cg the code generator
* @param task the task
* @return the logic for task
*/
@@ -249,7 +248,7 @@ public class CodeGeneratorCliEditorTest {
/**
* Gets the states for policy.
*
- * @param cg the code generator
+ * @param cg the code generator
* @param pol the policy
* @return the states for policy
*/
@@ -265,13 +264,13 @@ public class CodeGeneratorCliEditorTest {
final List<ST> ctxRefs = getCtxtRefsForState(cg, st);
final ST val = cg.createPolicyStateDef(PolicyStateDef.builder()
- .policyName(kig.getPName(skey)).version(kig.getPVersion(skey))
- .stateName(kig.getLName(skey)).triggerName(kig.getName(st.getTrigger()))
- .triggerVersion(kig.getVersion(st.getTrigger()))
- .defaultTask(kig.getName(st.getDefaultTask()))
- .defaultTaskVersion(kig.getVersion(st.getDefaultTask())).outputs(outputs)
- .tasks(tasks).tsLogic(tsLogic).finalizerLogics(finalizerLogics)
- .ctxRefs(ctxRefs).build());
+ .policyName(kig.getPName(skey)).version(kig.getPVersion(skey))
+ .stateName(kig.getLName(skey)).triggerName(kig.getName(st.getTrigger()))
+ .triggerVersion(kig.getVersion(st.getTrigger()))
+ .defaultTask(kig.getName(st.getDefaultTask()))
+ .defaultTaskVersion(kig.getVersion(st.getDefaultTask())).outputs(outputs)
+ .tasks(tasks).tsLogic(tsLogic).finalizerLogics(finalizerLogics)
+ .ctxRefs(ctxRefs).build());
ret.add(val);
}
@@ -293,7 +292,7 @@ public class CodeGeneratorCliEditorTest {
final AxReferenceKey finkey = fin.getKey();
final ST val = cg.createPolicyStateDefFinalizerLogic(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), kig.getLName(finkey), fin.getLogicFlavour(), fin.getLogic());
+ kig.getLName(skey), kig.getLName(finkey), fin.getLogicFlavour(), fin.getLogic());
ret.add(val);
}
@@ -314,7 +313,7 @@ public class CodeGeneratorCliEditorTest {
for (final AxArtifactKey ctx : ctxs) {
final ST val = cg.createPolicyStateDefContextRef(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), kig.getName(ctx), kig.getVersion(ctx));
+ kig.getLName(skey), kig.getName(ctx), kig.getVersion(ctx));
ret.add(val);
}
@@ -333,7 +332,7 @@ public class CodeGeneratorCliEditorTest {
if (st.checkSetTaskSelectionLogic()) {
final AxTaskSelectionLogic tsl = st.getTaskSelectionLogic();
final ST val = cg.createPolicyStateDefTaskSelLogic(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), tsl.getLogicFlavour(), tsl.getLogic());
+ kig.getLName(skey), tsl.getLogicFlavour(), tsl.getLogic());
return Collections.singletonList(val);
} else {
return Collections.emptyList();
@@ -357,12 +356,12 @@ public class CodeGeneratorCliEditorTest {
final AxReferenceKey trkey = tr.getKey();
final ST val = cg.createPolicyStateTask(PolicyStateTask.builder()
- .policyName(kig.getPName(skey)).version(kig.getPVersion(skey))
- .stateName(kig.getLName(skey)).taskLocalName(kig.getLName(trkey))
- .taskName(kig.getName(tkey)).taskVersion(kig.getVersion(tkey))
- .outputType(tr.getStateTaskOutputType().name())
- .outputName(kig.getLName(tr.getOutput()))
- .build());
+ .policyName(kig.getPName(skey)).version(kig.getPVersion(skey))
+ .stateName(kig.getLName(skey)).taskLocalName(kig.getLName(trkey))
+ .taskName(kig.getName(tkey)).taskVersion(kig.getVersion(tkey))
+ .outputType(tr.getStateTaskOutputType().name())
+ .outputName(kig.getLName(tr.getOutput()))
+ .build());
ret.add(val);
}
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/DummyStErrorListener.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/DummyStErrorListener.java
index 572b40e74..be3ec8642 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/DummyStErrorListener.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/DummyStErrorListener.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +35,9 @@ import org.stringtemplate.v4.misc.STMessage;
*/
public class DummyStErrorListener implements STErrorListener {
- /** Counts errors of the listener. */
+ /**
+ * Counts errors of the listener.
+ */
@Getter(AccessLevel.PROTECTED)
@Setter(AccessLevel.PROTECTED)
private int errorCount;
@@ -44,10 +47,7 @@ public class DummyStErrorListener implements STErrorListener {
*/
@Override
public void IOError(final STMessage msg) {
- switch (msg.error) {
- default:
- this.registerErrors(msg);
- }
+ this.registerErrors(msg);
}
/**
@@ -55,10 +55,7 @@ public class DummyStErrorListener implements STErrorListener {
*/
@Override
public void compileTimeError(final STMessage msg) {
- switch (msg.error) {
- default:
- this.registerErrors(msg);
- }
+ this.registerErrors(msg);
}
/**
@@ -66,10 +63,7 @@ public class DummyStErrorListener implements STErrorListener {
*/
@Override
public void internalError(final STMessage msg) {
- switch (msg.error) {
- default:
- this.registerErrors(msg);
- }
+ this.registerErrors(msg);
}
/**
@@ -78,9 +72,7 @@ public class DummyStErrorListener implements STErrorListener {
@Override
public void runTimeError(final STMessage msg) {
switch (msg.error) {
- case NO_SUCH_PROPERTY:
- case ARGUMENT_COUNT_MISMATCH:
- case ANON_ARGUMENT_MISMATCH:
+ case NO_SUCH_PROPERTY, ARGUMENT_COUNT_MISMATCH, ANON_ARGUMENT_MISMATCH:
break;
default:
this.registerErrors(msg);
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportGenerationTest.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportGenerationTest.java
index e6c43692f..e45a44296 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportGenerationTest.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportGenerationTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021-2022 Nordix Foundation
+ * Modifications Copyright (C) 2021-2022, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
package org.onap.policy.apex.auth.clicodegen;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.LinkedHashMap;
@@ -29,7 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.stringtemplate.v4.STGroup;
import org.stringtemplate.v4.STGroupFile;
@@ -38,7 +38,7 @@ import org.stringtemplate.v4.STGroupFile;
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
-public class SupportGenerationTest {
+class SupportGenerationTest {
/**
* Get the chunks for the codegen.
@@ -51,44 +51,46 @@ public class SupportGenerationTest {
final Map<String, List<String>> chunks = new LinkedHashMap<>();
chunks.put("/policyModel",
- Arrays.asList("name", "version", "uuid", "description", "declarations", "definitions"));
+ Arrays.asList("name", "version", "uuid", "description", "declarations", "definitions"));
chunks.put("/schemaDecl", Arrays.asList("name", "version", "uuid", "description", "flavour", "schema"));
chunks.put("/ctxAlbumDecl", Arrays.asList("name", "version", "uuid", "description", "scope", "writable",
- "schemaName", "schemaVersion"));
+ "schemaName", "schemaVersion"));
chunks.put("/eventDecl",
- Arrays.asList("name", "version", "uuid", "description", "nameSpace", "source", "target", "fields"));
+ Arrays.asList("name", "version", "uuid", "description", "nameSpace", "source", "target", "fields"));
chunks.put("/eventDefField",
- Arrays.asList("eventName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion", "optional"));
+ Arrays.asList("eventName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion", "optional"));
chunks.put("/taskDecl",
- Arrays.asList("name", "version", "uuid", "description", "infields", "outfields", "logic"));
+ Arrays.asList("name", "version", "uuid", "description", "infields", "outfields", "logic"));
chunks.put("/taskDefInputFields",
- Arrays.asList("taskName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion"));
+ Arrays.asList("taskName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion"));
chunks.put("/taskDefOutputFields",
- Arrays.asList("taskName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion"));
+ Arrays.asList("taskName", "version", "fieldName", "fieldSchema", "fieldSchemaVersion"));
chunks.put("/taskDefLogic", Arrays.asList("taskName", "version", "flavour", "logic"));
chunks.put("/taskDefParameter", Arrays.asList("name", "version", "parName", "defaultValue"));
chunks.put("/taskDefCtxRef", Arrays.asList("name", "version", "albumName", "albumVersion"));
chunks.put("/policyDef", Arrays.asList("name", "version", "uuid", "description", "template", "firstState"));
chunks.put("/policyStateDef", Arrays.asList("policyName", "version", "stateName", "triggerName",
- "triggerVersion", "defaultTask", "defaultTaskVersion", "outputs", "tasks"));
+ "triggerVersion", "defaultTask", "defaultTaskVersion", "outputs", "tasks"));
chunks.put("/policyStateOutput", Arrays.asList("policyName", "version", "stateName", "outputName", "eventName",
- "eventVersion", "nextState"));
+ "eventVersion", "nextState"));
chunks.put("/policyStateTaskSelectionLogic",
- Arrays.asList("name", "version", "stateName", "logicFlavour", "logic"));
+ Arrays.asList("name", "version", "stateName", "logicFlavour", "logic"));
chunks.put("/policyStateTask", Arrays.asList("policyName", "version", "stateName", "taskLocalName", "taskName",
- "taskVersion", "outputType", "outputName"));
+ "taskVersion", "outputType", "outputName"));
chunks.put("/policyStateFinalizerLogic",
- Arrays.asList("name", "version", "stateName", "finalizerLogicName", "logicFlavour", "logic"));
+ Arrays.asList("name", "version", "stateName", "finalizerLogicName", "logicFlavour", "logic"));
chunks.put("/policyStateContextRef",
- Arrays.asList("name", "version", "stateName", "albumName", "albumVersion"));
+ Arrays.asList("name", "version", "stateName", "albumName", "albumVersion"));
return chunks;
// CHECKSTYLE:ON: LineLength
}
- /** Test STG load. */
+ /**
+ * Test STG load.
+ */
@Test
- public void testGenerationLoad() {
+ void testGenerationLoad() {
final DummyStErrorListener errListener = new DummyStErrorListener();
final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE);
stg.setListener(errListener);
@@ -97,16 +99,18 @@ public class SupportGenerationTest {
assertEquals(0, errListener.getErrorCount());
}
- /** Test STG chunks. */
+ /**
+ * Test STG chunks.
+ */
@Test
- public void testGenerationChunks() {
+ void testGenerationChunks() {
final DummyStErrorListener errListener = new DummyStErrorListener();
final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE);
stg.setListener(errListener);
stg.getTemplateNames(); // dummy to compile group and get errors
final Map<String, List<String>> chunks = getCodeGenChunks();
- String error = "";
+ StringBuilder error = new StringBuilder();
final Set<String> definedNames = stg.getTemplateNames();
for (final STGroup group : stg.getImportedGroups()) {
definedNames.addAll(group.getTemplateNames());
@@ -115,15 +119,15 @@ public class SupportGenerationTest {
for (final String required : requiredNames) {
if (!definedNames.contains(required)) {
- error += " - target STG does not define template for <" + required + ">\n";
+ error.append(" - target STG does not define template for <").append(required).append(">\n");
} else {
final Set<String> definedParams = ((stg.getInstanceOf(required).getAttributes() == null)
- ? new TreeSet<String>() : stg.getInstanceOf(required).getAttributes().keySet());
+ ? new TreeSet<>() : stg.getInstanceOf(required).getAttributes().keySet());
final List<String> requiredParams = chunks.get(required);
for (final String reqArg : requiredParams) {
if (!definedParams.contains(reqArg)) {
- error += " - target STG with template <" + required + "> does not define argument <" + reqArg
- + ">\n";
+ error.append(" - target STG with template <").append(required)
+ .append("> does not define argument <").append(reqArg).append(">\n");
}
}
}
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportKeyInfoGetter.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportKeyInfoGetter.java
index 567991666..1d24c1f51 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportKeyInfoGetter.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/SupportKeyInfoGetter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +36,9 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@AllArgsConstructor
public class SupportKeyInfoGetter {
- /** The policy model for the getters. */
+ /**
+ * The policy model for the getters.
+ */
private final AxPolicyModel model;
/**
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorMain.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorMain.java
index 5f7bad116..6797ff4e4 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorMain.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/tosca/ApexCliToscaEditorMain.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2022 Nordix Foundation.
+ * Copyright (C) 2019-2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,14 +37,12 @@ import org.slf4j.LoggerFactory;
*
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
+@Getter
public class ApexCliToscaEditorMain {
private static final Logger LOGGER = LoggerFactory.getLogger(ApexCliToscaEditorMain.class);
- @Getter
private boolean failure;
- private ApexCliToscaParameters parameters;
- private ApexCommandLineEditorMain apexCliEditor;
/**
* Instantiates the Apex CLI Tosca editor.
@@ -56,7 +54,7 @@ public class ApexCliToscaEditorMain {
LOGGER.info("Starting Apex CLI Tosca editor with arguments - {}", argumentString);
final var parser = new ApexCliToscaParameterParser();
- parameters = parser.parse(args);
+ ApexCliToscaParameters parameters = parser.parse(args);
if (parameters.isHelpSet()) {
CliUtils.help(ApexCliToscaEditorMain.class.getName(), parser.getOptions());
return;
@@ -78,7 +76,7 @@ public class ApexCliToscaEditorMain {
cliArgsList.add(policyModelFilePath);
String[] cliArgs = cliArgsList.toArray(new String[cliArgsList.size()]);
- apexCliEditor = new ApexCommandLineEditorMain(cliArgs);
+ ApexCommandLineEditorMain apexCliEditor = new ApexCommandLineEditorMain(cliArgs);
if (apexCliEditor.getErrorCount() == 0) {
LOGGER.info("Apex CLI editor completed execution. Creating the ToscaPolicy using the tosca template"
+ "skeleton file, config file, and policy model created.");
@@ -90,7 +88,7 @@ public class ApexCliToscaEditorMain {
} catch (IOException | CoderException e) {
failure = true;
LOGGER.error("Failed to create the Tosca template using the generated policy model,"
- + "apex config file and the tosca template skeleton file. " + e);
+ + "apex config file and the tosca template skeleton file. {}", e.getMessage());
}
} else {
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
index 7c3e4cb01..5028abd31 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (c) 2020-2021 Nordix Foundation.
+ * Copyright (c) 2020-2021, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,26 +22,26 @@
package org.onap.policy.apex.auth.clieditor;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class CommandLineCommandTest {
+class CommandLineCommandTest {
CommandLineCommand commandLineCommand = null;
- @Before
- public void initializeCommandLineCommand() {
+ @BeforeEach
+ void initializeCommandLineCommand() {
commandLineCommand = new CommandLineCommand();
}
@Test
- public void testCommandLine() {
+ void testCommandLine() {
commandLineCommand.setName("TestName");
commandLineCommand.setDescription("testDescription");
commandLineCommand.setSystemCommand(true);
@@ -50,40 +50,40 @@ public class CommandLineCommandTest {
assertEquals("TestName", commandLineCommand.getName());
assertEquals(
"CommandLineCommand(name=TestName, keywordlist=[], argumentList=[], apiMethod=, systemCommand=true,"
- + " description=testDescription)", commandLineCommand.toString());
+ + " description=testDescription)", commandLineCommand.toString());
}
- @Test(expected = CommandLineException.class)
- public void testInvalidApiClassName() {
- commandLineCommand.getApiClassName();
+ @Test
+ void testInvalidApiClassName() {
+ assertThrows(CommandLineException.class, () -> commandLineCommand.getApiClassName());
}
@Test
- public void testGetValidApiClassName() {
+ void testGetValidApiClassName() {
commandLineCommand.setApiMethod("Java.Get");
assertEquals("Java", commandLineCommand.getApiClassName());
}
- @Test(expected = CommandLineException.class)
- public void testInvalidApiMethodName() {
- commandLineCommand.getApiMethodName();
+ @Test
+ void testInvalidApiMethodName() {
+ assertThrows(CommandLineException.class, () -> commandLineCommand.getApiMethodName());
}
@Test()
- public void testInvalidApiMethod() {
+ void testInvalidApiMethod() {
commandLineCommand.setApiMethod("fail.");
assertEquals("fail.", commandLineCommand.getApiMethod());
assertThrows(CommandLineException.class, () -> commandLineCommand.getApiMethodName());
}
@Test
- public void testValidApiMethodName() {
+ void testValidApiMethodName() {
commandLineCommand.setApiMethod("Java.Get");
assertEquals("Get", commandLineCommand.getApiMethodName());
}
@Test
- public void testGetHelp() {
+ void testGetHelp() {
List<String> keywordList = commandLineCommand.getKeywordlist();
List<CommandLineArgument> argumentList = commandLineCommand.getArgumentList();
assertEquals("{}: ", commandLineCommand.getHelp());
@@ -94,8 +94,7 @@ public class CommandLineCommandTest {
}
@Test
- public void testCompareTo() {
- assertEquals(0, commandLineCommand.compareTo(commandLineCommand));
+ void testCompareTo() {
CommandLineCommand otherCommand = new CommandLineCommand();
otherCommand.setSystemCommand(true);
assertThat(commandLineCommand).isNotEqualByComparingTo(otherCommand);
@@ -104,7 +103,7 @@ public class CommandLineCommandTest {
}
@Test
- public void testCompareKeywordList() {
+ void testCompareKeywordList() {
CommandLineCommand otherCommand = new CommandLineCommand();
otherCommand.getKeywordlist().add("test");
assertThat(commandLineCommand).isNotEqualByComparingTo(otherCommand);
@@ -117,7 +116,7 @@ public class CommandLineCommandTest {
}
@Test
- public void testHashCode() {
+ void testHashCode() {
CommandLineCommand otherCommand = new CommandLineCommand();
assertEquals(commandLineCommand.hashCode(), otherCommand.hashCode());
commandLineCommand.getKeywordlist().add("Test");
@@ -128,10 +127,9 @@ public class CommandLineCommandTest {
}
@Test
- public void testEquals() {
+ void testEquals() {
assertNotEquals(commandLineCommand, new Object());
- assertEquals(commandLineCommand, commandLineCommand);
- assertNotEquals(commandLineCommand, null);
+ assertNotEquals(null, commandLineCommand);
CommandLineCommand otherCommand = new CommandLineCommand();
assertEquals(commandLineCommand, otherCommand);
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java
index d5d288d04..437ae0fbb 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,22 +23,20 @@
package org.onap.policy.apex.auth.clieditor;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.onap.policy.common.utils.resources.TextFileUtils;
/**
* The Class TestCLIEditorEventsContext.
*/
-public class CommandLineEditorEventsContextTest {
+class CommandLineEditorEventsContextTest {
// CHECKSTYLE:OFF: MagicNumber
private static final Path SRC_MAIN_FOLDER = Paths.get("src/main/resources/");
@@ -56,20 +54,19 @@ public class CommandLineEditorEventsContextTest {
private static final String JSON_FILE = FILE_NAME + ".json";
private static final String LOG_FILE = FILE_NAME + ".log";
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ static Path temporaryFolder;
/**
* Test java context model.
*
* @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if an Apex error happens
*/
@Test
- public void testJavaContextModel() throws IOException, ApexModelException {
+ void testJavaContextModel() throws IOException {
- final File tempLogFile = temporaryFolder.newFile(LOG_FILE);
- final File tempModelFile = temporaryFolder.newFile(JSON_FILE);
+ final File tempLogFile = temporaryFolder.resolve(LOG_FILE).toFile();
+ final File tempModelFile = temporaryFolder.resolve(JSON_FILE).toFile();
final String[] cliArgs = new String[] {"-c", APEX_JAVA_POLICY_FILE.toString(), "-l",
tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()};
@@ -81,7 +78,7 @@ public class CommandLineEditorEventsContextTest {
final String logString = TextFileUtils.getTextFileAsString(tempLogFile.getCanonicalPath());
final String modelString = TextFileUtils.getTextFileAsString(tempModelFile.getCanonicalPath());
- // As a sanity check, count the number of non white space characters in log and model files
+ // As a sanity check, count the number of non-white space characters in log and model files
final int logCharCount = logString.replaceAll(SPACES, EMPTY_STRING).length();
final int modelCharCount = modelString.replaceAll(SPACES, EMPTY_STRING).length();
@@ -93,13 +90,12 @@ public class CommandLineEditorEventsContextTest {
* Test avro context model.
*
* @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if an Apex error happens
*/
@Test
- public void testAvroContextModel() throws IOException, ApexModelException {
+ void testAvroContextModel() throws IOException {
- final File tempLogFile = temporaryFolder.newFile(LOG_FILE);
- final File tempModelFile = temporaryFolder.newFile(JSON_FILE);
+ final File tempLogFile = temporaryFolder.resolve(LOG_FILE).toFile();
+ final File tempModelFile = temporaryFolder.resolve(JSON_FILE).toFile();
final String[] cliArgs = new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l",
tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()};
@@ -111,7 +107,7 @@ public class CommandLineEditorEventsContextTest {
final String logString = TextFileUtils.getTextFileAsString(tempLogFile.getCanonicalPath());
final String modelString = TextFileUtils.getTextFileAsString(tempModelFile.getCanonicalPath());
- // As a sanity check, count the number of non white space characters in log and model files
+ // As a sanity check, count the number of non-white space characters in log and model files
final int logCharCount = logString.replaceAll(SPACES, EMPTY_STRING).length();
final int modelCharCount = modelString.replaceAll(SPACES, EMPTY_STRING).length();
@@ -121,18 +117,18 @@ public class CommandLineEditorEventsContextTest {
}
@Test
- public void test_emptyMetadataCommandFileWithEmptyJsonTag_errorcountGreaterThanOne() throws IOException {
+ void test_emptyMetadataCommandFileWithEmptyJsonTag_errorCountGreaterThanOne() {
- final File tempLogFile = temporaryFolder.newFile(LOG_FILE);
- final File tempModelFile = temporaryFolder.newFile(JSON_FILE);
+ final File tempLogFile = temporaryFolder.resolve(LOG_FILE).toFile();
+ final File tempModelFile = temporaryFolder.resolve(JSON_FILE).toFile();
final String modelFile = SRC_TEST_FOLDER.resolve("model").resolve("empty_commands.json").toString();
final String apexPropertiesLocation =
- SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json").toString();
+ SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json").toString();
final String[] cliArgs =
- new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o",
- tempModelFile.getAbsolutePath(), "-m", modelFile, "-a", apexPropertiesLocation};
+ new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o",
+ tempModelFile.getAbsolutePath(), "-m", modelFile, "-a", apexPropertiesLocation};
final ApexCommandLineEditorMain objUnderTest = new ApexCommandLineEditorMain(cliArgs);
assertEquals(1, objUnderTest.getErrorCount());
@@ -140,19 +136,19 @@ public class CommandLineEditorEventsContextTest {
}
@Test
- public void test_emptyMetadataCommandFile_errorcountGreaterThanOne() throws IOException {
+ void test_emptyMetadataCommandFile_errorCountGreaterThanOne() {
- final File tempLogFile = temporaryFolder.newFile(LOG_FILE);
- final File tempModelFile = temporaryFolder.newFile(JSON_FILE);
+ final File tempLogFile = temporaryFolder.resolve(LOG_FILE).toFile();
+ final File tempModelFile = temporaryFolder.resolve(JSON_FILE).toFile();
- final File modelFile = temporaryFolder.newFile("empty_commands.json");
+ final File modelFile = temporaryFolder.resolve("empty_commands.json").toFile();
final String apexPropertiesLocation =
- SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json").toString();
+ SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json").toString();
final String[] cliArgs =
- new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o",
- tempModelFile.getAbsolutePath(), "-m", modelFile.getAbsolutePath(), "-a", apexPropertiesLocation};
+ new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o",
+ tempModelFile.getAbsolutePath(), "-m", modelFile.getAbsolutePath(), "-a", apexPropertiesLocation};
final ApexCommandLineEditorMain objUnderTest = new ApexCommandLineEditorMain(cliArgs);
assertEquals(1, objUnderTest.getErrorCount());
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java
index e49422996..dfdb4c2a3 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorOptionsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,16 +21,15 @@
package org.onap.policy.apex.auth.clieditor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.resources.TextFileUtils;
/**
@@ -38,17 +37,16 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CommandLineEditorOptionsTest {
+class CommandLineEditorOptionsTest {
// CHECKSTYLE:OFF: MagicNumber
/**
* Test script options log model.
*
* @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
*/
@Test
- public void testScriptOptionsLogModel() throws IOException, ApexModelException {
+ void testScriptOptionsLogModel() throws IOException {
final File tempLogFile = File.createTempFile("ShellPolicyModel", ".log");
final File tempModelFile = File.createTempFile("ShellPolicyModel", ".json");
@@ -62,25 +60,24 @@ public class CommandLineEditorOptionsTest {
final String logString = TextFileUtils.getTextFileAsString(tempLogFile.getCanonicalPath());
final String modelString = TextFileUtils.getTextFileAsString(tempModelFile.getCanonicalPath());
- // As a sanity check, count the number of non white space characters in log and model files
+ // As a sanity check, count the number of non-white space characters in log and model files
final int logCharCount = logString.replaceAll("\\s+", "").length();
final int modelCharCount = modelString.replaceAll("\\s+", "").length();
assertEquals(1204, logCharCount);
assertEquals(2904, modelCharCount);
- tempLogFile.delete();
- tempModelFile.delete();
+ assertTrue(tempLogFile.delete());
+ assertTrue(tempModelFile.delete());
}
/**
* Test script options no log no model spec.
*
* @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
*/
@Test
- public void testScriptOptionsNoLogNoModelSpec() throws IOException, ApexModelException {
+ void testScriptOptionsNoLogNoModelSpec() throws IOException {
final File tempLogFile = File.createTempFile("ShellPolicyModel", ".log");
final File tempModelFile = File.createTempFile("ShellPolicyModel", ".json");
@@ -101,18 +98,17 @@ public class CommandLineEditorOptionsTest {
assertEquals(0, logCharCount);
assertEquals(0, modelCharCount);
- tempLogFile.delete();
- tempModelFile.delete();
+ assertTrue(tempLogFile.delete());
+ assertTrue(tempModelFile.delete());
}
/**
* Test script options log no model spec.
*
* @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
*/
@Test
- public void testScriptOptionsLogNoModelSpec() throws IOException, ApexModelException {
+ void testScriptOptionsLogNoModelSpec() throws IOException {
final File tempLogFile = File.createTempFile("ShellPolicyModel", ".log");
final File tempModelFile = File.createTempFile("ShellPolicyModel", ".json");
@@ -133,18 +129,17 @@ public class CommandLineEditorOptionsTest {
assertEquals(1204, logCharCount);
assertEquals(0, modelCharCount);
- tempLogFile.delete();
- tempModelFile.delete();
+ assertTrue(tempLogFile.delete());
+ assertTrue(tempModelFile.delete());
}
/**
* Test script options no log model spec.
*
* @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
*/
@Test
- public void testScriptOptionsNoLogModelSpec() throws IOException, ApexModelException {
+ void testScriptOptionsNoLogModelSpec() throws IOException {
final File tempLogFile = File.createTempFile("ShellPolicyModel", ".log");
final File tempModelFile = File.createTempFile("ShellPolicyModel", ".json");
@@ -165,20 +160,17 @@ public class CommandLineEditorOptionsTest {
assertEquals(0, logCharCount);
assertEquals(2904, modelCharCount);
- tempLogFile.delete();
- tempModelFile.delete();
+ assertTrue(tempLogFile.delete());
+ assertTrue(tempModelFile.delete());
}
/**
* Test script options no log no model no spec.
- *
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
*/
@Test
- public void testScriptOptionsNoLogNoModelNoSpec() throws IOException, ApexModelException {
+ void testScriptOptionsNoLogNoModelNoSpec() {
final String[] cliArgs =
- new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-nl", "-nm"};
+ new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-nl", "-nm"};
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -195,12 +187,9 @@ public class CommandLineEditorOptionsTest {
/**
* Test script options log model no spec.
- *
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
*/
@Test
- public void testScriptOptionsLogModelNoSpec() throws IOException, ApexModelException {
+ void testScriptOptionsLogModelNoSpec() {
final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex"};
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -223,10 +212,9 @@ public class CommandLineEditorOptionsTest {
* Test script options input output model.
*
* @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
*/
@Test
- public void testScriptOptionsInputOutputModel() throws IOException, ApexModelException {
+ void testScriptOptionsInputOutputModel() throws IOException {
final File tempLogFileIn = File.createTempFile("ShellPolicyModelIn", ".log");
final File tempLogFileOut = File.createTempFile("ShellPolicyModelOut", ".log");
final File tempModelFileIn = File.createTempFile("ShellPolicyModelIn", ".json");
@@ -243,7 +231,7 @@ public class CommandLineEditorOptionsTest {
final String tempLogFileInString = TextFileUtils.getTextFileAsString(tempLogFileIn.getCanonicalPath());
final String tempModelFileInString = TextFileUtils.getTextFileAsString(tempModelFileIn.getCanonicalPath());
- // As a sanity check, count the number of non white space characters in log and model files
+ // As a sanity check, count the number of non-white space characters in log and model files
final int tempLogFileInCharCount = tempLogFileInString.replaceAll("\\s+", "").length();
final int tempModelFileInCharCount = tempModelFileInString.replaceAll("\\s+", "").length();
@@ -268,9 +256,9 @@ public class CommandLineEditorOptionsTest {
assertEquals(1154, tempLogFileOutCharCount);
assertEquals(3336, tempModelFileOutCharCount);
- tempLogFileIn.delete();
- tempModelFileIn.delete();
- tempLogFileOut.delete();
- tempModelFileOut.delete();
+ assertTrue(tempLogFileIn.delete());
+ assertTrue(tempModelFileIn.delete());
+ assertTrue(tempLogFileOut.delete());
+ assertTrue(tempModelFileOut.delete());
}
}
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java
index d2b3a812f..395f4c6bf 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorScriptingTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,15 +21,15 @@
package org.onap.policy.apex.auth.clieditor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
@@ -41,7 +41,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CommandLineEditorScriptingTest {
+class CommandLineEditorScriptingTest {
private File tempModelFile;
private File tempLogFile;
@@ -55,7 +55,7 @@ public class CommandLineEditorScriptingTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
+ @BeforeEach
public void initialiseArgs() throws IOException {
tempModelFile = File.createTempFile("SampleLBPolicyMap", ".json");
tempLogFile = File.createTempFile("SampleLBPolicyMap", ".log");
@@ -70,10 +70,10 @@ public class CommandLineEditorScriptingTest {
/**
* Removes the generated files.
*/
- @After
+ @AfterEach
public void removeGeneratedFiles() {
- tempModelFile.delete();
- tempLogFile.delete();
+ assertTrue(tempModelFile.delete());
+ assertTrue(tempLogFile.delete());
}
/**
@@ -83,7 +83,7 @@ public class CommandLineEditorScriptingTest {
* @throws ApexModelException if there is an Apex error
*/
@Test
- public void testSamplePolicyScript() throws IOException, ApexModelException {
+ void testSamplePolicyScript() throws IOException, ApexModelException {
final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(samplePolicyArgs);
assertEquals(0, cliEditor.getErrorCount());
@@ -118,8 +118,8 @@ public class CommandLineEditorScriptingTest {
* @throws ApexModelException if there is an Apex error
*/
@Test
- public void testSampleMapPolicyScript() throws IOException, ApexModelException {
- tempModelFile.delete();
+ void testSampleMapPolicyScript() throws IOException, ApexModelException {
+ assertTrue(tempModelFile.delete());
final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(samplePolicyMapArgs);
assertEquals(0, cliEditor.getErrorCount());
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java
index ab9b900af..6984b6701 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/ContextAlbumsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,15 +21,16 @@
package org.onap.policy.apex.auth.clieditor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -38,7 +39,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
/**
* The Class TestContextAlbums.
*/
-public class ContextAlbumsTest {
+class ContextAlbumsTest {
private String[] logicBlockArgs;
private File tempModelFile;
@@ -48,30 +49,30 @@ public class ContextAlbumsTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void createTempFiles() throws IOException {
+ @BeforeEach
+ void createTempFiles() throws IOException {
tempModelFile = File.createTempFile("TestPolicyModel", ".json");
logicBlockArgs = new String[] {"-c", "src/test/resources/scripts/ContextAlbums.apex", "-o",
- tempModelFile.getAbsolutePath(), "-nl"};
+ tempModelFile.getAbsolutePath(), "-nl"};
}
/**
* Removes the generated models.
*/
- @After
- public void removeGeneratedModels() {
- tempModelFile.delete();
+ @AfterEach
+ void removeGeneratedModels() {
+ assertTrue(tempModelFile.delete());
}
/**
* Test logic block.
*
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
* @throws ApexModelException if there is an Apex error
*/
@Test
- public void testLogicBlock() throws IOException, ApexModelException {
+ void testLogicBlock() throws IOException, ApexModelException {
final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(logicBlockArgs);
assertEquals(1, cliEditor.getErrorCount());
@@ -84,7 +85,7 @@ public class ContextAlbumsTest {
assertNotNull(writtenModel);
final URL compareModelUrl =
- ResourceUtils.getLocalFile("src/test/resources/compare/ContextAlbumsModel_Compare.json");
+ ResourceUtils.getLocalFile("src/test/resources/compare/ContextAlbumsModel_Compare.json");
final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java
index 9896ab9ee..d407e5a4e 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/FileMacroTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,15 +21,16 @@
package org.onap.policy.apex.auth.clieditor;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Paths;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -39,7 +40,7 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
/**
* Test FileMacro in the CLI.
*/
-public class FileMacroTest {
+class FileMacroTest {
private String[] fileMacroArgs;
private File tempModelFile;
@@ -50,8 +51,8 @@ public class FileMacroTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void createTempFiles() throws IOException {
+ @BeforeEach
+ void createTempFiles() throws IOException {
tempModelFile = File.createTempFile("TestPolicyModel", ".json");
tempLogFile = File.createTempFile("TestPolicyModel", ".log");
@@ -62,19 +63,19 @@ public class FileMacroTest {
/**
* Removes the generated models.
*/
- @After
- public void removeGeneratedModels() {
- tempModelFile.delete();
+ @AfterEach
+ void removeGeneratedModels() {
+ assertTrue(tempModelFile.delete());
}
/**
* Test logic block macro in CLI scripts.
*
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
* @throws ApexModelException if there is an Apex error
*/
@Test
- public void testLogicBlock() throws IOException, ApexModelException {
+ void testLogicBlock() throws IOException, ApexModelException {
final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(fileMacroArgs);
// We expect eight errors
assertEquals(8, cliEditor.getErrorCount());
@@ -87,7 +88,7 @@ public class FileMacroTest {
final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
final URL compareModelUrl =
- ResourceUtils.getLocalFile("src/test/resources/compare/FileMacroModel_Compare.json");
+ ResourceUtils.getLocalFile("src/test/resources/compare/FileMacroModel_Compare.json");
final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
@@ -100,11 +101,11 @@ public class FileMacroTest {
final File outputLogFile = new File(tempLogFile.getCanonicalPath());
final String outputLogString = TextFileUtils.getTextFileAsString(outputLogFile.getCanonicalPath())
- .replace(Paths.get("").toAbsolutePath().toString() + File.separator, "").replaceAll("\\s+", "");
+ .replace(Paths.get("").toAbsolutePath() + File.separator, "").replaceAll("\\s+", "");
// We compare the log to what we expect to get
final String outputLogCompareString = TextFileUtils
- .getTextFileAsString("src/test/resources/compare/FileMacro_Compare.log").replaceAll("\\s+", "");
+ .getTextFileAsString("src/test/resources/compare/FileMacro_Compare.log").replaceAll("\\s+", "");
// Check what we got is what we expected to get
assertEquals(outputLogCompareString, outputLogString);
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java
index 077f354f6..e30780ca0 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/LogicBlockTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,24 +21,24 @@
package org.onap.policy.apex.auth.clieditor;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.common.utils.resources.ResourceUtils;
-// TODO: Auto-generated Javadoc
/**
* The Class TestLogicBlock.
*/
-public class LogicBlockTest {
+class LogicBlockTest {
private String[] logicBlockArgs;
private String[] avroSchemaArgs;
@@ -50,35 +50,35 @@ public class LogicBlockTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void createTempFiles() throws IOException {
+ @BeforeEach
+ void createTempFiles() throws IOException {
tempLogicModelFile = File.createTempFile("TestLogicPolicyModel", ".json");
tempAvroModelFile = File.createTempFile("TestAvroPolicyModel", ".json");
logicBlockArgs = new String[] {"-c", "src/test/resources/scripts/LogicBlock.apex", "-o",
- tempLogicModelFile.getCanonicalPath(), "-if", "true", "-nl"};
+ tempLogicModelFile.getCanonicalPath(), "-if", "true", "-nl"};
avroSchemaArgs = new String[] {"-c", "src/test/resources/scripts/AvroSchema.apex", "-o",
- tempAvroModelFile.getCanonicalPath(), "-nl"};
+ tempAvroModelFile.getCanonicalPath(), "-nl"};
}
/**
* Removes the temp files.
*/
- @After
- public void removeTempFiles() {
- tempLogicModelFile.delete();
- tempAvroModelFile.delete();
+ @AfterEach
+ void removeTempFiles() {
+ assertTrue(tempLogicModelFile.delete());
+ assertTrue(tempAvroModelFile.delete());
}
/**
* Test logic block.
*
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
* @throws ApexModelException if there is an Apex error
*/
@Test
- public void testLogicBlock() throws IOException, ApexModelException {
+ void testLogicBlock() throws IOException, ApexModelException {
new ApexCommandLineEditorMain(logicBlockArgs);
// Read the file from disk
@@ -89,7 +89,7 @@ public class LogicBlockTest {
final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
final URL compareModelUrl =
- ResourceUtils.getLocalFile("src/test/resources/compare/LogicBlockModel_Compare.json");
+ ResourceUtils.getLocalFile("src/test/resources/compare/LogicBlockModel_Compare.json");
final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
@@ -102,11 +102,11 @@ public class LogicBlockTest {
/**
* Test avro schema.
*
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
* @throws ApexModelException if there is an Apex error
*/
@Test
- public void testAvroSchema() throws IOException, ApexModelException {
+ void testAvroSchema() throws IOException, ApexModelException {
new ApexCommandLineEditorMain(avroSchemaArgs);
// Read the file from disk
@@ -117,7 +117,7 @@ public class LogicBlockTest {
final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
final URL compareModelUrl =
- ResourceUtils.getLocalFile("src/test/resources/compare/AvroSchemaModel_Compare.json");
+ ResourceUtils.getLocalFile("src/test/resources/compare/AvroSchemaModel_Compare.json");
final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
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 51659c2ea..9399b821b 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019,2022 Nordix Foundation.
+ * Copyright (C) 2019, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,17 +22,17 @@
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 static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.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;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.resources.TextFileUtils;
/**
@@ -40,7 +40,7 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
*
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
-public class ApexCliToscaEditorTest {
+class ApexCliToscaEditorTest {
private File tempOutputToscaFile;
private File tempLogFile;
@@ -52,7 +52,7 @@ public class ApexCliToscaEditorTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
+ @BeforeEach
public void initialiseArgs() throws IOException {
tempOutputToscaFile = File.createTempFile("ToscaPolicyOutput", ".json");
@@ -64,21 +64,21 @@ public class ApexCliToscaEditorTest {
"-t", CommonTestData.INPUT_TOSCA_TEMPLATE_FILE_NAME,
"-ot", tempOutputToscaFile.getAbsolutePath(),
"-l", tempLogFile.getAbsolutePath()
- };
+ };
}
/**
* Removes the generated files.
*/
- @After
+ @AfterEach
public void removeGeneratedFiles() {
- tempOutputToscaFile.delete();
- tempLogFile.delete();
- tempNodeTemplateFile.delete();
+ assertTrue(tempOutputToscaFile.delete());
+ assertTrue(tempLogFile.delete());
+ assertTrue(tempNodeTemplateFile.delete());
}
@Test
- public void testApexCliToscaParameterParser() {
+ void testApexCliToscaParameterParser() {
ApexCliToscaParameters params = new ApexCliToscaParameterParser().parse(sampleArgs);
assertEquals(CommonTestData.APEX_CONFIG_FILE_NAME, params.getApexConfigFileName());
assertEquals(CommonTestData.COMMAND_FILE_NAME, params.getCommandFileName());
@@ -88,7 +88,7 @@ public class ApexCliToscaEditorTest {
}
@Test
- public void testApexCliTosca_success() throws IOException {
+ void testApexCliTosca_success() throws IOException {
final ApexCliToscaEditorMain cliEditor = new ApexCliToscaEditorMain(sampleArgs);
@@ -101,24 +101,26 @@ public class ApexCliToscaEditorTest {
}
@Test
- public void testApexCliTosca_no_args() {
+ void testApexCliTosca_no_args() {
String[] noArgs = new String[] {};
assertThatThrownBy(() -> new ApexCliToscaEditorMain(noArgs)).hasMessage("Insufficient arguments provided.");
}
@Test
- public void testApexCliTosca_missing_commandfile() {
- String[] sampleArgs = new String[] {
- "-ac", CommonTestData.APEX_CONFIG_FILE_NAME,
- "-t", CommonTestData.INPUT_TOSCA_TEMPLATE_FILE_NAME,
- "-ot", tempOutputToscaFile.getAbsolutePath(),
- "-l", tempLogFile.getAbsolutePath()
+ void testApexCliTosca_missing_commandFile() {
+ assertThatThrownBy(() -> {
+ String[] sampleArgs = new String[] {
+ "-ac", CommonTestData.APEX_CONFIG_FILE_NAME,
+ "-t", CommonTestData.INPUT_TOSCA_TEMPLATE_FILE_NAME,
+ "-ot", tempOutputToscaFile.getAbsolutePath(),
+ "-l", tempLogFile.getAbsolutePath()
};
- assertThatThrownBy(() -> new ApexCliToscaEditorMain(sampleArgs)).hasMessage("Insufficient arguments provided.");
+ new ApexCliToscaEditorMain(sampleArgs);
+ }).hasMessage("Insufficient arguments provided.");
}
@Test
- public void testGenerateToscaPolicyMetadataSet() throws Exception {
+ void testGenerateToscaPolicyMetadataSet() throws Exception {
// @formatter:off
final String[] cliArgs = new String[] {
"-c", CommonTestData.COMMAND_FILE_NAME,
@@ -135,9 +137,9 @@ public class ApexCliToscaEditorTest {
assertTrue(tempOutputToscaFile.length() > 0);
assertTrue(Files.lines(Paths.get(tempOutputToscaFile.toString()))
- .noneMatch(l -> l.contains("policy_type_impl")));
+ .noneMatch(l -> l.contains("policy_type_impl")));
assertTrue(tempNodeTemplateFile.length() > 0);
assertTrue(Files.lines(Paths.get(tempNodeTemplateFile.toString()))
- .anyMatch(l -> l.contains("policyModel")));
+ .anyMatch(l -> l.contains("policyModel")));
}
}
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 ba3ab7627..eb1fabec5 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019,2022 Nordix Foundation.
+ * Copyright (C) 2019, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,17 +22,17 @@
package org.onap.policy.apex.auth.clieditor.utils;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaParameterParser;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaParameters;
import org.onap.policy.apex.auth.clieditor.tosca.CommonTestData;
@@ -44,7 +44,7 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
*
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
-public class CliUtilsTest {
+class CliUtilsTest {
private File tempOutputToscaFile;
private File tempLogFile;
@@ -56,7 +56,7 @@ public class CliUtilsTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
+ @BeforeEach
public void initialiseArgs() throws IOException {
tempOutputToscaFile = File.createTempFile("ToscaPolicyOutput", ".json");
@@ -70,14 +70,14 @@ public class CliUtilsTest {
/**
* Removes the generated files.
*/
- @After
+ @AfterEach
public void removeGeneratedFiles() {
- tempOutputToscaFile.delete();
- tempLogFile.delete();
+ assertTrue(tempOutputToscaFile.delete());
+ assertTrue(tempLogFile.delete());
}
@Test
- public void testCreateToscaServiceTemplate() throws IOException, CoderException {
+ void testCreateToscaServiceTemplate() throws IOException, CoderException {
ApexCliToscaParameters params = new ApexCliToscaParameterParser().parse(sampleArgs);
CliUtils.createToscaPolicy(params, policyModelFilePath, null);
String outputTosca = TextFileUtils.getTextFileAsString(tempOutputToscaFile.getAbsolutePath());
@@ -87,43 +87,43 @@ public class CliUtilsTest {
}
@Test
- public void testValidateReadableFile_validfile() {
+ void testValidateReadableFile_validFile() {
CliUtils.validateReadableFile("Apex Config File", CommonTestData.APEX_CONFIG_FILE_NAME);
}
@Test
- public void testValidateReadableFile_invalidfile() {
+ void testValidateReadableFile_invalidFile() {
String invalidFileName = "src/test/resources/tosca/ApexConfigxyz.json";
assertThatThrownBy(() -> CliUtils.validateReadableFile("Apex Config File", invalidFileName))
.hasMessage("File " + invalidFileName + " of type Apex Config File does not exist");
}
@Test
- public void testValidateWritableFile_validfile() {
+ void testValidateWritableFile_validFile() {
CliUtils.validateWritableFile("Output Tosca Policy File", tempOutputToscaFile.getAbsolutePath());
}
@Test
- public void testValidateWritableFile_invalidfile() {
+ void testValidateWritableFile_invalidFile() {
String invalidFileName = "src/test/resources/tosca";
assertThatThrownBy(() -> CliUtils.validateWritableFile("Output Tosca Policy File", invalidFileName))
.hasMessage("File " + invalidFileName + " of type Output Tosca Policy File is not a normal file");
}
@Test
- public void testValidateWritableDirectory_validdirectory() {
+ void testValidateWritableDirectory_validDirectory() {
CliUtils.validateWritableDirectory("Working Directory", "src/test/resources/tosca");
}
@Test
- public void testValidateWritableDirectory_invaliddirectory() {
+ void testValidateWritableDirectory_invalidDirectory() {
assertThatThrownBy(() -> CliUtils.validateWritableDirectory("Working Directory",
CommonTestData.APEX_CONFIG_FILE_NAME)).hasMessage("directory " + CommonTestData.APEX_CONFIG_FILE_NAME
- + " of type Working Directory is not a directory");
+ + " of type Working Directory is not a directory");
}
@Test
- public void testGenerateArgumentsForCliEditor_success() {
+ void testGenerateArgumentsForCliEditor_success() {
ApexCliToscaParameters params = new ApexCliToscaParameterParser().parse(sampleArgs);
Properties optionVariableMap = new Properties();
optionVariableMap.setProperty("c", "commandFileName");
@@ -137,7 +137,7 @@ public class CliUtilsTest {
}
@Test
- public void testGenerateArgumentsForCliEditor_invalidvariable() {
+ void testGenerateArgumentsForCliEditor_invalidVariable() {
ApexCliToscaParameters params = new ApexCliToscaParameterParser().parse(sampleArgs);
Properties optionVariableMap = new Properties();
optionVariableMap.setProperty("c", "invalidFileName");
@@ -147,7 +147,7 @@ public class CliUtilsTest {
}
@Test
- public void testGenerateArgumentsForCliEditor_missingoption() {
+ void testGenerateArgumentsForCliEditor_missingOption() {
ApexCliToscaParameters params = new ApexCliToscaParameterParser().parse(sampleArgs);
Properties optionVariableMap = new Properties();
List<String> cliArgsList =