summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java')
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java24
1 files changed, 20 insertions, 4 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/TestAvroSchemaUnion.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
index 100b51d44..33cb20328 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
@@ -25,11 +25,13 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.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;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -37,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,15 +54,28 @@ public class TestAvroSchemaUnion {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
uinionSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/UnionExample.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Ignore
@Test
public void testUnionAllFields() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -76,7 +92,7 @@ public class TestAvroSchemaUnion {
@Test
public void testUnionOptionalField() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -94,7 +110,7 @@ public class TestAvroSchemaUnion {
@Test
public void testUnionNullField() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());