summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro')
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java12
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java6
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java10
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java40
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.java12
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java6
-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.java20
7 files changed, 55 insertions, 51 deletions
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java
index 9e0ab6252..c575eea02 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroBytesObjectMapper.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ public class AvroBytesObjectMapper implements AvroObjectMapper {
public Object mapFromAvro(final Object avroObject) {
// The Avro object should be a Utf8 object
if (!(avroObject instanceof ByteBuffer)) {
- final String returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ final var returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ avroObject.getClass() + "\" cannot be decoded to an object of class \""
+ schemaClass.getName() + "\"";
LOGGER.warn(returnString);
@@ -95,10 +95,10 @@ public class AvroBytesObjectMapper implements AvroObjectMapper {
}
// Cast the byte buffer object so we get access to its methods
- final ByteBuffer byteBufferAvroObject = (ByteBuffer) avroObject;
+ final var byteBufferAvroObject = (ByteBuffer) avroObject;
// read the byte buffer into a byte array
- final byte[] byteArray = new byte[byteBufferAvroObject.remaining()];
+ final var byteArray = new byte[byteBufferAvroObject.remaining()];
byteBufferAvroObject.get(byteArray);
return byteArray;
@@ -110,7 +110,7 @@ public class AvroBytesObjectMapper implements AvroObjectMapper {
@Override
public Object mapToAvro(final Object object) {
if (object == null) {
- final String returnString = userKey.getId() + ": cannot encode a null object of class \""
+ final var returnString = userKey.getId() + ": cannot encode a null object of class \""
+ schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
@@ -118,7 +118,7 @@ public class AvroBytesObjectMapper implements AvroObjectMapper {
// The incoming object should be a byte array
if (!(object instanceof byte[])) {
- final String returnString = userKey.getId() + ": object \"" + object + "\" of class \"" + object.getClass()
+ final var returnString = userKey.getId() + ": object \"" + object + "\" of class \"" + object.getClass()
+ "\" cannot be decoded to an object of class \"" + schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java
index 5d72c62d4..2c2483384 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroDirectObjectMapper.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -117,7 +117,7 @@ public class AvroDirectObjectMapper implements AvroObjectMapper {
// It is legal for the schema class to be null, if the Avro schema has a "null" type then
// the decoded object is always returned as a null
if (!schemaClass.isAssignableFrom(avroObject.getClass())) {
- final String returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ final var returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ avroObject.getClass() + "\" cannot be decoded to an object of class \""
+ schemaClass.getName() + "\"";
LOGGER.warn(returnString);
@@ -134,7 +134,7 @@ public class AvroDirectObjectMapper implements AvroObjectMapper {
public Object mapToAvro(final Object object) {
// Null values are only allowed if the schema class is null
if (object == null && schemaClass != null) {
- final String returnString = userKey.getId() + ": cannot encode a null object of class \""
+ final var returnString = userKey.getId() + ": cannot encode a null object of class \""
+ schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java
index 13feae3f4..4a4d92dea 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroObjectMapperFactory.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-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,14 +70,14 @@ public class AvroObjectMapperFactory {
* @return the avro object mapper
*/
public AvroObjectMapper get(final AxKey userKey, final Schema incomingSchema) {
- Schema schema = incomingSchema;
- boolean isnullable = false;
+ var schema = incomingSchema;
+ var isnullable = false;
if (Schema.Type.UNION.equals(schema.getType())) {
final List<Schema> types = schema.getTypes();
// currently only support unions with 2 types, one of which is NULL
- final Schema nullschema = Schema.create(Schema.Type.NULL);
+ final var nullschema = Schema.create(Schema.Type.NULL);
if (types.size() != 2 || !types.contains(nullschema)) {
final String resultSting = userKey.getId()
+ ": Apex currently only supports UNION schemas with 2 options, one must be NULL";
@@ -99,7 +99,7 @@ public class AvroObjectMapperFactory {
}
}
- final Schema.Type avroType = schema.getType();
+ final var avroType = schema.getType();
// Check that there is a definition for the mapper for this type
if (!AVRO_OBJECT_MAPPER_MAP.containsKey(avroType) || AVRO_OBJECT_MAPPER_MAP.get(avroType) == null) {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
index 020cc1520..fe6779891 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.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-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,8 +37,6 @@ import org.apache.avro.generic.GenericRecord;
import org.apache.avro.io.DatumWriter;
import org.apache.avro.io.DecoderFactory;
import org.apache.avro.io.EncoderFactory;
-import org.apache.avro.io.JsonDecoder;
-import org.apache.avro.io.JsonEncoder;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.impl.schema.AbstractSchemaHelper;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -100,7 +98,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
@Override
public Object createNewInstance() {
// Create a new instance using the Avro object mapper
- final Object newInstance = avroObjectMapper.createNewInstance(avroSchema);
+ final var newInstance = avroObjectMapper.createNewInstance(avroSchema);
// If no new instance is created, use default schema handler behaviour
if (newInstance != null) {
@@ -118,12 +116,12 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
@Override
public Object createNewInstance(final Object incomingObject) {
if (incomingObject instanceof JsonElement) {
- final Gson gson = new GsonBuilder().serializeNulls().create();
- final String elementJsonString = gson.toJson((JsonElement) incomingObject);
+ final var gson = new GsonBuilder().serializeNulls().create();
+ final var elementJsonString = gson.toJson((JsonElement) incomingObject);
return createNewInstance(elementJsonString);
} else {
- final String returnString =
+ final var returnString =
getUserKey().getId() + ": the object \"" + incomingObject + "\" is not an instance of JsonObject";
throw new ContextRuntimeException(returnString);
}
@@ -138,7 +136,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
if (subInstance != null) {
return subInstance;
} else {
- final String returnString = getUserKey().getId() + ": the schema \"" + avroSchema.getName()
+ final var returnString = getUserKey().getId() + ": the schema \"" + avroSchema.getName()
+ "\" does not have a subtype of type \"" + subInstanceType + "\"";
throw new ContextRuntimeException(returnString);
}
@@ -216,7 +214,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
return object;
}
- String objectString = getStringObject(object);
+ var objectString = getStringObject(object);
// Translate illegal characters in incoming JSON keys to legal Avro values
objectString = AvroSchemaKeyTranslationUtilities.translateIllegalKeys(objectString, false);
@@ -224,10 +222,10 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
// Decode the object
Object decodedObject;
try {
- final JsonDecoder jsonDecoder = DecoderFactory.get().jsonDecoder(avroSchema, objectString);
+ final var jsonDecoder = DecoderFactory.get().jsonDecoder(avroSchema, objectString);
decodedObject = new GenericDatumReader<GenericRecord>(avroSchema).read(null, jsonDecoder);
} catch (final Exception e) {
- final String returnString =
+ final var returnString =
getUserKey().getId() + OBJECT_TAG + objectString + "\" Avro unmarshalling failed.";
throw new ContextRuntimeException(returnString, e);
}
@@ -250,7 +248,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
return (String) object;
}
} catch (final ClassCastException e) {
- final String returnString = getUserKey().getId() + OBJECT_TAG + object + "\" of type \""
+ final var returnString = getUserKey().getId() + OBJECT_TAG + object + "\" of type \""
+ (object != null ? object.getClass().getName() : "null") + "\" must be assignable to \""
+ getSchemaClass().getName() + "\" or be a Json string representation of it for Avro unmarshalling";
throw new ContextRuntimeException(returnString, e);
@@ -264,7 +262,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
* @return the string
*/
private String getObjectString(final Object object) {
- String objectString = object.toString().trim();
+ var objectString = object.toString().trim();
if (objectString.length() == 0) {
return "\"\"";
} else if (objectString.length() == 1) {
@@ -288,23 +286,23 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
@Override
public String marshal2String(final Object object) {
// Condition the object for Avro encoding
- final Object conditionedObject = avroObjectMapper.mapToAvro(object);
+ final var conditionedObject = avroObjectMapper.mapToAvro(object);
- final String jsonString = getJsonString(object, conditionedObject);
+ final var jsonString = getJsonString(object, conditionedObject);
return AvroSchemaKeyTranslationUtilities.translateIllegalKeys(jsonString, true);
}
private String getJsonString(final Object object, final Object conditionedObject) {
- try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
+ try (final var output = new ByteArrayOutputStream()) {
final DatumWriter<Object> writer = new GenericDatumWriter<>(avroSchema);
- final JsonEncoder jsonEncoder = EncoderFactory.get().jsonEncoder(avroSchema, output, true);
+ final var jsonEncoder = EncoderFactory.get().jsonEncoder(avroSchema, output, true);
writer.write(conditionedObject, jsonEncoder);
jsonEncoder.flush();
return new String(output.toByteArray());
} catch (final Exception e) {
- final String returnString = getUserKey().getId() + OBJECT_TAG + object + "\" Avro marshalling failed.";
+ final var returnString = getUserKey().getId() + OBJECT_TAG + object + "\" Avro marshalling failed.";
throw new ContextRuntimeException(returnString, e);
}
}
@@ -312,13 +310,13 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
@Override
public JsonElement marshal2Object(final Object schemaObject) {
// Get the object as a Json string
- final String schemaObjectAsString = marshal2String(schemaObject);
+ final var schemaObjectAsString = marshal2String(schemaObject);
// Get a Gson instance to convert the Json string to an object created by Json
- final Gson gson = new Gson();
+ final var gson = new Gson();
// Convert the Json string into an object
- final Object schemaObjectAsObject = gson.fromJson(schemaObjectAsString, Object.class);
+ final var schemaObjectAsObject = gson.fromJson(schemaObjectAsString, Object.class);
return gson.toJsonTree(schemaObjectAsObject);
}
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.java
index 6229c066e..34a4dedb0 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaKeyTranslationUtilities.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-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,10 +62,10 @@ public final class AvroSchemaKeyTranslationUtilities {
}
// Create a JSON element for the incoming JSON string
- final JsonElement jsonElement = new GsonBuilder().serializeNulls().create().fromJson(jsonString,
+ final var jsonElement = new GsonBuilder().serializeNulls().create().fromJson(jsonString,
JsonElement.class);
- final JsonElement translatedJsonElement = translateIllegalKeys(jsonElement, revert);
+ final var translatedJsonElement = translateIllegalKeys(jsonElement, revert);
return new GsonBuilder().serializeNulls().create().toJson(translatedJsonElement);
}
@@ -98,7 +98,7 @@ public final class AvroSchemaKeyTranslationUtilities {
* @return the translated JSON element
*/
public static JsonElement translateIllegalKeys(final JsonObject jsonObject, final boolean revert) {
- final JsonObject newJsonObject = new JsonObject();
+ final var newJsonObject = new JsonObject();
for (final Entry<String, JsonElement> jsonObjectEntry : jsonObject.entrySet()) {
newJsonObject.add(translateIllegalKey(jsonObjectEntry.getKey(), revert),
@@ -117,9 +117,9 @@ public final class AvroSchemaKeyTranslationUtilities {
* @return the translated JSON element
*/
public static JsonElement translateIllegalKeys(final JsonArray jsonArray, final boolean revert) {
- final JsonArray newJsonArray = new JsonArray();
+ final var newJsonArray = new JsonArray();
- for (int i = 0; i < jsonArray.size(); i++) {
+ for (var i = 0; i < jsonArray.size(); i++) {
newJsonArray.add(translateIllegalKeys(jsonArray.get(i), revert));
}
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java
index f664006e2..27737b500 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroStringObjectMapper.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ public class AvroStringObjectMapper implements AvroObjectMapper {
public Object mapFromAvro(final Object avroObject) {
// The Avro object should be a Utf8 object
if (!(avroObject instanceof Utf8)) {
- final String returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ final var returnString = userKey.getId() + ": object \"" + avroObject + "\" of class \""
+ avroObject.getClass() + "\" cannot be decoded to an object of class \""
+ schemaClass.getName() + "\"";
LOGGER.warn(returnString);
@@ -103,7 +103,7 @@ public class AvroStringObjectMapper implements AvroObjectMapper {
@Override
public Object mapToAvro(final Object object) {
if (object == null) {
- final String returnString = userKey.getId() + ": cannot encode a null object of class \""
+ final var returnString = userKey.getId() + ": cannot encode a null object of class \""
+ schemaClass.getName() + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
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 abc9335ae..f4d202473 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 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ public class AvroSchemaMapTest {
assertEquals(new Utf8("foo"), subst1A.get("A_DasH_B"));
assertNull(subst1A.get("A-B"));
final Throwable exception1 = assertThrows(ContextRuntimeException.class,
- () -> schemaHelperSubst1.unmarshal("{\"A-B\":123}"));
+ () -> schemaHelperSubst1.unmarshal("{\"A-B\":123}"));
assertNotNull(exception1.getCause());
assertEquals("Expected string. Got VALUE_NUMBER_INT", exception1.getCause().getMessage());
@@ -129,7 +129,7 @@ public class AvroSchemaMapTest {
assertEquals(123, subst2A.get("C_DoT_D"));
assertNull(subst2A.get("C.D"));
final Throwable exception2 = assertThrows(ContextRuntimeException.class,
- () -> schemaHelperSubst2.unmarshal("{\"C_DoT_D\":\"bar\"}"));
+ () -> schemaHelperSubst2.unmarshal("{\"C_DoT_D\":\"bar\"}"));
assertNotNull(exception2.getCause());
assertEquals("Expected int. Got VALUE_STRING", exception2.getCause().getMessage());
@@ -145,7 +145,7 @@ public class AvroSchemaMapTest {
assertEquals(true, subst3A.get("E_ColoN_F"));
assertNull(subst3A.get("E:F"));
final Throwable exception3 = assertThrows(ContextRuntimeException.class,
- () -> schemaHelperSubst3.unmarshal("{\"E_ColoN_F\":\"gaz\"}"));
+ () -> schemaHelperSubst3.unmarshal("{\"E_ColoN_F\":\"gaz\"}"));
assertNotNull(exception3.getCause());
assertEquals("Expected boolean. Got VALUE_STRING", exception3.getCause().getMessage());
}
@@ -162,8 +162,11 @@ public class AvroSchemaMapTest {
final AxContextSchema avroFailSchema1 = new AxContextSchema(
new AxArtifactKey("AvroFail1", "0.0.1"), "AVRO", fail1);
schemas.getSchemasMap().put(avroFailSchema1.getKey(), avroFailSchema1);
+
+ SchemaHelperFactory sh = new SchemaHelperFactory();
+ AxArtifactKey ak = avroFailSchema1.getKey();
final Throwable exception1 = assertThrows(ContextRuntimeException.class,
- () -> new SchemaHelperFactory().createSchemaHelper(testKey, avroFailSchema1.getKey()));
+ () -> sh.createSchemaHelper(testKey, ak));
assertNotNull(exception1.getCause());
assertEquals("Illegal character in: A-B", exception1.getCause().getMessage());
@@ -172,8 +175,10 @@ public class AvroSchemaMapTest {
final AxContextSchema avroFailSchema2 = new AxContextSchema(
new AxArtifactKey("AvroFail2", "0.0.1"), "AVRO", fail2);
schemas.getSchemasMap().put(avroFailSchema2.getKey(), avroFailSchema2);
+
+ AxArtifactKey ak2 = avroFailSchema2.getKey();
final Throwable exception2 = assertThrows(ContextRuntimeException.class,
- () -> new SchemaHelperFactory().createSchemaHelper(testKey, avroFailSchema2.getKey()));
+ () -> sh.createSchemaHelper(testKey, ak2));
assertNotNull(exception2.getCause());
assertEquals("Illegal character in: C.D", exception2.getCause().getMessage());
@@ -182,8 +187,9 @@ public class AvroSchemaMapTest {
final AxContextSchema avroFailSchema3 = new AxContextSchema(
new AxArtifactKey("AvroFail3", "0.0.1"), "AVRO", fail3);
schemas.getSchemasMap().put(avroFailSchema3.getKey(), avroFailSchema3);
+ AxArtifactKey ak3 = avroFailSchema3.getKey();
final Throwable exception3 = assertThrows(ContextRuntimeException.class,
- () -> new SchemaHelperFactory().createSchemaHelper(testKey, avroFailSchema3.getKey()));
+ () -> sh.createSchemaHelper(testKey, ak3));
assertNotNull(exception3.getCause());
assertEquals("Illegal character in: E:F", exception3.getCause().getMessage());
}