X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=champ-lib%2Fchamp-core%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fchampcore%2Fcore%2FChampSchemaTest.java;fp=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fchamp%2Fcore%2FChampSchemaTest.java;h=ba62628a101bbd5ef6754240ace5e7324a7afe10;hb=c74f7b13b573386e70c10721fc391624ee792ed6;hp=df3363137963a45f93f3a874241f10c7b3c5873e;hpb=9fc28cff11a4b570618c0f533ce9de6209a5dd0c;p=aai%2Fchamp.git diff --git a/src/test/java/org/onap/aai/champ/core/ChampSchemaTest.java b/champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampSchemaTest.java similarity index 93% rename from src/test/java/org/onap/aai/champ/core/ChampSchemaTest.java rename to champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampSchemaTest.java index df33631..ba62628 100644 --- a/src/test/java/org/onap/aai/champ/core/ChampSchemaTest.java +++ b/champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampSchemaTest.java @@ -19,52 +19,47 @@ * ============LICENSE_END============================================ * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ -package org.onap.aai.champ.core; +package org.onap.aai.champcore.core; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.Optional; import java.util.Set; import org.junit.Test; -import org.onap.aai.champ.ChampAPI; -import org.onap.aai.champ.ChampGraph; -import org.onap.aai.champ.exceptions.ChampMarshallingException; -import org.onap.aai.champ.exceptions.ChampObjectNotExistsException; -import org.onap.aai.champ.exceptions.ChampSchemaViolationException; -import org.onap.aai.champ.model.ChampConnectionConstraint; -import org.onap.aai.champ.model.ChampConnectionMultiplicity; -import org.onap.aai.champ.model.ChampField; -import org.onap.aai.champ.model.ChampObject; -import org.onap.aai.champ.model.ChampObjectConstraint; -import org.onap.aai.champ.model.ChampPartition; -import org.onap.aai.champ.model.ChampPropertyConstraint; -import org.onap.aai.champ.model.ChampRelationship; -import org.onap.aai.champ.model.ChampRelationshipConstraint; -import org.onap.aai.champ.model.ChampSchema; -import org.onap.aai.champ.model.ChampObject.ReservedTypes; -import org.onap.aai.champ.schema.AlwaysValidChampSchemaEnforcer; -import org.onap.aai.champ.schema.ChampSchemaEnforcer; -import org.onap.aai.champ.schema.DefaultChampSchemaEnforcer; +import org.onap.aai.champcore.ChampAPI; +import org.onap.aai.champcore.ChampGraph; +import org.onap.aai.champcore.exceptions.ChampMarshallingException; +import org.onap.aai.champcore.exceptions.ChampObjectNotExistsException; +import org.onap.aai.champcore.exceptions.ChampSchemaViolationException; +import org.onap.aai.champcore.exceptions.ChampTransactionException; +import org.onap.aai.champcore.model.ChampConnectionConstraint; +import org.onap.aai.champcore.model.ChampConnectionMultiplicity; +import org.onap.aai.champcore.model.ChampField; +import org.onap.aai.champcore.model.ChampObject; +import org.onap.aai.champcore.model.ChampObject.ReservedTypes; +import org.onap.aai.champcore.model.ChampObjectConstraint; +import org.onap.aai.champcore.model.ChampPartition; +import org.onap.aai.champcore.model.ChampPropertyConstraint; +import org.onap.aai.champcore.model.ChampRelationship; +import org.onap.aai.champcore.model.ChampRelationshipConstraint; +import org.onap.aai.champcore.model.ChampSchema; +import org.onap.aai.champcore.schema.AlwaysValidChampSchemaEnforcer; +import org.onap.aai.champcore.schema.ChampSchemaEnforcer; +import org.onap.aai.champcore.schema.DefaultChampSchemaEnforcer; import com.fasterxml.jackson.databind.ObjectMapper; public class ChampSchemaTest extends BaseChampAPITest { @Test - public void runTest() { - for (ChampGraph.Type apiType : ChampGraph.Type.values()) { - final String graphName = ChampSchemaTest.class.getSimpleName(); + public void runInMemoryTest() { + runTest("IN_MEMORY"); + } - switch (apiType) { - case IN_MEMORY: - break; - case TITAN: - cleanUp(graphName); - break; - default: - break; - } + public void runTest(String apiType) { + final String graphName = ChampSchemaTest.class.getSimpleName(); final ChampAPI api = ChampAPI.Factory.newInstance(apiType); @@ -75,7 +70,6 @@ public class ChampSchemaTest extends BaseChampAPITest { } api.shutdown(); - } } public static void testChampSchemaCrud(ChampGraph graph) { @@ -118,14 +112,16 @@ public class ChampSchemaTest extends BaseChampAPITest { .build(); try { - graph.storeObject(emptyFoo); + graph.storeObject(emptyFoo, Optional.empty()); } catch (ChampMarshallingException e1) { throw new AssertionError(e1); } catch (ChampSchemaViolationException e1) { //Expected, since it does not have the required property "property1" } catch (ChampObjectNotExistsException e) { throw new AssertionError(e); - } + } catch (ChampTransactionException e) { + throw new AssertionError(e); + } final ChampSchema retrievedSchema = graph.retrieveSchema(); @@ -158,16 +154,18 @@ public class ChampSchemaTest extends BaseChampAPITest { ) .build()); - final ChampObject storedEmptyFoo = graph.storeObject(emptyFoo); + final ChampObject storedEmptyFoo = graph.storeObject(emptyFoo, Optional.empty()); - graph.deleteObject(storedEmptyFoo.getKey().get()); + graph.deleteObject(storedEmptyFoo.getKey().get(), Optional.empty()); } catch (ChampMarshallingException e) { throw new AssertionError(e); } catch (ChampSchemaViolationException e) { throw new AssertionError(e); } catch (ChampObjectNotExistsException e) { throw new AssertionError(e); - } + } catch (ChampTransactionException e) { + throw new AssertionError(e); + } graph.deleteSchema(); assertTrue(graph.retrieveSchema().equals(ChampSchema.emptySchema()));