aboutsummaryrefslogtreecommitdiffstats
path: root/context/context-management
diff options
context:
space:
mode:
Diffstat (limited to 'context/context-management')
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java50
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java31
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java185
3 files changed, 72 insertions, 194 deletions
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
index 7bf836c3c..663424411 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 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,14 +21,12 @@
package org.onap.policy.apex.context.impl.schema;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.apex.context.ContextRuntimeException;
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;
@@ -61,38 +60,19 @@ public class SchemaHelperFactoryTest {
@Test
public void testSchemaHelperFactory() {
- try {
- new SchemaHelperFactory().createSchemaHelper(null, null);
- fail("this test should throw an exception");
- } catch (IllegalArgumentException e) {
- assertEquals("Parameter \"owningEntityKey\" may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(null, null))
+ .hasMessage("Parameter \"owningEntityKey\" may not be null");
AxArtifactKey ownerKey = new AxArtifactKey("Owner", "0.0.1");
- try {
- new SchemaHelperFactory().createSchemaHelper(ownerKey, null);
- fail("this test should throw an exception");
- } catch (IllegalArgumentException e) {
- assertEquals("Parameter \"schemaKey\" may not be null", e.getMessage());
- }
-
- try {
- new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey());
- fail("this test should throw an exception");
- } catch (ContextRuntimeException e) {
- assertEquals("schema \"IntSchema:0.0.1\" for entity Owner:0.0.1 does not exist", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(ownerKey, null))
+ .hasMessage("Parameter \"schemaKey\" may not be null");
+ assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey()))
+ .hasMessage("schema \"IntSchema:0.0.1\" for entity Owner:0.0.1 does not exist");
schemas.getSchemasMap().put(intSchema.getKey(), intSchema);
SchemaParameters schemaParameters0 = new SchemaParameters();
schemaParameters0.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
ParameterService.register(schemaParameters0);
- try {
- new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey());
- fail("this test should throw an exception");
- } catch (ContextRuntimeException e) {
- assertEquals("context schema helper parameters not found for context schema \"JAVA\"", e.getMessage());
- }
+ assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey()))
+ .hasMessage("context schema helper parameters not found for context schema \"JAVA\"");
ParameterService.deregister(schemaParameters0);
SchemaParameters schemaParameters1 = new SchemaParameters();
@@ -102,12 +82,8 @@ public class SchemaHelperFactoryTest {
assertNotNull(new SchemaHelperFactory().createSchemaHelper(ownerKey, intSchema.getKey()));
schemas.getSchemasMap().put(intSchema.getKey(), badSchema);
- try {
- new SchemaHelperFactory().createSchemaHelper(ownerKey, badSchema.getKey());
- fail("this test should throw an exception");
- } catch (ContextRuntimeException e) {
- assertEquals("Owner:0.0.1: class/type java.lang.Bad for context schema \"IntSchema:0.0.1\" "
- + "not found. Check the class path of the JVM", e.getMessage());
- }
+ assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(ownerKey, badSchema.getKey()))
+ .hasMessage("Owner:0.0.1: class/type java.lang.Bad for context schema \"IntSchema:0.0.1\" "
+ + "not found. Check the class path of the JVM");
}
}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
index 14d44ee8b..620a78152 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 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,8 +21,8 @@
package org.onap.policy.apex.context.impl.schema.java;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import org.junit.AfterClass;
import org.junit.Before;
@@ -87,32 +88,20 @@ public class JavaSchemaHelperInstanceCreationTest {
final SchemaHelper schemaHelper2 =
new SchemaHelperFactory().createSchemaHelper(testKey, javaStringSchema.getKey());
- try {
- schemaHelper0.createNewInstance();
- fail("this test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" using the default"
- + " constructor \"Boolean()\"", e.getMessage());
- }
+ assertThatThrownBy(schemaHelper0::createNewInstance)
+ .hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\""
+ + " using the default constructor \"Boolean()\"");
assertEquals(true, schemaHelper0.createNewInstance("true"));
- try {
- schemaHelper1.createNewInstance();
- fail("this test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" using the default "
- + "constructor \"Long()\"", e.getMessage());
- }
+ assertThatThrownBy(schemaHelper1::createNewInstance)
+ .hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\""
+ + " using the default constructor \"Long()\"");
assertEquals(65536L, schemaHelper1.createNewInstance("65536"));
assertEquals("", schemaHelper2.createNewInstance());
assertEquals("true", schemaHelper2.createNewInstance("true"));
- try {
- schemaHelper1.createNewSubInstance("SomeSubtype");
- fail("this test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("sub types are not supported on this schema helper", e.getMessage());
- }
+ assertThatThrownBy(() -> schemaHelper1.createNewSubInstance("SomeSubtype"))
+ .hasMessage("sub types are not supported on this schema helper");
}
}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
index d9304d142..d06ac7469 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.context.impl.schema.java;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
@@ -32,7 +32,6 @@ import java.time.Instant;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
@@ -72,24 +71,15 @@ public class JavaSchemaHelperTest {
AxContextSchema badJavaTypeSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Rubbish");
- try {
- new JavaSchemaHelper().init(userKey, badJavaTypeSchema);
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: class/type java.lang.Rubbish for context schema"
- + " \"SchemaKey:0.0.1\" not found. Check the class path of the JVM", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new JavaSchemaHelper().init(userKey, badJavaTypeSchema))
+ .hasMessage("UserKey:0.0.1: class/type java.lang.Rubbish for context schema"
+ + " \"SchemaKey:0.0.1\" not found. Check the class path of the JVM");
AxContextSchema builtInJavaTypeSchema = new AxContextSchema(schemaKey, "Java", "short");
- try {
- new JavaSchemaHelper().init(userKey, builtInJavaTypeSchema);
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: class/type short for context schema "
+ assertThatThrownBy(() -> new JavaSchemaHelper().init(userKey, builtInJavaTypeSchema))
+ .hasMessage("UserKey:0.0.1: class/type short for context schema "
+ "\"SchemaKey:0.0.1\" not found. Primitive types are not supported."
- + " Use the appropriate Java boxing type instead.", e.getMessage());
- }
+ + " Use the appropriate Java boxing type instead.");
}
@Test
@@ -101,30 +91,12 @@ public class JavaSchemaHelperTest {
assertEquals(null, intSchemaHelper.getSchemaClass());
assertEquals(null, intSchemaHelper.getSchemaObject());
- try {
- intSchemaHelper.createNewInstance();
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
- }
-
- try {
- intSchemaHelper.createNewInstance(Float.parseFloat("1.23"));
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
- }
-
- try {
- intSchemaHelper.createNewInstance("hello");
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
- }
-
+ assertThatThrownBy(intSchemaHelper::createNewInstance)
+ .hasMessage("NULL:0.0.0: could not create an instance, schema class for the schema is null");
+ assertThatThrownBy(() -> intSchemaHelper.createNewInstance(Float.parseFloat("1.23")))
+ .hasMessage("NULL:0.0.0: could not create an instance, schema class for the schema is null");
+ assertThatThrownBy(() -> intSchemaHelper.createNewInstance("hello"))
+ .hasMessage("NULL:0.0.0: could not create an instance, schema class for the schema is null");
AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
AxContextSchema intSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Integer");
@@ -135,31 +107,16 @@ public class JavaSchemaHelperTest {
assertEquals(Integer.class, intSchemaHelper.getSchemaClass());
assertEquals(null, intSchemaHelper.getSchemaObject());
- try {
- intSchemaHelper.createNewInstance();
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: could not create an instance of class "
- + "\"java.lang.Integer\" using the default constructor \"Integer()\"", e.getMessage());
- }
-
- try {
- intSchemaHelper.createNewInstance(Float.parseFloat("1.23"));
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: the object \"1.23\" of type "
+ assertThatThrownBy(intSchemaHelper::createNewInstance)
+ .hasMessage("UserKey:0.0.1: could not create an instance of class "
+ + "\"java.lang.Integer\" using the default constructor \"Integer()\"");
+ assertThatThrownBy(() -> intSchemaHelper.createNewInstance(Float.parseFloat("1.23")))
+ .hasMessage("UserKey:0.0.1: the object \"1.23\" of type "
+ "\"java.lang.Float\" is not an instance of JsonObject and is not "
- + "assignable to \"java.lang.Integer\"", e.getMessage());
- }
-
- try {
- intSchemaHelper.createNewInstance("hello");
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: could not create an instance of class \"java.lang.Integer\" "
- + "using the string constructor \"Integer(String)\"", e.getMessage());
- }
-
+ + "assignable to \"java.lang.Integer\"");
+ assertThatThrownBy(() -> intSchemaHelper.createNewInstance("hello"))
+ .hasMessage("UserKey:0.0.1: could not create an instance of class \"java.lang.Integer\" "
+ + "using the string constructor \"Integer(String)\"");
JsonElement jsonIntElement = null;
assertEquals(null, intSchemaHelper.createNewInstance(jsonIntElement));
@@ -222,14 +179,9 @@ public class JavaSchemaHelperTest {
assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Long.parseLong("123")));
assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Float.parseFloat("123")));
assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Double.parseDouble("123")));
- try {
- byteSchemaHelper.unmarshal("one two three");
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Byte\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> byteSchemaHelper.unmarshal("one two three"))
+ .hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
+ + "compatible with class \"java.lang.Byte\"");
assertEquals(null, shortSchemaHelper.unmarshal(null));
assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal("123"));
assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Integer.parseInt("123")));
@@ -238,14 +190,9 @@ public class JavaSchemaHelperTest {
assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Long.parseLong("123")));
assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Float.parseFloat("123")));
assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Double.parseDouble("123")));
- try {
- shortSchemaHelper.unmarshal("one two three");
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Short\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> shortSchemaHelper.unmarshal("one two three"))
+ .hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
+ + "compatible with class \"java.lang.Short\"");
assertEquals(null, intSchemaHelper.unmarshal(null));
assertEquals(123, intSchemaHelper.unmarshal("123"));
assertEquals(123, intSchemaHelper.unmarshal(Integer.parseInt("123")));
@@ -254,14 +201,9 @@ public class JavaSchemaHelperTest {
assertEquals(123, intSchemaHelper.unmarshal(Long.parseLong("123")));
assertEquals(123, intSchemaHelper.unmarshal(Float.parseFloat("123")));
assertEquals(123, intSchemaHelper.unmarshal(Double.parseDouble("123")));
- try {
- intSchemaHelper.unmarshal("one two three");
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Integer\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> intSchemaHelper.unmarshal("one two three"))
+ .hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
+ + "compatible with class \"java.lang.Integer\"");
assertEquals(null, longSchemaHelper.unmarshal(null));
assertEquals(123L, longSchemaHelper.unmarshal("123"));
assertEquals(123L, longSchemaHelper.unmarshal(Integer.parseInt("123")));
@@ -270,14 +212,9 @@ public class JavaSchemaHelperTest {
assertEquals(123L, longSchemaHelper.unmarshal(Long.parseLong("123")));
assertEquals(123L, longSchemaHelper.unmarshal(Float.parseFloat("123")));
assertEquals(123L, longSchemaHelper.unmarshal(Double.parseDouble("123")));
- try {
- longSchemaHelper.unmarshal("one two three");
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Long\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> longSchemaHelper.unmarshal("one two three"))
+ .hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
+ + "compatible with class \"java.lang.Long\"");
assertEquals(null, floatSchemaHelper.unmarshal(null));
assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal("123"));
assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Integer.parseInt("123")));
@@ -286,14 +223,9 @@ public class JavaSchemaHelperTest {
assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Long.parseLong("123")));
assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Float.parseFloat("123")));
assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Double.parseDouble("123")));
- try {
- floatSchemaHelper.unmarshal("one two three");
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Float\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> floatSchemaHelper.unmarshal("one two three"))
+ .hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
+ + "compatible with class \"java.lang.Float\"");
assertEquals(null, doubleSchemaHelper.unmarshal(null));
assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal("123"));
assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Integer.parseInt("123")));
@@ -303,14 +235,9 @@ public class JavaSchemaHelperTest {
assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Float.parseFloat("123")));
assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Double.parseDouble("123")));
assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(BigDecimal.valueOf(123)));
- try {
- doubleSchemaHelper.unmarshal("one two three");
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Double\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> doubleSchemaHelper.unmarshal("one two three"))
+ .hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
+ + "compatible with class \"java.lang.Double\"");
assertEquals("123", stringSchemaHelper.unmarshal(123));
SupportSubClass subClassInstance = new SupportSubClass("123");
@@ -328,14 +255,9 @@ public class JavaSchemaHelperTest {
assertEquals("null", intSchemaHelper.marshal2String(null));
assertEquals("123", intSchemaHelper.marshal2String(123));
- try {
- intSchemaHelper.marshal2String(123.45);
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: object \"123.45\" of class \"java.lang.Double\" not "
- + "compatible with class \"java.lang.Integer\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> intSchemaHelper.marshal2String(123.45))
+ .hasMessage("UserKey:0.0.1: object \"123.45\" of class \"java.lang.Double\" not "
+ + "compatible with class \"java.lang.Integer\"");
JsonPrimitive intJsonPrimitive = (JsonPrimitive) intSchemaHelper.marshal2Object(123);
assertEquals(123, intJsonPrimitive.getAsInt());
}
@@ -351,14 +273,9 @@ public class JavaSchemaHelperTest {
assertEquals("null", stringSchemaHelper.marshal2String(null));
assertEquals("\"Hello\"", stringSchemaHelper.marshal2String("Hello"));
- try {
- stringSchemaHelper.marshal2String(Instant.ofEpochMilli(1000));
- fail("test should throw an exception here");
- } catch (ContextRuntimeException e) {
- assertEquals("UserKey:0.0.1: object \"1970-01-01T00:00:01Z\" of class \"java.time.Instant\" "
- + "not compatible with class \"java.lang.String\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> stringSchemaHelper.marshal2String(Instant.ofEpochMilli(1000)))
+ .hasMessage("UserKey:0.0.1: object \"1970-01-01T00:00:01Z\" of class \"java.time.Instant\" "
+ + "not compatible with class \"java.lang.String\"");
JsonPrimitive stringJsonPrimitive = (JsonPrimitive) stringSchemaHelper.marshal2Object("Another String");
assertEquals("Another String", stringJsonPrimitive.getAsString());
}
@@ -379,14 +296,10 @@ public class JavaSchemaHelperTest {
SchemaHelper stringSchemaHelper = new JavaSchemaHelper();
stringSchemaHelper.init(userKey, stringSchema);
- try {
- stringSchemaHelper.marshal2String("Hello");
- fail("test should throw an exception");
- } catch (ContextRuntimeException pre) {
- assertEquals("UserKey:0.0.1: instantiation of adapter class "
+ assertThatThrownBy(() -> stringSchemaHelper.marshal2String("Hello"))
+ .hasMessage("UserKey:0.0.1: instantiation of adapter class "
+ "\"org.onap.policy.apex.context.impl.schema.java.SupportBadJsonAdapter\" to decode and encode "
- + "class \"java.lang.String\" failed: null", pre.getMessage());
- }
+ + "class \"java.lang.String\" failed: null");
}
@Test