diff options
Diffstat (limited to 'context')
4 files changed, 24 insertions, 2 deletions
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/SchemaHelper.java b/context/context-management/src/main/java/org/onap/policy/apex/context/SchemaHelper.java index 44ec06c6d..b6d21a20d 100644 --- a/context/context-management/src/main/java/org/onap/policy/apex/context/SchemaHelper.java +++ b/context/context-management/src/main/java/org/onap/policy/apex/context/SchemaHelper.java @@ -92,6 +92,14 @@ public interface SchemaHelper { Object createNewInstance(Object incomingObject); /** + * Create an object of a sub type of this object. + * + * @param subType the sub type definition of this type + * @return a new object of the sub type + */ + Object createNewSubInstance(String subType); + + /** * Unmarshal an object in schema format into a Java object. * * @param object the object as a Java object diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java index f50eb5914..6d98313ed 100644 --- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java +++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java @@ -22,6 +22,7 @@ package org.onap.policy.apex.context.impl.schema; import java.lang.reflect.Constructor; +import org.apache.commons.lang3.NotImplementedException; import org.onap.policy.apex.context.ContextRuntimeException; import org.onap.policy.apex.context.SchemaHelper; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; @@ -169,4 +170,12 @@ public abstract class AbstractSchemaHelper implements SchemaHelper { throw new ContextRuntimeException(returnString); } } + + /* (non-Javadoc) + * @see org.onap.policy.apex.context.SchemaHelper#createNewSubInstance(java.lang.String) + */ + @Override + public Object createNewSubInstance(String subType) { + throw new NotImplementedException("sub types are not supported on this schema helper"); + } } diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java index 8b61f718a..fcc7c4d60 100644 --- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java +++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java @@ -279,5 +279,4 @@ public class JavaSchemaHelper extends AbstractSchemaHelper { return gsonBuilder.create(); } - } 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 800a7011d..14d44ee8b 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 @@ -96,7 +96,6 @@ public class JavaSchemaHelperInstanceCreationTest { } assertEquals(true, schemaHelper0.createNewInstance("true")); - try { schemaHelper1.createNewInstance(); fail("this test should throw an exception here"); @@ -108,5 +107,12 @@ public class JavaSchemaHelperInstanceCreationTest { 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()); + } } } |