From ab6a90df6444ef7282fe9de8fe8107641bf7082f Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Fri, 28 May 2021 12:29:13 +0100 Subject: Support adding capability types to model Signed-off-by: MichaelMorris Issue-ID: SDC-3612 Change-Id: I5d3713ba420c2392dd232b5651aef4d51560ab4a --- .../impl/CapabilityTypeOperationTest.java | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'catalog-model/src/test/java') diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java index 5391410431..af4715fd62 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java @@ -49,6 +49,7 @@ import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.CapabilityTypeDefinition; +import org.openecomp.sdc.be.model.Model; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; @@ -73,6 +74,9 @@ public class CapabilityTypeOperationTest extends ModelTestBase { @Resource(name = "capability-type-operation") private CapabilityTypeOperation capabilityTypeOperation; + + @Resource(name = "model-operation") + private ModelOperation modelOperation; @BeforeClass public static void setupBeforeClass() { @@ -123,6 +127,40 @@ public class CapabilityTypeOperationTest extends ModelTestBase { assertEquals("check returned error", StorageOperationStatus.SCHEMA_VIOLATION, addCapabilityType2.right().value()); } + + @Test + public void testAddCapabilityTypeWithModel() { + + CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition(); + capabilityTypeDefinition.setDescription("desc1"); + capabilityTypeDefinition.setType("tosca.capabilities.Container1"); + capabilityTypeDefinition.setModel("testModel"); + + Model model = new Model("testModel"); + modelOperation.createModel(model , true); + + Either addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + assertTrue("check capability type added", addCapabilityType1.isLeft()); + + CapabilityTypeDefinition capabilityTypeAdded = addCapabilityType1.left().value(); + compareBetweenCreatedToSent(capabilityTypeDefinition, capabilityTypeAdded); + + Either capabilityTypeByUid = capabilityTypeOperation.getCapabilityTypeByUid(capabilityTypeAdded.getUniqueId()); + compareBetweenCreatedToSent(capabilityTypeByUid.left().value(), capabilityTypeDefinition); + + CapabilityTypeDefinition capabilityTypeWithDerivedFrom = new CapabilityTypeDefinition(); + capabilityTypeWithDerivedFrom.setDescription("desc2"); + capabilityTypeWithDerivedFrom.setType("tosca.capabilities.Container2"); + capabilityTypeWithDerivedFrom.setDerivedFrom("tosca.capabilities.Container1"); + capabilityTypeWithDerivedFrom.setModel("testModel"); + + Either addCapabilityType2 = capabilityTypeOperation.addCapabilityType(capabilityTypeWithDerivedFrom, true); + assertTrue("check capability type added", addCapabilityType2.isLeft()); + + capabilityTypeAdded = addCapabilityType2.left().value(); + compareBetweenCreatedToSent(capabilityTypeWithDerivedFrom, capabilityTypeAdded); + + } @Test public void testAddDerviedCapabilityType() { @@ -500,6 +538,7 @@ public class CapabilityTypeOperationTest extends ModelTestBase { assertTrue(compareValue(x.getDerivedFrom(), y.getDerivedFrom())); assertTrue(compareValue(x.getType(), y.getType())); assertTrue(compareValue(x.getDescription(), y.getDescription())); + assertTrue(compareValue(x.getModel(), y.getModel())); } -- cgit 1.2.3-korg