summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-08-20 15:40:35 +0100
committerAndr� Schmid <andre.schmid@est.tech>2021-08-27 10:33:32 +0000
commita5e32b3d20bc078482cb08645c38ffb685c0f145 (patch)
tree133fe88578f3a3c3db3ec73315b65f45caba625a /catalog-model/src/test/java
parent4701612ba26c4b8c7c7e9fbfa38f582a4b74669f (diff)
Support querying of model by type
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3678 Change-Id: I5fd19eefe475113df501901628b2ee8669004399
Diffstat (limited to 'catalog-model/src/test/java')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java3
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java3
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java3
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java3
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java18
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java6
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java9
7 files changed, 27 insertions, 18 deletions
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 af4715fd62..6ed482f948 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
@@ -47,6 +47,7 @@ import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
import org.openecomp.sdc.be.model.Model;
@@ -136,7 +137,7 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
capabilityTypeDefinition.setType("tosca.capabilities.Container1");
capabilityTypeDefinition.setModel("testModel");
- Model model = new Model("testModel");
+ Model model = new Model("testModel", ModelTypeEnum.NORMATIVE);
modelOperation.createModel(model , true);
Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java
index 015aedc6a3..c8a2b03fb3 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java
@@ -34,6 +34,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.Model;
@@ -122,7 +123,7 @@ class DataTypeOperationTest {
private void initTestData() {
- model = new Model(modelName);
+ model = new Model(modelName, ModelTypeEnum.NORMATIVE);
final String TEST_DATA_TYPE_001 = "test.data.type001";
final String TEST_DATA_TYPE_002 = "test.data.type002";
final String TEST_DATA_TYPE_003 = "test.data.type003";
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java
index 48202c3ec5..19812e6d61 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java
@@ -48,6 +48,7 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.GroupTypeDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
@@ -544,7 +545,7 @@ public class GroupTypeOperationTest extends ModelTestBase {
public void testAddGroupTypeWithModel() {
GroupTypeDefinition groupTypeDefinition = createGroupTypeDef();
groupTypeDefinition.setModel("testModel");
- Model model = new Model("testModel");
+ Model model = new Model("testModel", ModelTypeEnum.NORMATIVE);
modelOperation.createModel(model , true);
Either<GroupTypeDefinition, StorageOperationStatus> addGroupType = groupTypeOperation.addGroupType(groupTypeDefinition);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java
index 4e0d68f7e2..1a7f1c8ba3 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java
@@ -48,6 +48,7 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.ModelTestBase;
@@ -188,7 +189,7 @@ public class InterfaceLifecycleOperationTest {
@Test
public void testGetAllInterfaceLifecycleTypesWithModel() {
final var uid = UniqueIdBuilder.buildInterfaceTypeUid(MODEL_NAME, INTERFACE_TYPE);
- final var modelData = new ModelData(MODEL_NAME, uid);
+ final var modelData = new ModelData(MODEL_NAME, uid, ModelTypeEnum.NORMATIVE);
final ImmutablePair<GraphNode, GraphEdge> modelNode = new ImmutablePair<>(modelData, Mockito.mock(GraphEdge.class));
final InterfaceData interfaceData = new InterfaceData();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
index 44a9a7df42..6071b4d59d 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
@@ -58,6 +58,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.data.model.ToscaImportByModel;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.Model;
import org.openecomp.sdc.be.model.ModelTestBase;
@@ -95,9 +96,9 @@ class ModelOperationTest extends ModelTestBase {
@Test
void createModelSuccessTest() {
- final ModelData modelData = new ModelData(modelName, UniqueIdBuilder.buildModelUid(modelName));
+ final ModelData modelData = new ModelData(modelName, UniqueIdBuilder.buildModelUid(modelName), ModelTypeEnum.NORMATIVE);
when(janusGraphGenericDao.createNode(any(),any())).thenReturn(Either.left(modelData));
- final Model createdModel = modelOperation.createModel(new Model(modelName), false);
+ final Model createdModel = modelOperation.createModel(new Model(modelName, ModelTypeEnum.NORMATIVE), false);
assertThat(createdModel).isNotNull();
assertThat(createdModel.getName()).isEqualTo(modelName);
}
@@ -105,16 +106,17 @@ class ModelOperationTest extends ModelTestBase {
@Test
void createDerivedModelSuccessTest() {
final String derivedModelName = "derivedModel";
- final ModelData modelData = new ModelData(derivedModelName, UniqueIdBuilder.buildModelUid(derivedModelName));
+ final ModelData modelData = new ModelData(derivedModelName, UniqueIdBuilder.buildModelUid(derivedModelName), ModelTypeEnum.NORMATIVE);
when(janusGraphGenericDao.createNode(any(),any())).thenReturn(Either.left(modelData));
final GraphVertex modelVertex = new GraphVertex();
modelVertex.addMetadataProperty(GraphPropertyEnum.NAME, "baseModel");
+ modelVertex.addMetadataProperty(GraphPropertyEnum.MODEL_TYPE, ModelTypeEnum.NORMATIVE.getValue());
when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.MODEL), anyMap())).thenReturn(Either.left(Collections.singletonList(modelVertex)));
when(janusGraphGenericDao.getChild(eq("uid"), anyString(), eq(GraphEdgeLabels.DERIVED_FROM), eq(NodeTypeEnum.Model), eq(ModelData.class))).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
when(derivedFromOperation.addDerivedFromRelation("model.derivedModel", "model.baseModel", NodeTypeEnum.Model)).thenReturn(Either.left(new GraphRelation()));
- final Model createdModel = modelOperation.createModel(new Model(derivedModelName, modelName), false);
+ final Model createdModel = modelOperation.createModel(new Model(derivedModelName, modelName, ModelTypeEnum.NORMATIVE), false);
assertThat(createdModel).isNotNull();
assertThat(createdModel.getName()).isEqualTo(derivedModelName);
}
@@ -122,14 +124,14 @@ class ModelOperationTest extends ModelTestBase {
@Test
void createModelFailWithModelAlreadyExistTest() {
when(janusGraphGenericDao.createNode(any(),any())).thenReturn(Either.right(JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION));
- final var model = new Model(modelName);
+ final var model = new Model(modelName, ModelTypeEnum.NORMATIVE);
assertThrows(OperationException.class, () -> modelOperation.createModel(model, false));
}
@Test
void createModelFailTest() {
when(janusGraphGenericDao.createNode(any(),any())).thenReturn(Either.right(JanusGraphOperationStatus.GRAPH_IS_NOT_AVAILABLE));
- final var model = new Model(modelName);
+ final var model = new Model(modelName, ModelTypeEnum.NORMATIVE);
assertThrows(OperationException.class, () -> modelOperation.createModel(model, false));
}
@@ -224,6 +226,7 @@ class ModelOperationTest extends ModelTestBase {
var modelName = "modelName";
final GraphVertex expectedVertex = mock(GraphVertex.class);
when(expectedVertex.getMetadataProperty(GraphPropertyEnum.NAME)).thenReturn(modelName);
+ when(expectedVertex.getMetadataProperty(GraphPropertyEnum.MODEL_TYPE)).thenReturn(ModelTypeEnum.NORMATIVE.getValue());
when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.MODEL), mapArgumentCaptor.capture())).thenReturn(Either.left(List.of(expectedVertex)));
when(janusGraphGenericDao.getChild("uid", UniqueIdBuilder.buildModelUid(modelName), GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.Model,
ModelData.class)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
@@ -233,7 +236,7 @@ class ModelOperationTest extends ModelTestBase {
assertEquals(modelName, value.get(GraphPropertyEnum.NAME));
assertEquals(UniqueIdBuilder.buildModelUid(modelName), value.get(GraphPropertyEnum.UNIQUE_ID));
- final Model expectedModel = new Model(modelName);
+ final Model expectedModel = new Model(modelName, ModelTypeEnum.NORMATIVE);
assertTrue(modelByNameOpt.isPresent());
assertEquals(expectedModel, modelByNameOpt.get());
}
@@ -258,6 +261,7 @@ class ModelOperationTest extends ModelTestBase {
void findAllModelsSuccessTest() {
final GraphVertex expectedVertex = mock(GraphVertex.class);
when(expectedVertex.getMetadataProperty(GraphPropertyEnum.NAME)).thenReturn(modelName);
+ when(expectedVertex.getMetadataProperty(GraphPropertyEnum.MODEL_TYPE)).thenReturn(ModelTypeEnum.NORMATIVE.getValue());
when(janusGraphDao.getByCriteria(VertexTypeEnum.MODEL, Collections.emptyMap())).thenReturn(Either.left(List.of(expectedVertex)));
when(janusGraphGenericDao.getChild("uid", UniqueIdBuilder.buildModelUid(modelName), GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.Model,
ModelData.class)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
index d849ec647d..a6b2aa687a 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
@@ -25,8 +25,6 @@ import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
-import fj.data.Either;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
@@ -44,6 +42,7 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.datatypes.elements.PolicyTypeDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.Model;
import org.openecomp.sdc.be.model.ModelTestBase;
@@ -54,6 +53,7 @@ import org.openecomp.sdc.be.resources.data.PolicyTypeData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import fj.data.Either;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:application-context-test.xml")
@@ -117,7 +117,7 @@ public class PolicyTypeOperationTest extends ModelTestBase {
public void testAddPolicyTypeWithModel() {
PolicyTypeDefinition policyTypeDefinition = createPolicyTypeDef();
policyTypeDefinition.setModel("testModel");
- Model model = new Model("testModel");
+ Model model = new Model("testModel", ModelTypeEnum.NORMATIVE);
modelOperation.createModel(model , true);
Either<PolicyTypeDefinition, StorageOperationStatus> addPolicyType = policyTypeOperation.addPolicyType(policyTypeDefinition);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
index 6551a13981..371c3edfe5 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
@@ -50,6 +50,7 @@ import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.ModelTestBase;
import org.openecomp.sdc.be.model.PropertyConstraint;
@@ -396,7 +397,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase {
.when(janusGraphGenericDao).getNode(Mockito.anyString(), Mockito.any(), Mockito.eq(RelationshipTypeData.class), Mockito.any());
- ModelData modelData = new ModelData("modelA", "modelA");
+ ModelData modelData = new ModelData("modelA", "modelA", ModelTypeEnum.NORMATIVE);
ImmutablePair<ModelData, GraphEdge> pair = new ImmutablePair<>(modelData, new GraphEdge());
Mockito.doReturn(Either.left(pair))
.when(janusGraphGenericDao).getParentNode("uid", relationshipInstDataDefinition1.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class);
@@ -464,7 +465,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase {
Mockito.doReturn(Either.left(new GraphRelation())).when(derivedFromOperation)
.addDerivedFromRelation(relationshipTypeDefinition.getUniqueId(), derivedFromRelationshipTypeData.getUniqueId(), NodeTypeEnum.RelationshipType);
- ModelData modelData = new ModelData("modelA", "modelA");
+ ModelData modelData = new ModelData("modelA", "modelA", ModelTypeEnum.NORMATIVE);
ImmutablePair<ModelData, GraphEdge> pair = new ImmutablePair<>(modelData, new GraphEdge());
Mockito.doReturn(Either.left(pair))
.when(janusGraphGenericDao).getParentNode("uid", dervideFromRelationshipInstDataDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class);
@@ -544,7 +545,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase {
Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(janusGraphGenericDao)
.getChild(Mockito.any(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.eq(RelationshipTypeData.class));
- ModelData modelData = new ModelData("modelA", "modelA");
+ ModelData modelData = new ModelData("modelA", "modelA", ModelTypeEnum.NORMATIVE);
ImmutablePair<ModelData, GraphEdge> pair = new ImmutablePair<>(modelData, new GraphEdge());
Mockito.doReturn(Either.left(pair))
.when(janusGraphGenericDao).getParentNode("uid", newRelationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class);
@@ -574,7 +575,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase {
.getChild(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(),
Mockito.eq(RelationshipTypeData.class));
- ModelData modelData = new ModelData("modelA", "modelA");
+ ModelData modelData = new ModelData("modelA", "modelA", ModelTypeEnum.NORMATIVE);
ImmutablePair<ModelData, GraphEdge> pair = new ImmutablePair<>(modelData, new GraphEdge());
Mockito.doReturn(Either.left(pair))
.when(janusGraphGenericDao).getParentNode("uid", relationshipTypeDefinition.getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class);