aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model
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
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')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Model.java7
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java24
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ModelOperationExceptionSupplier.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java20
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/ModelCreateRequest.java4
-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
12 files changed, 70 insertions, 34 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Model.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Model.java
index 9c07c0565c..f551f252c7 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Model.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Model.java
@@ -18,6 +18,7 @@
*/
package org.openecomp.sdc.be.model;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import com.googlecode.jmapper.annotations.JGlobalMap;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -31,9 +32,15 @@ public class Model {
private String name;
private String derivedFrom;
+ private ModelTypeEnum modelType;
public Model(final String name) {
this.name = name;
}
+
+ public Model(final String name, final ModelTypeEnum modelType) {
+ this.name = name;
+ this.modelType = modelType;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index bd61f61a49..b2ccb6d0ac 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -1935,17 +1935,18 @@ public class ToscaOperationFacade {
return fetchServicesByCriteria(services, hasProps, hasNotProps, modelName);
}
- private Either<List<Component>, StorageOperationStatus> getLatestVersionNotAbstractToscaElementsMetadataOnly(boolean isAbstract,
- ComponentTypeEnum componentTypeEnum,
- String internalComponentType,
- VertexTypeEnum vertexType,
- String modelName) {
+ private Either<List<Component>, StorageOperationStatus> getLatestVersionNotAbstractToscaElementsMetadataOnly(final boolean isAbstract,
+ final ComponentTypeEnum componentTypeEnum,
+ final String internalComponentType,
+ final VertexTypeEnum vertexType,
+ final String modelName,
+ final boolean includeNormativeExtensionModels) {
List<Service> services = null;
Map<GraphPropertyEnum, Object> hasProps = new EnumMap<>(GraphPropertyEnum.class);
Map<GraphPropertyEnum, Object> hasNotProps = new EnumMap<>(GraphPropertyEnum.class);
fillPropsMap(hasProps, hasNotProps, internalComponentType, componentTypeEnum, isAbstract, vertexType, modelName);
Either<List<GraphVertex>, JanusGraphOperationStatus> getRes = janusGraphDao
- .getByCriteria(vertexType, hasProps, hasNotProps, JsonParseFlagEnum.ParseMetadata, modelName);
+ .getByCriteria(vertexType, hasProps, hasNotProps, JsonParseFlagEnum.ParseMetadata, modelName, includeNormativeExtensionModels);
if (getRes.isRight() && !JanusGraphOperationStatus.NOT_FOUND.equals(getRes.right().value())) {
return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getRes.right().value()));
}
@@ -2070,7 +2071,7 @@ public class ToscaOperationFacade {
private Either<List<String>, StorageOperationStatus> getComponentUids(boolean isAbstract, ComponentTypeEnum componentTypeEnum,
String internalComponentType) {
Either<List<Component>, StorageOperationStatus> getToscaElementsRes = getLatestVersionNotAbstractMetadataOnly(isAbstract, componentTypeEnum,
- internalComponentType, null);
+ internalComponentType, null, false);
if (getToscaElementsRes.isRight()) {
return Either.right(getToscaElementsRes.right().value());
}
@@ -2214,14 +2215,15 @@ public class ToscaOperationFacade {
}
public Either<List<Component>, StorageOperationStatus> getLatestVersionNotAbstractMetadataOnly(boolean isAbstract,
- ComponentTypeEnum componentTypeEnum,
- String internalComponentType,
- String modelName) {
+ final ComponentTypeEnum componentTypeEnum,
+ final String internalComponentType,
+ final String modelName,
+ final boolean includeNormativeExtensionModels) {
List<VertexTypeEnum> internalVertexTypes = getInternalVertexTypes(componentTypeEnum, internalComponentType);
List<Component> result = new ArrayList<>();
for (VertexTypeEnum vertexType : internalVertexTypes) {
Either<List<Component>, StorageOperationStatus> listByVertexType = getLatestVersionNotAbstractToscaElementsMetadataOnly(isAbstract,
- componentTypeEnum, internalComponentType, vertexType, modelName);
+ componentTypeEnum, internalComponentType, vertexType, modelName, includeNormativeExtensionModels);
if (listByVertexType.isRight()) {
return listByVertexType;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ModelOperationExceptionSupplier.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ModelOperationExceptionSupplier.java
index 6622bf5bd8..68e098bd69 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ModelOperationExceptionSupplier.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ModelOperationExceptionSupplier.java
@@ -52,5 +52,9 @@ public class ModelOperationExceptionSupplier {
var errorMsg = String.format("Failed to retrieve models. Status '%s'", janusGraphOperationStatus);
return () -> new OperationException(ActionStatus.GENERAL_ERROR, errorMsg);
}
+
+ public static Supplier<OperationException> unknownModelType(final String modelType) {
+ return () -> new OperationException(ActionStatus.UNKNOWN_MODEL_TYPE, modelType);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
index ce1f574e93..d522e10d7c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
@@ -46,6 +46,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.jsonjanusgraph.operations.exception.ModelOperationExceptionSupplier;
@@ -83,7 +84,7 @@ public class ModelOperation {
public Model createModel(final Model model, final boolean inTransaction) {
Model result = null;
- final var modelData = new ModelData(model.getName(), UniqueIdBuilder.buildModelUid(model.getName()));
+ final var modelData = new ModelData(model.getName(), UniqueIdBuilder.buildModelUid(model.getName()), model.getModelType());
try {
final Either<ModelData, JanusGraphOperationStatus> createNode = janusGraphGenericDao.createNode(modelData, ModelData.class);
if (createNode.isRight()) {
@@ -97,7 +98,7 @@ public class ModelOperation {
String.format("Failed to create model %s on JanusGraph with %s error", model, janusGraphOperationStatus));
}
addDerivedFromRelation(model);
- result = new Model(createNode.left().value().getName(), model.getDerivedFrom());
+ result = new Model(createNode.left().value().getName(), model.getDerivedFrom(), model.getModelType());
return result;
} finally {
if (!inTransaction) {
@@ -183,6 +184,13 @@ public class ModelOperation {
public List<Model> findAllModels() {
return findModelsByCriteria(Collections.emptyMap());
}
+
+ public List<Model> findModels(final ModelTypeEnum modelType) {
+ final Map<GraphPropertyEnum, Object> propertyCriteria = new EnumMap<>(GraphPropertyEnum.class);
+ propertyCriteria.put(GraphPropertyEnum.MODEL_TYPE, modelType.getValue());
+
+ return findModelsByCriteria(propertyCriteria);
+ }
private List<Model> findModelsByCriteria(final Map<GraphPropertyEnum, Object> propertyCriteria) {
final List<GraphVertex> modelVerticesByCriteria = findModelVerticesByCriteria(propertyCriteria);
@@ -209,7 +217,9 @@ public class ModelOperation {
private Model convertToModel(final GraphVertex modelGraphVertex) {
final String modelName = (String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.NAME);
-
+ final String modelTypeProperty = (String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.MODEL_TYPE);
+ final ModelTypeEnum modelType = StringUtils.isEmpty(modelTypeProperty) ? ModelTypeEnum.NORMATIVE : ModelTypeEnum.findByValue(modelTypeProperty).get();
+
final Either<ImmutablePair<ModelData, GraphEdge>, JanusGraphOperationStatus> parentNode =
janusGraphGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Model), UniqueIdBuilder.buildModelUid(modelName),
GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.Model, ModelData.class);
@@ -221,10 +231,10 @@ public class ModelOperation {
log.error(EcompLoggerErrorCode.DATA_ERROR, this.getClass().getName(), operationException.getMessage());
throw operationException;
}
- return new Model((String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.NAME));
+ return new Model((String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.NAME), modelType);
} else {
final ModelData parentModel = parentNode.left().value().getKey();
- return new Model((String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.NAME), parentModel.getName());
+ return new Model((String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.NAME), parentModel.getName(), modelType);
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/ModelCreateRequest.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/ModelCreateRequest.java
index 685d95e4ab..8c2ee302f7 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/ModelCreateRequest.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/ModelCreateRequest.java
@@ -20,6 +20,7 @@ package org.openecomp.sdc.be.ui.model;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -36,4 +37,7 @@ public class ModelCreateRequest {
private String name;
private String derivedFrom;
+
+ private ModelTypeEnum modelType;
+
}
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);