aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-schema
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-06-17 15:31:12 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-06-17 16:05:42 +0100
commitfe6bb57982677177f85daa5f893868556b18e63c (patch)
tree54a2f6f5a3e31469c4ea703a777399fb30fc9cfc /plugins/plugins-context/plugins-context-schema
parente9b746340711ddfccee7ac0f669ace626b1b3d46 (diff)
Convert junit4 to junit5
- plugins module Issue-ID: POLICY-5041 Change-Id: Iebff0a2e6898a5dfe9679662dd2be4c5067a4008 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'plugins/plugins-context/plugins-context-schema')
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java33
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java44
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java36
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java43
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java35
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java71
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java71
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java94
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java60
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java41
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java13
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java19
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java32
13 files changed, 292 insertions, 300 deletions
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java
index 9051f3688..93bbe2054 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaAaiTest.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,14 +21,14 @@
package org.onap.policy.apex.plugins.context.schema.avro;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Array;
import org.apache.avro.generic.GenericRecord;
-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.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -45,9 +45,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
* The Class TestAvroSchemaAai.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaAaiTest {
+class AvroSchemaAaiTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String aaiInventoryResponseSchema;
@@ -57,20 +56,20 @@ public class AvroSchemaAaiTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
aaiInventoryResponseSchema =
- TextFileUtils.getTextFileAsString("src/test/resources/avsc/AAIInventoryResponseItemType.avsc");
+ TextFileUtils.getTextFileAsString("src/test/resources/avsc/AAIInventoryResponseItemType.avsc");
}
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +80,8 @@ public class AvroSchemaAaiTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,9 +91,9 @@ public class AvroSchemaAaiTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testAaiResponsePolicy() throws IOException {
+ void testAaiResponsePolicy() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", aaiInventoryResponseSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", aaiInventoryResponseSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -105,7 +104,7 @@ public class AvroSchemaAaiTest {
final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/AAIResponse4Policy.json");
final Array<?> newArrayFull = (Array<?>) schemaHelper.createNewInstance(inString);
final String vnfName = ((GenericRecord) ((GenericRecord) newArrayFull.get(0)).get("generic_DasH_vnf"))
- .get("vnf_DasH_name").toString();
+ .get("vnf_DasH_name").toString();
assertEquals("ZRDM2MMEX39", vnfName);
}
}
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java
index 8d7041c60..f2dd5b5e3 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaArrayTest.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,13 +21,13 @@
package org.onap.policy.apex.plugins.context.schema.avro;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Array;
-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.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -40,14 +40,12 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.TextFileUtils;
-// TODO: Auto-generated Javadoc
/**
* The Class TestAvroSchemaArray.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaArrayTest {
+class AvroSchemaArrayTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String longArraySchema;
@@ -58,8 +56,8 @@ public class AvroSchemaArrayTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
longArraySchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/ArrayExampleLong.avsc");
@@ -69,8 +67,8 @@ public class AvroSchemaArrayTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +79,8 @@ public class AvroSchemaArrayTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,9 +90,9 @@ public class AvroSchemaArrayTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testArrayInit() throws IOException {
+ void testArrayInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -103,10 +101,10 @@ public class AvroSchemaArrayTest {
assertEquals(0, newArrayEmpty.size());
final String inString =
- TextFileUtils.getTextFileAsString("src/test/resources/data/ArrayExampleAddressFull.json");
+ TextFileUtils.getTextFileAsString("src/test/resources/data/ArrayExampleAddressFull.json");
final Array<?> newArrayFull = (Array<?>) schemaHelper.createNewInstance(inString);
assertEquals("{\"streetaddress\": \"1600 Pennsylvania Avenue\", \"city\": \"Washington DC\"}",
- newArrayFull.get(0).toString());
+ newArrayFull.get(0).toString());
}
/**
@@ -115,9 +113,9 @@ public class AvroSchemaArrayTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testLongArrayUnmarshalMarshal() throws IOException {
+ void testLongArrayUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", longArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", longArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -132,9 +130,9 @@ public class AvroSchemaArrayTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testAddressArrayUnmarshalMarshal() throws IOException {
+ void testAddressArrayUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", addressArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", addressArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -147,7 +145,7 @@ public class AvroSchemaArrayTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java
index d3cd7a482..43d68f223 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaEnumTest.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,13 +23,13 @@
package org.onap.policy.apex.plugins.context.schema.avro;
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.IOException;
import org.apache.avro.generic.GenericData.EnumSymbol;
-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.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -42,14 +42,12 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.TextFileUtils;
-// TODO: Auto-generated Javadoc
/**
* The Class TestAvroSchemaEnum.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaEnumTest {
+class AvroSchemaEnumTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String enumSchema;
@@ -59,8 +57,8 @@ public class AvroSchemaEnumTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
enumSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/EnumSchema.avsc");
@@ -69,8 +67,8 @@ public class AvroSchemaEnumTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +79,8 @@ public class AvroSchemaEnumTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,9 +90,9 @@ public class AvroSchemaEnumTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testEnumInit() throws IOException {
+ void testEnumInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", enumSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", enumSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -112,9 +110,9 @@ public class AvroSchemaEnumTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testEnumUnmarshalMarshal() throws IOException {
+ void testEnumUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", enumSchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", enumSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -135,7 +133,7 @@ public class AvroSchemaEnumTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java
index 93797fba1..ba04226c7 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaFixedTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,14 +23,14 @@
package org.onap.policy.apex.plugins.context.schema.avro;
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.IOException;
import org.apache.avro.generic.GenericData.Fixed;
-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.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -47,9 +47,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
* The Class TestAvroSchemaFixed.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaFixedTest {
+class AvroSchemaFixedTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String fixedSchema;
@@ -59,8 +58,8 @@ public class AvroSchemaFixedTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
fixedSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/FixedSchema.avsc");
@@ -69,8 +68,8 @@ public class AvroSchemaFixedTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +80,8 @@ public class AvroSchemaFixedTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,17 +91,17 @@ public class AvroSchemaFixedTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFixedInit() throws IOException {
+ void testFixedInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", fixedSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", fixedSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
- assertThatThrownBy(() -> schemaHelper.createNewInstance())
+ assertThatThrownBy(schemaHelper::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance "
- + "of class \"org.apache.avro.generic.GenericData$Fixed\" "
- + "using the default constructor \"Fixed()\"");
+ + "of class \"org.apache.avro.generic.GenericData$Fixed\" "
+ + "using the default constructor \"Fixed()\"");
final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/FixedExampleGood.json");
final Fixed newFixedFull = (Fixed) schemaHelper.createNewInstance(inString);
assertTrue(newFixedFull.toString().startsWith("[48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65"));
@@ -115,9 +114,9 @@ public class AvroSchemaFixedTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFixedUnmarshalMarshal() throws IOException {
+ void testFixedUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", fixedSchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", fixedSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -140,7 +139,7 @@ public class AvroSchemaFixedTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java
index 5bbaf97fa..fd9d5b6e5 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperBadSchemasTest.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,9 +23,9 @@ package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-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.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
@@ -40,17 +40,16 @@ import org.onap.policy.common.parameters.ParameterService;
* The Class TestAvroSchemaHelperBadSchemas.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaHelperBadSchemasTest {
+class AvroSchemaHelperBadSchemasTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
/**
* Inits the test.
*/
- @Before
- public void initTest() {
+ @BeforeEach
+ void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
}
@@ -58,20 +57,20 @@ public class AvroSchemaHelperBadSchemasTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
ParameterService.register(schemaParameters);
-
+
}
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -79,7 +78,7 @@ public class AvroSchemaHelperBadSchemasTest {
* Bad schema test.
*/
@Test
- public void badSchemaTest() {
+ void badSchemaTest() {
final AxContextSchema avroBadSchema0 = new AxContextSchema(new AxArtifactKey("AvroBad0", "0.0.1"), "AVRO", "}");
schemas.getSchemasMap().put(avroBadSchema0.getKey(), avroBadSchema0);
@@ -91,25 +90,25 @@ public class AvroSchemaHelperBadSchemasTest {
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema1.getKey()))
.hasMessageStartingWith("AvroTest:0.0.1: avro context schema \"AvroBad1:0.0.1\" schema is invalid");
final AxContextSchema avroBadSchema2 =
- new AxContextSchema(new AxArtifactKey("AvroBad2", "0.0.1"), "AVRO", "{}");
+ new AxContextSchema(new AxArtifactKey("AvroBad2", "0.0.1"), "AVRO", "{}");
schemas.getSchemasMap().put(avroBadSchema2.getKey(), avroBadSchema2);
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema2.getKey()))
.hasMessageStartingWith("AvroTest:0.0.1: avro context schema \"AvroBad2:0.0.1\" schema is invalid");
final AxContextSchema avroBadSchema3 =
- new AxContextSchema(new AxArtifactKey("AvroBad3", "0.0.1"), "AVRO", "{zooby}");
+ new AxContextSchema(new AxArtifactKey("AvroBad3", "0.0.1"), "AVRO", "{zooby}");
schemas.getSchemasMap().put(avroBadSchema3.getKey(), avroBadSchema3);
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema3.getKey()))
.hasMessageStartingWith("AvroTest:0.0.1: avro context schema \"AvroBad3:0.0.1\" schema is invalid");
final AxContextSchema avroBadSchema4 =
- new AxContextSchema(new AxArtifactKey("AvroBad4", "0.0.1"), "AVRO", "{\"zooby\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBad4", "0.0.1"), "AVRO", "{\"zooby\"}");
schemas.getSchemasMap().put(avroBadSchema4.getKey(), avroBadSchema4);
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema4.getKey()))
.hasMessageStartingWith("AvroTest:0.0.1: avro context schema \"AvroBad4:0.0.1\" schema is invalid");
final AxContextSchema avroBadSchema5 =
- new AxContextSchema(new AxArtifactKey("AvroBad5", "0.0.1"), "AVRO", "{\"type\": \"zooby\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBad5", "0.0.1"), "AVRO", "{\"type\": \"zooby\"}");
schemas.getSchemasMap().put(avroBadSchema5.getKey(), avroBadSchema5);
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(testKey, avroBadSchema5.getKey()))
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java
index 06848c9a9..4cb5c9dd3 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperMarshalTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,11 +23,11 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-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.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -43,17 +43,16 @@ import org.onap.policy.common.parameters.ParameterService;
* The Class TestAvroSchemaHelperMarshal.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaHelperMarshalTest {
+class AvroSchemaHelperMarshalTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
/**
* Inits the test.
*/
- @Before
- public void initTest() {
+ @BeforeEach
+ void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
}
@@ -61,8 +60,8 @@ public class AvroSchemaHelperMarshalTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -73,8 +72,8 @@ public class AvroSchemaHelperMarshalTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -82,13 +81,13 @@ public class AvroSchemaHelperMarshalTest {
* Test null marshal.
*/
@Test
- public void testNullMarshal() {
+ void testNullMarshal() {
final AxContextSchema avroNullSchema =
- new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", "{\"type\": \"null\"}");
+ new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", "{\"type\": \"null\"}");
schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema);
final SchemaHelper schemaHelper0 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroNullSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroNullSchema.getKey());
assertEquals("null", schemaHelper0.marshal2String(null));
assertEquals("null", schemaHelper0.marshal2String(123));
@@ -99,13 +98,13 @@ public class AvroSchemaHelperMarshalTest {
* Test boolean marshal.
*/
@Test
- public void testBooleanMarshal() {
+ void testBooleanMarshal() {
final AxContextSchema avroBooleanSchema =
- new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", "{\"type\": \"boolean\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", "{\"type\": \"boolean\"}");
schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema);
final SchemaHelper schemaHelper1 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroBooleanSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroBooleanSchema.getKey());
assertEquals("true", schemaHelper1.marshal2String(true));
assertEquals("false", schemaHelper1.marshal2String(false));
@@ -119,13 +118,13 @@ public class AvroSchemaHelperMarshalTest {
* Test int marshal.
*/
@Test
- public void testIntMarshal() {
+ void testIntMarshal() {
final AxContextSchema avroIntSchema =
- new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", "{\"type\": \"int\"}");
+ new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", "{\"type\": \"int\"}");
schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema);
final SchemaHelper schemaHelper2 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroIntSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroIntSchema.getKey());
assertEquals("0", schemaHelper2.marshal2String(0));
assertEquals("1", schemaHelper2.marshal2String(1));
@@ -144,13 +143,13 @@ public class AvroSchemaHelperMarshalTest {
* Test long marshal.
*/
@Test
- public void testLongMarshal() {
+ void testLongMarshal() {
final AxContextSchema avroLongSchema =
- new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", "{\"type\": \"long\"}");
+ new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", "{\"type\": \"long\"}");
schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema);
final SchemaHelper schemaHelper3 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroLongSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroLongSchema.getKey());
assertEquals("0", schemaHelper3.marshal2String(0L));
assertEquals("1", schemaHelper3.marshal2String(1L));
@@ -167,13 +166,13 @@ public class AvroSchemaHelperMarshalTest {
* Test float marshal.
*/
@Test
- public void testFloatMarshal() {
+ void testFloatMarshal() {
final AxContextSchema avroFloatSchema =
- new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", "{\"type\": \"float\"}");
+ new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", "{\"type\": \"float\"}");
schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema);
final SchemaHelper schemaHelper4 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroFloatSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroFloatSchema.getKey());
assertEquals("0.0", schemaHelper4.marshal2String(0F));
assertEquals("1.0", schemaHelper4.marshal2String(1F));
@@ -194,13 +193,13 @@ public class AvroSchemaHelperMarshalTest {
* Test double marshal.
*/
@Test
- public void testDoubleMarshal() {
+ void testDoubleMarshal() {
final AxContextSchema avroDoubleSchema =
- new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", "{\"type\": \"double\"}");
+ new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", "{\"type\": \"double\"}");
schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema);
final SchemaHelper schemaHelper5 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroDoubleSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroDoubleSchema.getKey());
assertEquals("0.0", schemaHelper5.marshal2String(0D));
assertEquals("1.0", schemaHelper5.marshal2String(1D));
@@ -221,13 +220,13 @@ public class AvroSchemaHelperMarshalTest {
* Test string marshal.
*/
@Test
- public void testStringMarshal() {
+ void testStringMarshal() {
final AxContextSchema avroStringSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"string\"}");
+ new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"string\"}");
schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema);
final SchemaHelper schemaHelper7 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroStringSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, avroStringSchema.getKey());
assertEquals("\"0\"", schemaHelper7.marshal2String("0"));
assertEquals("\"1\"", schemaHelper7.marshal2String("1"));
@@ -247,9 +246,9 @@ public class AvroSchemaHelperMarshalTest {
* Test bytes marshal.
*/
@Test
- public void testBytesMarshal() {
+ void testBytesMarshal() {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"bytes\"}");
+ new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"bytes\"}");
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java
index 23ac9a855..7dd1e1aca 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelperUnmarshalTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,12 +23,12 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.avro.util.Utf8;
-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.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -44,17 +44,16 @@ import org.onap.policy.common.parameters.ParameterService;
* The Class TestAvroSchemaHelperUnmarshal.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaHelperUnmarshalTest {
+class AvroSchemaHelperUnmarshalTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
/**
* Inits the test.
*/
- @Before
- public void initTest() {
+ @BeforeEach
+ void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
}
@@ -62,8 +61,8 @@ public class AvroSchemaHelperUnmarshalTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -74,8 +73,8 @@ public class AvroSchemaHelperUnmarshalTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -83,13 +82,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test null unmarshal.
*/
@Test
- public void testNullUnmarshal() {
+ void testNullUnmarshal() {
final AxContextSchema avroNullSchema = new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO",
- "{\"type\": \"null\"}");
+ "{\"type\": \"null\"}");
schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema);
final SchemaHelper schemaHelper0 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroNullSchema.getKey());
+ avroNullSchema.getKey());
assertThatThrownBy(schemaHelper0::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance, schema class for the schema is null");
@@ -103,13 +102,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test boolean unmarshal.
*/
@Test
- public void testBooleanUnmarshal() {
+ void testBooleanUnmarshal() {
final AxContextSchema avroBooleanSchema = new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO",
- "{\"type\": \"boolean\"}");
+ "{\"type\": \"boolean\"}");
schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema);
final SchemaHelper schemaHelper1 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroBooleanSchema.getKey());
+ avroBooleanSchema.getKey());
assertThatThrownBy(schemaHelper1::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" "
@@ -128,13 +127,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test int unmarshal.
*/
@Test
- public void testIntUnmarshal() {
+ void testIntUnmarshal() {
final AxContextSchema avroIntSchema = new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO",
- "{\"type\": \"int\"}");
+ "{\"type\": \"int\"}");
schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema);
final SchemaHelper schemaHelper2 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroIntSchema.getKey());
+ avroIntSchema.getKey());
assertThatThrownBy(schemaHelper2::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Integer\" "
@@ -160,13 +159,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test long unmarshal.
*/
@Test
- public void testLongUnmarshal() {
+ void testLongUnmarshal() {
final AxContextSchema avroLongSchema = new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO",
- "{\"type\": \"long\"}");
+ "{\"type\": \"long\"}");
schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema);
final SchemaHelper schemaHelper3 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroLongSchema.getKey());
+ avroLongSchema.getKey());
assertThatThrownBy(schemaHelper3::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" "
@@ -194,13 +193,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test float unmarshal.
*/
@Test
- public void testFloatUnmarshal() {
+ void testFloatUnmarshal() {
final AxContextSchema avroFloatSchema = new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO",
- "{\"type\": \"float\"}");
+ "{\"type\": \"float\"}");
schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema);
final SchemaHelper schemaHelper4 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroFloatSchema.getKey());
+ avroFloatSchema.getKey());
assertThatThrownBy(schemaHelper4::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Float\" "
@@ -226,13 +225,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test double unmarshal.
*/
@Test
- public void testDoubleUnmarshal() {
+ void testDoubleUnmarshal() {
final AxContextSchema avroDoubleSchema = new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO",
- "{\"type\": \"double\"}");
+ "{\"type\": \"double\"}");
schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema);
final SchemaHelper schemaHelper5 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroDoubleSchema.getKey());
+ avroDoubleSchema.getKey());
assertThatThrownBy(schemaHelper5::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Double\" "
@@ -258,13 +257,13 @@ public class AvroSchemaHelperUnmarshalTest {
* Test string unmarshal.
*/
@Test
- public void testStringUnmarshal() {
+ void testStringUnmarshal() {
final AxContextSchema avroStringSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO",
- "{\"type\": \"string\"}");
+ "{\"type\": \"string\"}");
schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema);
final SchemaHelper schemaHelper7 = new SchemaHelperFactory().createSchemaHelper(testKey,
- avroStringSchema.getKey());
+ avroStringSchema.getKey());
assertEquals("", schemaHelper7.createNewInstance(""));
assertEquals("1.2345E06", schemaHelper7.createNewInstance("1.2345E06"));
@@ -288,9 +287,9 @@ public class AvroSchemaHelperUnmarshalTest {
* Test bytes unmarshal.
*/
@Test
- public void testBytesUnmarshal() {
+ void testBytesUnmarshal() {
final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO",
- "{\"type\": \"bytes\"}");
+ "{\"type\": \"bytes\"}");
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java
index a3e85ed91..2411b0bb2 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaMapTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2023-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,18 +22,19 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.util.Utf8;
-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.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
@@ -51,9 +52,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
* The Class TestAvroSchemaMap.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaMapTest {
+class AvroSchemaMapTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String longMapSchema;
@@ -65,21 +65,21 @@ public class AvroSchemaMapTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
longMapSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleLong.avsc");
addressMapSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddress.avsc");
addressMapSchemaInvalidFields =
- TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddressInvalidFields.avsc");
+ TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddressInvalidFields.avsc");
}
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -89,8 +89,8 @@ public class AvroSchemaMapTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -100,15 +100,15 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testValidSubstitutions() throws IOException {
+ void testValidSubstitutions() throws IOException {
final String subst1 = "{\"type\":\"record\",\"name\":\"Subst1\","
- + "\"fields\":[{\"name\": \"A_DasH_B\",\"type\":\"string\"}]}";
+ + "\"fields\":[{\"name\": \"A_DasH_B\",\"type\":\"string\"}]}";
final AxContextSchema avroSubstSchema1 = new AxContextSchema(
- new AxArtifactKey("AvroSubst1", "0.0.1"), "AVRO", subst1);
+ new AxArtifactKey("AvroSubst1", "0.0.1"), "AVRO", subst1);
schemas.getSchemasMap().put(avroSubstSchema1.getKey(), avroSubstSchema1);
SchemaHelper schemaHelperSubst1 = new SchemaHelperFactory()
- .createSchemaHelper(testKey, avroSubstSchema1.getKey());
+ .createSchemaHelper(testKey, avroSubstSchema1.getKey());
final GenericRecord subst1A = (GenericRecord) schemaHelperSubst1.unmarshal("{\"A-B\":\"foo\"}");
assertEquals(new Utf8("foo"), subst1A.get("A_DasH_B"));
assertThatThrownBy(() -> subst1A.get("A-B")).hasMessage("Not a valid schema field: A-B");
@@ -119,13 +119,13 @@ public class AvroSchemaMapTest {
assertEquals("Expected string. Got VALUE_NUMBER_INT", exception1.getCause().getMessage());
final String subst2 = "{\"type\":\"record\",\"name\":\"Subst2\","
- + "\"fields\":[{\"name\": \"C_DoT_D\",\"type\":\"int\"}]}";
+ + "\"fields\":[{\"name\": \"C_DoT_D\",\"type\":\"int\"}]}";
final AxContextSchema avroSubstSchema2 = new AxContextSchema(
- new AxArtifactKey("AvroSubst2", "0.0.1"), "AVRO", subst2);
+ new AxArtifactKey("AvroSubst2", "0.0.1"), "AVRO", subst2);
schemas.getSchemasMap().put(avroSubstSchema2.getKey(), avroSubstSchema2);
final SchemaHelper schemaHelperSubst2 = new SchemaHelperFactory()
- .createSchemaHelper(testKey, avroSubstSchema2.getKey());
+ .createSchemaHelper(testKey, avroSubstSchema2.getKey());
final GenericRecord subst2A = (GenericRecord) schemaHelperSubst2.unmarshal("{\"C.D\":123}");
assertEquals(123, subst2A.get("C_DoT_D"));
assertThatThrownBy(() -> subst2A.get("C.D")).hasMessage("Not a valid schema field: C.D");
@@ -136,13 +136,13 @@ public class AvroSchemaMapTest {
assertEquals("Expected int. Got VALUE_STRING", exception2.getCause().getMessage());
final String subst3 = "{\"type\":\"record\",\"name\":\"Subst3\","
- + "\"fields\":[{\"name\": \"E_ColoN_F\",\"type\":\"boolean\"}]}";
+ + "\"fields\":[{\"name\": \"E_ColoN_F\",\"type\":\"boolean\"}]}";
final AxContextSchema avroSubstSchema3 = new AxContextSchema(
- new AxArtifactKey("AvroSubst3", "0.0.1"), "AVRO", subst3);
+ new AxArtifactKey("AvroSubst3", "0.0.1"), "AVRO", subst3);
schemas.getSchemasMap().put(avroSubstSchema3.getKey(), avroSubstSchema3);
final SchemaHelper schemaHelperSubst3 = new SchemaHelperFactory()
- .createSchemaHelper(testKey, avroSubstSchema3.getKey());
+ .createSchemaHelper(testKey, avroSubstSchema3.getKey());
final GenericRecord subst3A = (GenericRecord) schemaHelperSubst3.unmarshal("{\"E:F\":true}");
assertEquals(true, subst3A.get("E_ColoN_F"));
assertThatThrownBy(() -> subst3A.get("E:F")).hasMessage("Not a valid schema field: E:F");
@@ -159,11 +159,11 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testInValidSubstitutions() throws IOException {
+ void testInValidSubstitutions() throws IOException {
final String fail1 = "{\"type\":\"record\",\"name\":\"Fail1\","
- + "\"fields\":[{\"name\": \"A-B\",\"type\":\"string\"}]}";
+ + "\"fields\":[{\"name\": \"A-B\",\"type\":\"string\"}]}";
final AxContextSchema avroFailSchema1 = new AxContextSchema(
- new AxArtifactKey("AvroFail1", "0.0.1"), "AVRO", fail1);
+ new AxArtifactKey("AvroFail1", "0.0.1"), "AVRO", fail1);
schemas.getSchemasMap().put(avroFailSchema1.getKey(), avroFailSchema1);
SchemaHelperFactory sh = new SchemaHelperFactory();
@@ -174,9 +174,9 @@ public class AvroSchemaMapTest {
assertEquals("Illegal character in: A-B", exception1.getCause().getMessage());
final String fail2 = "{\"type\":\"record\",\"name\":\"Fail2\","
- + "\"fields\":[{\"name\": \"C.D\",\"type\":\"int\"}]}";
+ + "\"fields\":[{\"name\": \"C.D\",\"type\":\"int\"}]}";
final AxContextSchema avroFailSchema2 = new AxContextSchema(
- new AxArtifactKey("AvroFail2", "0.0.1"), "AVRO", fail2);
+ new AxArtifactKey("AvroFail2", "0.0.1"), "AVRO", fail2);
schemas.getSchemasMap().put(avroFailSchema2.getKey(), avroFailSchema2);
AxArtifactKey ak2 = avroFailSchema2.getKey();
@@ -186,9 +186,9 @@ public class AvroSchemaMapTest {
assertEquals("Illegal character in: C.D", exception2.getCause().getMessage());
final String fail3 = "{\"type\":\"record\",\"name\":\"Fail3\","
- + "\"fields\":[{\"name\": \"E:F\",\"type\":\"boolean\"}]}";
+ + "\"fields\":[{\"name\": \"E:F\",\"type\":\"boolean\"}]}";
final AxContextSchema avroFailSchema3 = new AxContextSchema(
- new AxArtifactKey("AvroFail3", "0.0.1"), "AVRO", fail3);
+ new AxArtifactKey("AvroFail3", "0.0.1"), "AVRO", fail3);
schemas.getSchemasMap().put(avroFailSchema3.getKey(), avroFailSchema3);
AxArtifactKey ak3 = avroFailSchema3.getKey();
final Throwable exception3 = assertThrows(ContextRuntimeException.class,
@@ -203,9 +203,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testMapInit() throws IOException {
+ void testMapInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -217,7 +217,7 @@ public class AvroSchemaMapTest {
final HashMap<?, ?> newMapFull = (HashMap<?, ?>) schemaHelper.createNewInstance(inString);
assertEquals("{\"streetaddress\": \"221 B Baker St.\", \"city\": \"London\"}",
- newMapFull.get(new Utf8("address2")).toString());
+ newMapFull.get(new Utf8("address2")).toString());
}
/**
@@ -226,9 +226,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testLongMapUnmarshalMarshal() throws IOException {
+ void testLongMapUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", longMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", longMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -243,9 +243,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testAddressMapUnmarshalMarshal() throws IOException {
+ void testAddressMapUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -260,9 +260,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testSubRecordCreateRecord() throws IOException {
+ void testSubRecordCreateRecord() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -278,9 +278,9 @@ public class AvroSchemaMapTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testAddressMapUnmarshalMarshalInvalidFields() throws IOException {
+ void testAddressMapUnmarshalMarshalInvalidFields() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchemaInvalidFields);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchemaInvalidFields);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -290,7 +290,7 @@ public class AvroSchemaMapTest {
String vals = TextFileUtils.getTextFileAsString("src/test/resources/data/MapExampleAddressInvalidFields.json");
final HashMap<?, ?> newMapFull = (HashMap<?, ?>) schemaHelper.createNewInstance(vals);
final String expect = "{\"street_DasH_address\": \"Wayne Manor\", \"the_DoT_city\": \"Gotham City\", "
- + "\"the_ColoN_code\": \"BatCave7\"}";
+ + "\"the_ColoN_code\": \"BatCave7\"}";
assertEquals(expect, newMapFull.get(new Utf8("address_DoT_3")).toString());
}
@@ -298,7 +298,7 @@ public class AvroSchemaMapTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
@@ -311,7 +311,7 @@ public class AvroSchemaMapTest {
TextFileUtils.putStringAsFile(outString, tempOutFile);
final String decodeEncodeInString = TextFileUtils.getTextFileAsString(fileName);
- tempOutFile.delete();
+ assertTrue(tempOutFile.delete());
final HashMap<?, ?> secondDecodedMap = (HashMap<?, ?>) schemaHelper.unmarshal(decodeEncodeInString);
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
index 3a81584f0..a2a8bdd61 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023-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,14 +22,15 @@
package org.onap.policy.apex.plugins.context.schema.avro;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-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.assertNull;
import java.io.IOException;
import org.apache.avro.generic.GenericRecord;
-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.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -46,9 +47,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
* The Class TestAvroSchemaRecord.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class AvroSchemaRecordTest {
+class AvroSchemaRecordTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String recordSchema;
@@ -61,22 +61,22 @@ public class AvroSchemaRecordTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
recordSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExample.avsc");
recordSchemaVpn = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPN.avsc");
recordSchemaVpnReuse = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPNReuse.avsc");
recordSchemaInvalidFields =
- TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleInvalidFields.avsc");
+ TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleInvalidFields.avsc");
}
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -87,8 +87,8 @@ public class AvroSchemaRecordTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -98,15 +98,15 @@ public class AvroSchemaRecordTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRecordInit() throws IOException {
+ void testRecordInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
final GenericRecord newRecordEmpty = (GenericRecord) schemaHelper.createNewInstance();
- assertEquals(null, newRecordEmpty.get("passwordHash"));
+ assertNull(newRecordEmpty.get("passwordHash"));
final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/RecordExampleFull.json");
final GenericRecord newRecordFull = (GenericRecord) schemaHelper.createNewInstance(inString);
@@ -119,9 +119,9 @@ public class AvroSchemaRecordTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRecordUnmarshalMarshal() throws IOException {
+ void testRecordUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -133,12 +133,11 @@ public class AvroSchemaRecordTest {
/**
* Test record create.
*
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRecordCreateRecord() throws IOException {
+ void testRecordCreateRecord() {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -159,9 +158,9 @@ public class AvroSchemaRecordTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRecordUnmarshalMarshalInvalid() throws IOException {
+ void testRecordUnmarshalMarshalInvalid() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaInvalidFields);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaInvalidFields);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -175,9 +174,9 @@ public class AvroSchemaRecordTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testVpnRecordUnmarshalMarshal() throws IOException {
+ void testVpnRecordUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpn);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpn);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -188,12 +187,11 @@ public class AvroSchemaRecordTest {
/**
* Test VPN record reuse.
*
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testVpnRecordReuse() throws IOException {
+ void testVpnRecordReuse() {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpnReuse);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVpnReuse);
assertNotNull(avroSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
@@ -205,7 +203,7 @@ public class AvroSchemaRecordTest {
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
+ * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java
index 4691927eb..390381e1b 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/HealthCheckSchemaTest.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,16 +21,16 @@
package org.onap.policy.apex.plugins.context.schema.avro;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericData.Record;
import org.apache.avro.generic.GenericRecord;
-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.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -48,7 +48,7 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class HealthCheckSchemaTest {
+class HealthCheckSchemaTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
private String healthCheckSchema;
@@ -58,8 +58,8 @@ public class HealthCheckSchemaTest {
*
* @throws IOException Signals that an I/O exception has occurred.
*/
- @Before
- public void initTest() throws IOException {
+ @BeforeEach
+ void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
@@ -69,8 +69,8 @@ public class HealthCheckSchemaTest {
/**
* Inits the context.
*/
- @Before
- public void initContext() {
+ @BeforeEach
+ void initContext() {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
@@ -81,8 +81,8 @@ public class HealthCheckSchemaTest {
/**
* Clear context.
*/
- @After
- public void clearContext() {
+ @AfterEach
+ void clearContext() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@@ -92,14 +92,14 @@ public class HealthCheckSchemaTest {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testHealthCheck() throws IOException {
+ void testHealthCheck() throws IOException {
final AxContextSchema avroSchema =
new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", healthCheckSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
- testUnmarshalMarshal(schemaHelper, "src/test/resources/data/HealthCheckEvent.json");
+ testUnmarshalMarshal(schemaHelper);
final GenericRecord healthCheckRecord = (Record) schemaHelper.createNewInstance();
final Schema healthCheckRecordSchema = healthCheckRecord.getSchema();
@@ -107,7 +107,7 @@ public class HealthCheckSchemaTest {
final GenericRecord inputRecord = new GenericData.Record(healthCheckRecordSchema.getField("input").schema());
final Schema inputRecordRecordSchema = inputRecord.getSchema();
- final GenericRecord actionIndentifiersRecord =
+ final GenericRecord actionIdentifiersRecord =
new GenericData.Record(inputRecordRecordSchema.getField("action_DasH_identifiers").schema());
final GenericRecord commonHeaderRecord =
@@ -118,7 +118,7 @@ public class HealthCheckSchemaTest {
new GenericData.Record(commonHeaderRecordSchema.getField("flags").schema());
healthCheckRecord.put("input", inputRecord);
- inputRecord.put("action_DasH_identifiers", actionIndentifiersRecord);
+ inputRecord.put("action_DasH_identifiers", actionIdentifiersRecord);
inputRecord.put("common_DasH_header", commonHeaderRecord);
commonHeaderRecord.put("flags", commonHeaderFlagsRecord);
@@ -126,7 +126,7 @@ public class HealthCheckSchemaTest {
inputRecord.put("payload", "{\"host-ip-address\":\"131.160.203.125\",\"input.url\":\"131.160.203.125/afr\","
+ "\"request-action-type\":\"GET\",\"request-action\":\"AFR\"}");
- actionIndentifiersRecord.put("vnf_DasH_id", "49414df5-3482-4fd8-9952-c463dff2770b");
+ actionIdentifiersRecord.put("vnf_DasH_id", "49414df5-3482-4fd8-9952-c463dff2770b");
commonHeaderRecord.put("request_DasH_id", "afr-request3");
commonHeaderRecord.put("originator_DasH_id", "AFR");
@@ -140,18 +140,17 @@ public class HealthCheckSchemaTest {
final String eventString = TextFileUtils.getTextFileAsString("src/test/resources/data/HealthCheckEvent.json");
final String outString = schemaHelper.marshal2String(healthCheckRecord);
- assertEquals(eventString.toString().replaceAll("\\s+", ""), outString.replaceAll("\\s+", ""));
+ assertEquals(eventString.replaceAll("\\s+", ""), outString.replaceAll("\\s+", ""));
}
/**
* Test unmarshal marshal.
*
* @param schemaHelper the schema helper
- * @param fileName the file name
* @throws IOException Signals that an I/O exception has occurred.
*/
- private void testUnmarshalMarshal(final SchemaHelper schemaHelper, final String fileName) throws IOException {
- final String inString = TextFileUtils.getTextFileAsString(fileName);
+ private void testUnmarshalMarshal(final SchemaHelper schemaHelper) throws IOException {
+ final String inString = TextFileUtils.getTextFileAsString("src/test/resources/data/HealthCheckEvent.json");
final GenericRecord decodedObject = (GenericRecord) schemaHelper.unmarshal(inString);
final String outString = schemaHelper.marshal2String(decodedObject);
assertEquals(inString.replaceAll("\\s+", ""), outString.replaceAll("\\s+", ""));
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java
index ce03678c9..7a7daa2bd 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/CommonTestData.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada. 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.
@@ -21,9 +22,9 @@
package org.onap.policy.apex.plugins.context.schema.json;
import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -62,7 +63,7 @@ public class CommonTestData {
/**
* Setup before all tests.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws IOException {
COMMONHEADERTYPE_DRAFT04 =
TextFileUtils.getTextFileAsString("src/test/resources/schema/commonHeaderType_draft04.json");
@@ -81,7 +82,7 @@ public class CommonTestData {
/**
* Setup before test.
*/
- @Before
+ @BeforeEach
public void setUp() {
schemas = new AxContextSchemas(new AxArtifactKey("JsonSchema", VERSION));
ModelService.registerModel(AxContextSchemas.class, schemas);
@@ -95,7 +96,7 @@ public class CommonTestData {
/**
* Teardown after test.
*/
- @After
+ @AfterEach
public void tearDown() {
ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
ModelService.clear();
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
index 15458199a..b129330ce 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperMarshalTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada. 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.
@@ -28,16 +29,16 @@ import com.google.gson.JsonObject;
import com.worldturner.medeia.api.ValidationFailedException;
import java.util.ArrayList;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
-public class JsonSchemaHelperMarshalTest extends CommonTestData {
+class JsonSchemaHelperMarshalTest extends CommonTestData {
/**
* Test Boolean.
*/
@Test
- public void testBooleanMarshal() {
+ void testBooleanMarshal() {
var schemaHelper = createSchema(BOOLEAN_SCHEMA);
assertThat(schemaHelper.marshal2String(Boolean.TRUE)).isEqualTo("true");
}
@@ -46,7 +47,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* Test null.
*/
@Test
- public void testNullMarshal() {
+ void testNullMarshal() {
var schemaHelper = createSchema(NULL_SCHEMA);
assertThat(schemaHelper.marshal2String(null)).isEqualTo("null");
}
@@ -57,7 +58,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coder exception
*/
@Test
- public void testArrayMarshal() throws CoderException {
+ void testArrayMarshal() throws CoderException {
var schemaHelper = createSchema(MEASUREMENTGROUPS_TYPE);
var object = coder.decode(MEASUREMENTGROUPS, Object.class);
assertThat(object).isInstanceOf(ArrayList.class);
@@ -73,7 +74,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft04_valid() throws CoderException {
+ void testObjectSchemaDraft04_valid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataReturned = validateAndMarshal(COMMONHEADERTYPE_DRAFT04, dataAsObject, true);
assertThat(dataReturned).isEqualTo(COMMONHEADER);
@@ -85,7 +86,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft07_valid() throws CoderException {
+ void testObjectSchemaDraft07_valid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataReturned = validateAndMarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject, true);
assertThat(dataReturned).isEqualTo(COMMONHEADER);
@@ -98,7 +99,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchema_fieldMissing() throws CoderException {
+ void testObjectSchema_fieldMissing() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
dataAsObject.remove(TEST_ID);
assertThatThrownBy(() -> validateAndMarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject, true))
@@ -112,7 +113,7 @@ public class JsonSchemaHelperMarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchema_OptionalField() throws CoderException {
+ void testObjectSchema_OptionalField() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataAsjsonObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.remove(TEST_ID);
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
index 11c8638de..d0059f26f 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-json/src/test/java/org/onap/policy/apex/plugins/context/schema/json/JsonSchemaHelperUnmarshalTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada. 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.
@@ -27,19 +28,19 @@ import com.google.gson.JsonObject;
import com.worldturner.medeia.api.ValidationFailedException;
import java.util.ArrayList;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.common.utils.coder.CoderException;
-public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
+class JsonSchemaHelperUnmarshalTest extends CommonTestData {
/**
* Test Boolean.
*/
@Test
- public void testBooleanUnmarshal() {
+ void testBooleanUnmarshal() {
var schemaHelper = createSchema(BOOLEAN_SCHEMA);
assertThat(schemaHelper.createNewInstance(BOOLEAN_DATA)).isInstanceOf(Boolean.class).isEqualTo(Boolean.TRUE);
}
@@ -48,30 +49,31 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* Test null.
*/
@Test
- public void testNullUnmarshal() {
+ void testNullUnmarshal() {
var schemaHelper = createSchema(NULL_SCHEMA);
- assertThat(schemaHelper.createNewInstance(NULL_DATA)).isEqualTo(null);
+ assertThat(schemaHelper.createNewInstance(NULL_DATA)).isNull();
}
/**
* Test Array.
*/
@Test
- public void testArrayUnmarshal() {
+ void testArrayUnmarshal() {
var schemaHelper = createSchema(MEASUREMENTGROUPS_TYPE);
var obj = schemaHelper.createNewInstance(MEASUREMENTGROUPS);
assertThat(obj).isInstanceOf(ArrayList.class);
}
/**
- * Test invlaid schema.
+ * Test invalid schema.
*/
@Test
- public void testSchemaInvalid() {
+ void testSchemaInvalid() {
String schemaDef = "{\"type\": \"object\"}";
final AxContextSchema jsonSchema =
new AxContextSchema(new AxArtifactKey("JsonObject", VERSION), JSON, schemaDef);
- assertThatThrownBy(() -> new JsonSchemaHelper().init(testKey, jsonSchema))
+ var jsonSchemaHelper = new JsonSchemaHelper();
+ assertThatThrownBy(() -> jsonSchemaHelper.init(testKey, jsonSchema))
.isInstanceOf(ContextRuntimeException.class).hasMessageContaining("schema is invalid");
}
@@ -81,7 +83,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft04_valid() throws CoderException {
+ void testObjectSchemaDraft04_valid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataReturned = validateAndUnmarshal(COMMONHEADERTYPE_DRAFT04, COMMONHEADER);
assertThat(dataReturned).isEqualTo(dataAsObject);
@@ -93,7 +95,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft07_valid() throws CoderException {
+ void testObjectSchemaDraft07_valid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataReturned = validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, COMMONHEADER);
assertThat(dataReturned).isEqualTo(dataAsObject);
@@ -105,7 +107,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchemaDraft07_invalid() throws CoderException {
+ void testObjectSchemaDraft07_invalid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.addProperty("requestId", "abcd");
assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject))
@@ -119,7 +121,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testCreateNewInstanceInvalid() throws CoderException {
+ void testCreateNewInstanceInvalid() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject))
.isInstanceOf(ContextRuntimeException.class).hasMessageContaining("not an instance of JsonObject");
@@ -131,7 +133,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchema_fieldMissing() throws CoderException {
+ void testObjectSchema_fieldMissing() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.remove(TEST_ID);
assertThatThrownBy(() -> validateAndUnmarshal(COMMONHEADERTYPE_DRAFT07, dataAsObject))
@@ -145,7 +147,7 @@ public class JsonSchemaHelperUnmarshalTest extends CommonTestData {
* @throws CoderException the coderException
*/
@Test
- public void testObjectSchema_OptionalField() throws CoderException {
+ void testObjectSchema_OptionalField() throws CoderException {
var dataAsObject = coder.decode(COMMONHEADER, Map.class);
var dataAsjsonObject = coder.decode(COMMONHEADER, JsonObject.class);
dataAsObject.remove(TEST_ID);