summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-06-11 15:49:30 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-06-17 16:12:00 +0100
commitdd15704b23b3b1e9508a5f615f066ffca46a7101 (patch)
treec3a1158fc288223fcb4173765e71637d844a3501
parente9b746340711ddfccee7ac0f669ace626b1b3d46 (diff)
Convert junit4 to junit5
- tools module Issue-ID: POLICY-5041 Change-Id: I4fddc20e306e82db8af858ff2444f7e40c9e5acd Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
-rw-r--r--tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/KeyInfoGetterTest.java31
-rw-r--r--tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java40
-rw-r--r--tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java32
-rw-r--r--tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java43
-rw-r--r--tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java50
-rw-r--r--tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java35
-rw-r--r--tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java18
-rw-r--r--tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/ConsoleTest.java35
-rw-r--r--tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java35
-rw-r--r--tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java18
-rw-r--r--tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java18
11 files changed, 179 insertions, 176 deletions
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/KeyInfoGetterTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/KeyInfoGetterTest.java
index e6ecefd12..3ba316f8a 100644
--- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/KeyInfoGetterTest.java
+++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/KeyInfoGetterTest.java
@@ -1,29 +1,30 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.tools.model.generator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-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.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.concepts.AxState;
@@ -32,10 +33,10 @@ import org.onap.policy.apex.testsuites.integration.common.model.SampleDomainMode
/**
* Test the Key Info Getter.
*/
-public class KeyInfoGetterTest {
+class KeyInfoGetterTest {
@Test
- public void testKeyInfoGetter() {
+ void testKeyInfoGetter() {
AxPolicyModel sampleModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
KeyInfoGetter kiGetter = new KeyInfoGetter(sampleModel);
@@ -50,22 +51,22 @@ public class KeyInfoGetterTest {
assertNull(kiGetter.getDesc(null));
assertNull(kiGetter.getDesc(new AxArtifactKey()));
assertEquals("Generated description for concept referred to by key " + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"",
- kiGetter.getDesc(sampleModel.getKey()));
-
+ kiGetter.getDesc(sampleModel.getKey()));
+
assertNull(kiGetter.getVersion(null));
assertEquals("0.0.1", kiGetter.getVersion(sampleModel.getKey()));
-
+
AxState matchState = sampleModel.getPolicies().get("Policy0").getStateMap().get("Match");
-
+
assertNull(kiGetter.getLName(null));
assertEquals("Match", kiGetter.getLName(matchState.getKey()));
-
+
assertNull(kiGetter.getPName(null));
assertEquals("Policy0", kiGetter.getPName(matchState.getKey()));
-
+
assertNull(kiGetter.getPVersion(null));
assertEquals("0.0.1", kiGetter.getPVersion(matchState.getKey()));
-
+
assertNull(kiGetter.getPlName(null));
assertEquals("NULL", kiGetter.getPlName(matchState.getKey()));
}
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java
index a195411f3..f4f0997af 100644
--- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java
+++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 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.
@@ -22,7 +22,7 @@
package org.onap.policy.apex.tools.model.generator;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -31,8 +31,8 @@ import java.util.List;
import java.util.Map;
import org.apache.avro.Schema;
import org.apache.avro.Schema.Field;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -63,10 +63,10 @@ public class SchemaUtilsTest {
/**
* Read the models into strings.
*
- * @throws IOException on model reading errors
+ * @throws IOException on model reading errors
* @throws ApexModelException on model reading exceptions
*/
- @BeforeClass
+ @BeforeAll
public static void readSimpleModel() throws IOException, ApexModelException {
String avroModelString = TextFileUtils.getTextFileAsString("src/test/resources/vpnsla.json");
@@ -75,18 +75,17 @@ public class SchemaUtilsTest {
}
@Test
- public void testSchemaUtilsErrors() {
+ void testSchemaUtilsErrors() {
AxEvent event = avroModel.getEvents().get("CustomerContextEventIn");
+ String modelClassName = "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas";
assertThatThrownBy(() -> SchemaUtils.getEventSchema(event))
- .hasMessage("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas"
- + " not found in model service");
+ .hasMessage("Model for " + modelClassName + " not found in model service");
assertThatThrownBy(() -> {
Map<String, Schema> preexistingParamSchemas = new LinkedHashMap<>();
SchemaUtils.getEventParameterSchema(event.getParameterMap().get("links"), preexistingParamSchemas);
- }).hasMessage("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas"
- + " not found in model service");
+ }).hasMessage("Model for " + modelClassName + " not found in model service");
List<Field> skeletonFields = SchemaUtils.getSkeletonEventSchemaFields();
assertEquals(5, skeletonFields.size());
@@ -95,16 +94,15 @@ public class SchemaUtilsTest {
AxArtifactKey topoNodesKey = new AxArtifactKey("albumTopoNodes", "0.0.1");
assertThatThrownBy(() -> {
AvroSchemaHelper schemaHelper = (AvroSchemaHelper) new SchemaHelperFactory()
- .createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey());
+ .createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey());
Map<String, Schema> schemaMap = new LinkedHashMap<>();
SchemaUtils.processSubSchemas(schemaHelper.getAvroSchema(), schemaMap);
- }).hasMessage("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas"
- + " not found in model service");
+ }).hasMessage("Model for " + modelClassName + " not found in model service");
}
@Test
- public void testSchemaUtils() throws ApexEventException {
+ void testSchemaUtils() throws ApexEventException {
ParameterService.clear();
final SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -117,11 +115,11 @@ public class SchemaUtilsTest {
Schema eventSchema = SchemaUtils.getEventSchema(event);
assertEquals("{\"type\":\"record\",\"name\":\"CustomerContextEventIn\"",
- eventSchema.toString().substring(0, 48));
+ eventSchema.toString().substring(0, 48));
Map<String, Schema> preexistingParamSchemas = new LinkedHashMap<>();
Schema epSchema =
- SchemaUtils.getEventParameterSchema(event.getParameterMap().get("links"), preexistingParamSchemas);
+ SchemaUtils.getEventParameterSchema(event.getParameterMap().get("links"), preexistingParamSchemas);
assertEquals("\"string\"", epSchema.toString());
AxContextSchema avroCtxtSchema = avroModel.getSchemas().get("ctxtTopologyNodesDecl");
@@ -131,7 +129,7 @@ public class SchemaUtilsTest {
assertThatThrownBy(() -> {
AvroSchemaHelper schemaHelper = (AvroSchemaHelper) new SchemaHelperFactory()
- .createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey());
+ .createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey());
Map<String, Schema> schemaMap = new LinkedHashMap<>();
SchemaUtils.processSubSchemas(schemaHelper.getAvroSchema(), schemaMap);
@@ -140,20 +138,20 @@ public class SchemaUtilsTest {
schemaParameters.getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
AvroSchemaHelper schemaHelper =
- (AvroSchemaHelper) new SchemaHelperFactory().createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey());
+ (AvroSchemaHelper) new SchemaHelperFactory().createSchemaHelper(topoNodesKey, avroCtxtSchema.getKey());
Map<String, Schema> schemaMap = new LinkedHashMap<>();
SchemaUtils.processSubSchemas(schemaHelper.getAvroSchema(), schemaMap);
eventSchema = SchemaUtils.getEventSchema(event);
assertEquals("{\"type\":\"record\",\"name\":\"CustomerContextEventIn\"",
- eventSchema.toString().substring(0, 48));
+ eventSchema.toString().substring(0, 48));
epSchema = SchemaUtils.getEventParameterSchema(event.getParameterMap().get("links"), preexistingParamSchemas);
assertEquals("\"string\"", epSchema.toString());
AxInputField inField =
- new AxInputField(new AxReferenceKey("FieldParent", "0.0.1", "Field"), avroCtxtSchema.getKey(), false);
+ new AxInputField(new AxReferenceKey("FieldParent", "0.0.1", "Field"), avroCtxtSchema.getKey(), false);
Schema ep2Schema = SchemaUtils.getEventParameterSchema(inField, preexistingParamSchemas);
assertEquals("{\"type\":\"record\",\"name\":\"TopologyNodes\"", ep2Schema.toString().substring(0, 39));
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java
index b27c16842..41be1d3dd 100644
--- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java
+++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,27 +24,27 @@ package org.onap.policy.apex.tools.model.generator.model2cli;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertTrue;
+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.junit.jupiter.api.Test;
/**
* Test the Model2Cli utility.
*/
-public class Model2CliTest {
+class Model2CliTest {
@Test
- public void testModel2Cli() {
+ void testModel2Cli() {
final String[] cliArgs = {"-h"};
assertThatCode(() -> Model2CliMain.main(cliArgs)).doesNotThrowAnyException();
}
@Test
- public void testModel2CliNoOptions() {
+ void testModel2CliNoOptions() {
final String[] cliArgs = new String[] {};
final String outputString = runModel2Cli(cliArgs);
@@ -53,22 +53,22 @@ public class Model2CliTest {
}
@Test
- public void testModel2CliBadOptions() {
+ void testModel2CliBadOptions() {
assertThat(runModel2Cli(new String[] {"-zabbu"})).contains("usage: gen-model2cli");
}
@Test
- public void testModel2CliHelp() {
+ void testModel2CliHelp() {
assertThat(runModel2Cli(new String[] {"-h"})).contains("usage: gen-model2cli");
}
@Test
- public void testModel2CliVersion() {
+ void testModel2CliVersion() {
assertThat(runModel2Cli(new String[] {"-v"})).contains("gen-model2cli").doesNotContain("usage:");
}
@Test
- public void testModel2CliOverwrite() throws IOException {
+ void testModel2CliOverwrite() throws IOException {
File tempFile = File.createTempFile("AvroModel", ".apex");
tempFile.deleteOnExit();
@@ -80,32 +80,32 @@ public class Model2CliTest {
}
@Test
- public void testModel2CliAadm() throws IOException {
+ void testModel2CliAadm() throws IOException {
testModel2CliModel("target/examples/models/AADM", "AADMPolicyModel");
}
@Test
- public void testModel2CliAnomaly() throws IOException {
+ void testModel2CliAnomaly() throws IOException {
testModel2CliModel("target/examples/models/Adaptive", "AnomalyDetectionPolicyModel");
}
@Test
- public void testModel2CliAutoLearn() throws IOException {
+ void testModel2CliAutoLearn() throws IOException {
testModel2CliModel("target/examples/models/Adaptive", "AutoLearnPolicyModel");
}
@Test
- public void testModel2CliJms() throws IOException {
+ void testModel2CliJms() throws IOException {
testModel2CliModel("target/examples/models/JMS", "JMSTestModel");
}
@Test
- public void testModel2CliMfp() throws IOException {
+ void testModel2CliMfp() throws IOException {
testModel2CliModel("target/examples/models/MyFirstPolicy/2", "MyFirstPolicyModel_0.0.1");
}
@Test
- public void testModel2CliSample() throws IOException {
+ void testModel2CliSample() throws IOException {
testModel2CliModel("target/examples/models/SampleDomain", "SamplePolicyModelJAVASCRIPT");
}
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java
index 9c7eccd0f..9ffbd3ca4 100644
--- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java
+++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventSchemaTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 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,15 +22,15 @@
package org.onap.policy.apex.tools.model.generator.model2event;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import org.apache.avro.Schema;
import org.apache.avro.Schema.Field;
import org.apache.avro.Schema.Type;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
@@ -42,17 +42,20 @@ import org.stringtemplate.v4.STGroupFile;
/**
* Test the Model2EventSchema.
*/
-public class Model2EventSchemaTest {
+class Model2EventSchemaTest {
String modelFile = "src/test/resources/blankSchema.json";
String type = "stimuli";
- /** The name of the application. */
- public static final String APP_NAME = "gen-model2eventSchema";
/**
- * Set ups parameterService for the test.
+ * The name of the application.
*/
- @BeforeClass
- public static void prepareForTest() {
+ private static final String APP_NAME = "gen-model2eventSchema";
+
+ /**
+ * Set-ups parameterService for the test.
+ */
+ @BeforeAll
+ static void prepareForTest() {
final SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
@@ -62,7 +65,7 @@ public class Model2EventSchemaTest {
}
@Test
- public void testEventSchemaBadModelFile() {
+ void testEventSchemaBadModelFile() {
Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
assertThatCode(() -> {
int ret = app.runApp();
@@ -72,7 +75,7 @@ public class Model2EventSchemaTest {
}
@Test
- public void testEventSchemaBadType() {
+ void testEventSchemaBadType() {
modelFile = "src/test/resources/SmallModel.json";
type = "default";
Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
@@ -83,19 +86,19 @@ public class Model2EventSchemaTest {
}
@Test
- public void testEventSchemaStimuli() throws ApexException {
+ void testEventSchemaStimuli() throws ApexException {
modelFile = "src/test/resources/SmallModel.json";
String[] types = {"stimuli", "response", "internal"};
- for (String type2: types) {
+ for (String type2 : types) {
type = type2;
Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
- assertEquals(type, 0, app.runApp());
+ assertEquals(0, app.runApp(), type);
}
}
@Test
- public void testEventSchemaNotSimpleType() {
+ void testEventSchemaNotSimpleType() {
modelFile = "src/test/resources/ExecutionPropertiesRestTestPolicyModel.json";
type = "internal";
Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
@@ -103,7 +106,7 @@ public class Model2EventSchemaTest {
Field stringField = new Field("string", Schema.create(Type.STRING), null, null);
Field enumField =
- new Field("enum", Schema.createEnum("my_enum", "doc", null, Arrays.asList("a", "b", "c")), null, null);
+ new Field("enum", Schema.createEnum("my_enum", "doc", null, Arrays.asList("a", "b", "c")), null, null);
Schema schema = Schema.createRecord("my_record", "doc", "mytest", false);
schema.setFields(Arrays.asList(stringField, enumField));
Schema arrayOut = Schema.createArray(schema);
@@ -115,8 +118,8 @@ public class Model2EventSchemaTest {
}).doesNotThrowAnyException();
}
- @AfterClass
- public static void cleanTest() {
+ @AfterAll
+ static void cleanTest() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
ModelService.clear();
}
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java
index c9180607e..93bb6e9e8 100644
--- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java
+++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2event/Model2EventTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,31 +24,27 @@ package org.onap.policy.apex.tools.model.generator.model2event;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertTrue;
+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.junit.jupiter.api.Test;
/**
* Test the Model2Event utility.
*/
-public class Model2EventTest {
+class Model2EventTest {
@Test
- public void testModel2Event() {
- final String[] EventArgs =
- { "-h" };
-
+ void testModel2Event() {
+ final String[] EventArgs = {"-h"};
assertThatCode(() -> Model2EventMain.main(EventArgs)).doesNotThrowAnyException();
-
}
@Test
- public void testModel2EventNoOptions() {
- final String[] EventArgs = new String[]
- {};
+ void testModel2EventNoOptions() {
+ final String[] EventArgs = new String[] {};
final String outputString = runModel2Event(EventArgs);
@@ -56,24 +52,24 @@ public class Model2EventTest {
}
@Test
- public void testModel2EventBadOptions() {
+ void testModel2EventBadOptions() {
assertThat(runModel2Event(new String[] {"-zabbu"})).contains("usage: gen-model2event");
}
@Test
- public void testModel2EventHelp() {
+ void testModel2EventHelp() {
assertThat(runModel2Event(new String[] {"-h"})).contains("usage: gen-model2event");
}
@Test
- public void testModel2EventVersion() {
+ void testModel2EventVersion() {
assertThat(runModel2Event(new String[] {"-v"})).contains("gen-model2event").doesNotContain("usage:");
}
@Test
- public void testModel2EventNoType() {
+ void testModel2EventNoType() {
final String[] EventArgs =
- { "-m", "src/test/resources/models/AvroModel.json" };
+ {"-m", "src/test/resources/models/AvroModel.json"};
final String outputString = runModel2Event(EventArgs);
@@ -81,9 +77,9 @@ public class Model2EventTest {
}
@Test
- public void testModel2EventBadType() {
+ void testModel2EventBadType() {
final String[] EventArgs =
- { "-m", "src/test/resources/models/AvroModel.json", "-t", "Zooby" };
+ {"-m", "src/test/resources/models/AvroModel.json", "-t", "Zooby"};
final String outputString = runModel2Event(EventArgs);
@@ -91,27 +87,27 @@ public class Model2EventTest {
}
@Test
- public void testModel2EventAadm() throws IOException {
+ void testModel2EventAadm() throws IOException {
testModel2EventModel("AADMPolicyModel");
}
@Test
- public void testModel2EventAnomaly() throws IOException {
+ void testModel2EventAnomaly() throws IOException {
testModel2EventModel("AnomalyDetectionPolicyModel");
}
@Test
- public void testModel2EventAutoLearn() throws IOException {
+ void testModel2EventAutoLearn() throws IOException {
testModel2EventModel("AutoLearnPolicyModel");
}
@Test
- public void testModel2EventMfp() throws IOException {
+ void testModel2EventMfp() throws IOException {
testModel2EventModel("MyFirstPolicyModel");
}
@Test
- public void testModel2EventSample() throws IOException {
+ void testModel2EventSample() throws IOException {
testModel2EventModel("SamplePolicyModelJAVASCRIPT");
}
@@ -143,17 +139,17 @@ public class Model2EventTest {
tempFile.deleteOnExit();
final String[] eventArgs0 =
- { "-m", "src/test/resources/models/" + modelName + ".json", "-t", "stimuli" };
+ {"-m", "src/test/resources/models/" + modelName + ".json", "-t", "stimuli"};
final String outputString0 = runModel2Event(eventArgs0);
assertTrue(outputString0.contains("type: stimuli"));
- final String[] eventArgs1 = {"-m", "src/test/resources/models/" + modelName + ".json", "-t", "response" };
+ final String[] eventArgs1 = {"-m", "src/test/resources/models/" + modelName + ".json", "-t", "response"};
final String outputString1 = runModel2Event(eventArgs1);
assertTrue(outputString1.contains("type: response"));
- final String[] eventArgs2 = {"-m", "src/test/resources/models/" + modelName + ".json", "-t", "internal" };
+ final String[] eventArgs2 = {"-m", "src/test/resources/models/" + modelName + ".json", "-t", "internal"};
final String outputString2 = runModel2Event(eventArgs2);
assertTrue(outputString2.contains("type: internal"));
diff --git a/tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java b/tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java
index e3e775af4..2c618c6a7 100644
--- a/tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java
+++ b/tools/simple-wsclient/src/test/java/org/onap/policy/apex/tools/simple/wsclient/WsClientTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,70 +29,71 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the WsClient utility.
*/
-public class WsClientTest {
+class WsClientTest {
+
@Test
- public void testWsClient() {
+ void testWsClient() {
final String[] EventArgs =
- { "-h" };
+ {"-h"};
assertThatCode(() -> WsClientMain.main(EventArgs)).doesNotThrowAnyException();
}
@Test
- public void testWsClientNoOptions() {
+ void testWsClientNoOptions() {
assertThat(runWsClient(new String[] {})).contains("ws-client: starting simple event echo");
}
@Test
- public void testWsClientBadOptions() {
+ void testWsClientBadOptions() {
assertThat(runWsClient(new String[] {"-zabbu"})).contains("usage: ws-client");
}
@Test
- public void testWsClientHelp() {
+ void testWsClientHelp() {
assertThat(runWsClient(new String[] {"-h"})).contains("usage: ws-client");
}
@Test
- public void testWsClientVersion() {
+ void testWsClientVersion() {
assertThat(runWsClient(new String[] {"-v"})).contains("ws-client").doesNotContain("usage:");
}
@Test
- public void testWsClientNoServerArg() {
+ void testWsClientNoServerArg() {
assertThat(runWsClient(new String[] {"-s"})).contains("ws-client");
}
@Test
- public void testWsClientNoPortArg() {
+ void testWsClientNoPortArg() {
assertThat(runWsClient(new String[] {"-p"})).contains("usage: ws-client");
}
@Test
- public void testWsClientBadPortArg() {
+ void testWsClientBadPortArg() {
assertThat(runWsClient(new String[] {"-p", "hello"})).contains("ws-client");
}
@Test
- public void testWsClientBadServerArg() {
+ void testWsClientBadServerArg() {
assertThat(runWsClient(new String[] {"-s", "asdsadadasd:asdasdsadasd"})).contains("ws-client");
}
@Test
- public void testWsClientConsole() {
+ void testWsClientConsole() {
assertThat(runWsClient(new String[] {"-c", "-s", "AServerThatDoesntExist", "-p", "99999999"}))
- .contains("terminate the application typing");
+ .contains("terminate the application typing");
}
@Test
- public void testWsClientEcho() {
+ void testWsClientEcho() {
assertThat(runWsClient(new String[] {"-s", "AServerThatDoesntExist", "-p", "99999999"})).contains(
- "Once started, the application will simply print out all received events to standard out");
+ "Once started, the application will simply print out all received events to standard out");
}
/**
diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java
index 80980bb34..62dd1c2db 100644
--- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.java
+++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/CliParserTest.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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,10 +23,10 @@ package org.onap.policy.apex.tools.common;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.commons.cli.Option;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -36,13 +36,15 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
-public class CliParserTest {
+class CliParserTest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(CliParserTest.class);
- /** Testapp version. */
+ /**
+ * Test app version.
+ */
@Test
- public void testappVersion() {
+ void testAppVersion() {
final CliParser cli = new CliParser();
assertNotNull(cli);
LOGGER.info(cli.getAppVersion());
@@ -52,7 +54,7 @@ public class CliParserTest {
* testAddAndGetOptionException.
*/
@Test
- public void testAddAndGetOptionException() {
+ void testAddAndGetOptionException() {
final CliParser cli = new CliParser();
assertThatThrownBy(() -> {
cli.addOption(null);
@@ -63,7 +65,7 @@ public class CliParserTest {
* testParseAndGetCli.
*/
@Test
- public void testParseAndGetCli() {
+ void testParseAndGetCli() {
final CliParser cli = new CliParser();
final Option option = new Option("g", "Good option.");
cli.addOption(option);
diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/ConsoleTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/ConsoleTest.java
index aefa92b9c..70c8d1e4d 100644
--- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/ConsoleTest.java
+++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/ConsoleTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 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.
@@ -24,31 +24,30 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-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;
/**
* Tests for {@link Console}.
- *
*/
-public class ConsoleTest {
+class ConsoleTest {
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
private final PrintStream originalErr = System.err;
- @Before
+ @BeforeEach
public void setUpStreams() {
System.setErr(new PrintStream(errContent));
}
- @After
+ @AfterEach
public void restoreStreams() {
System.setErr(originalErr);
}
@Test
- public void testConsole() {
+ void testConsole() {
Console.CONSOLE.setAppName(null);
Console.CONSOLE.info("");
Console.CONSOLE.error("");
@@ -61,23 +60,23 @@ public class ConsoleTest {
Console.CONSOLE.setAppName("");
Console.CONSOLE.set(Console.TYPE_DEBUG, Console.TYPE_ERROR, Console.TYPE_INFO, Console.TYPE_PROGRESS,
- Console.TYPE_WARNING, Console.TYPE_TRACE, Console.TYPE_STACKTRACE);
+ Console.TYPE_WARNING, Console.TYPE_TRACE, Console.TYPE_STACKTRACE);
Console.CONSOLE.configure(Console.CONFIG_COLLECT_WARNINGS);
logMessage();
assertThat(errContent.toString().trim()).contains("debug: debug message.")
- .contains("error: error message.").contains("info message.").contains("progress: progress message.")
- .contains("warning: warn message.").contains("trace: trace message.")
- .contains("exception message: Exception message.");
+ .contains("error: error message.").contains("info message.").contains("progress: progress message.")
+ .contains("warning: warn message.").contains("trace: trace message.")
+ .contains("exception message: Exception message.");
reset();
Console.CONSOLE.setAppName("ConsoleTest");
Console.CONSOLE.configure(Console.CONFIG_COLLECT_ERRORS);
logMessage();
assertThat(errContent.toString().trim())
- .contains("ConsoleTest: debug: debug message.").contains("ConsoleTest: error: error message.")
- .contains("ConsoleTest: info message.").contains("ConsoleTest: progress: progress message.")
- .contains("ConsoleTest: warning: warn message.").contains("ConsoleTest: trace: trace message.")
- .contains("ConsoleTest: exception message: Exception message.");
+ .contains("ConsoleTest: debug: debug message.").contains("ConsoleTest: error: error message.")
+ .contains("ConsoleTest: info message.").contains("ConsoleTest: progress: progress message.")
+ .contains("ConsoleTest: warning: warn message.").contains("ConsoleTest: trace: trace message.")
+ .contains("ConsoleTest: exception message: Exception message.");
reset();
Console.CONSOLE.deActivate(Console.TYPE_DEBUG);
@@ -94,7 +93,7 @@ public class ConsoleTest {
Console.CONSOLE.setAppName(null);
Console.CONSOLE.stacktrace(new Exception("Exception message.", new Throwable("test stacktrace!")));
assertThat(errContent.toString()).contains("exception message: Exception message.")
- .contains("exception cause: java.lang.Throwable: test stacktrace!");
+ .contains("exception cause: java.lang.Throwable: test stacktrace!");
reset();
}
diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java
index abc01b5e3..decbb4395 100644
--- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java
+++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/OutputFileTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (c) 2020 Nordix Foundation.
+ * Copyright (c) 2020, 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.
@@ -20,32 +20,33 @@
package org.onap.policy.apex.tools.common;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.nio.file.FileSystems;
import java.nio.file.Path;
-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;
-public class OutputFileTest {
+class OutputFileTest {
final String testFileName = "testing.txt";
final Path fp = FileSystems.getDefault().getPath(testFileName);
File file = fp.toFile();
- @Before
- public void beforeSetUp() {
+ @BeforeEach
+ void beforeSetUp() {
if (file.exists()) {
- file.delete();
+ assertTrue(file.delete());
}
}
@Test
- public void testToWriter() {
+ void testToWriter() {
OutputFile testFile = new OutputFile(testFileName, false);
testFile.validate();
file.setReadable(false);
@@ -56,7 +57,7 @@ public class OutputFileTest {
}
@Test
- public void testValidate() {
+ void testValidate() {
OutputFile testFile = new OutputFile(testFileName, true);
assertNull(testFile.validate());
file.setReadable(false);
@@ -68,7 +69,7 @@ public class OutputFileTest {
}
@Test
- public void testToOutputStream() {
+ void testToOutputStream() {
OutputFile testFile = new OutputFile(testFileName, true);
assertNotNull(testFile.toOutputStream());
file.setReadable(false);
@@ -76,10 +77,10 @@ public class OutputFileTest {
assertNull(testFile.toOutputStream());
}
- @After
- public void testDown() {
+ @AfterEach
+ void testDown() {
if (file.exists()) {
- file.delete();
+ assertTrue(file.delete());
}
}
}
diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java
index 1dc8d53ef..f817dc152 100644
--- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java
+++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.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.
* ================================================================================
* 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.tools.common.docs;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
////
//// NOTE: This file contains tags for ASCIIDOC
@@ -30,7 +30,7 @@ import static org.junit.Assert.assertNotNull;
////// end::**
////
import org.apache.commons.cli.CommandLine;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.tools.common.CliOptions;
import org.onap.policy.apex.tools.common.CliParser;
import org.slf4j.ext.XLogger;
@@ -41,14 +41,16 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
-public class ExampleAppVersionTest {
+class ExampleAppVersionTest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ExampleAppVersionTest.class);
- /** Test example app version. */
+ /**
+ * Test example app version.
+ */
@Test
- public void testExampleAppVersion() {
- final String[] args = new String[] { "-v" };
+ void testExampleAppVersion() {
+ final String[] args = new String[] {"-v"};
// tag::setupParser[]
final CliParser cli = new CliParser();
@@ -60,7 +62,7 @@ public class ExampleAppVersionTest {
// tag::processCliVersion[]
// version is an exit option, print version and exit
if (cmd.hasOption('v') || cmd.hasOption("version")) {
- LOGGER.info("myApp" + " " + cli.getAppVersion());
+ LOGGER.info("myApp {}", cli.getAppVersion());
return;
}
// end::processCliVersion[]
diff --git a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java
index c653cd0b2..0be41d685 100644
--- a/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java
+++ b/tools/tools-common/src/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.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.
* ================================================================================
* 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.tools.common.docs;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
////
////NOTE: This file contains tags for ASCIIDOC
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertNotNull;
////
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
//tag::import[]
import org.onap.policy.apex.tools.common.CliOptions;
import org.onap.policy.apex.tools.common.CliParser;
@@ -46,7 +46,7 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
-public class ExampleCliParserTest {
+class ExampleCliParserTest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ExampleCliParserTest.class);
@@ -54,8 +54,8 @@ public class ExampleCliParserTest {
* Test example parser.
*/
@Test
- public void testExampleParser() {
- final String[] args = new String[] { "-h" };
+ void testExampleParser() {
+ final String[] args = new String[] {"-h"};
// tag::setApp[]
final String appName = "test-app";
@@ -79,7 +79,7 @@ public class ExampleCliParserTest {
// help is an exit option, print usage and exit
if (cmd.hasOption('h') || cmd.hasOption("help")) {
final HelpFormatter formatter = new HelpFormatter();
- LOGGER.info(appName + " v" + cli.getAppVersion() + " - " + appDescription);
+ LOGGER.info(appName + " v{} - " + appDescription, cli.getAppVersion());
formatter.printHelp(appName, cli.getOptions());
return;
}
@@ -88,7 +88,7 @@ public class ExampleCliParserTest {
// tag::processCliVersion[]
// version is an exit option, print version and exit
if (cmd.hasOption('v') || cmd.hasOption("version")) {
- LOGGER.info(appName + " " + cli.getAppVersion());
+ LOGGER.info(appName + " {}", cli.getAppVersion());
return;
}
// end::processCliVersion[]
@@ -106,7 +106,7 @@ public class ExampleCliParserTest {
// tag::someStartPrint[]
LOGGER.info(appName + ": starting");
- LOGGER.info(" --> model file: " + modelFile);
+ LOGGER.info(" --> model file: {}", modelFile);
// end::someStartPrint[]
// tag::yourApp[]