From 4959218f8ced87d458151d14a38891b1fdc70c7d Mon Sep 17 00:00:00 2001 From: KrupaNagabhushan Date: Mon, 26 Jul 2021 12:50:21 +0100 Subject: Consider component model when retrieving group and policy types Issue-ID: SDC-3659 Signed-off-by: KrupaNagabhushan Change-Id: I6d58e51e70085adf114e6efd0c29b00b14358b39 --- .../model/operations/api/IGroupTypeOperation.java | 8 +-- .../model/operations/api/IPolicyTypeOperation.java | 2 +- .../model/operations/impl/GroupTypeOperation.java | 68 ++++++++++------------ .../model/operations/impl/PolicyTypeOperation.java | 43 ++++++-------- .../operations/impl/GroupTypeOperationTest.java | 24 ++++---- .../operations/impl/PolicyTypeOperationTest.java | 20 +++---- 6 files changed, 73 insertions(+), 92 deletions(-) (limited to 'catalog-model/src') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IGroupTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IGroupTypeOperation.java index d601a2fd49..62f51210f4 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IGroupTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IGroupTypeOperation.java @@ -32,11 +32,11 @@ public interface IGroupTypeOperation { Either getGroupType(String uniqueId, boolean inTransaction); - Either getLatestGroupTypeByType(String name); + Either getLatestGroupTypeByType(String name, String model); - Either getLatestGroupTypeByType(String name, boolean inTransaction); + Either getLatestGroupTypeByType(String name, String model, boolean inTransaction); - Either getGroupTypeByTypeAndVersion(String name, String version); + Either getGroupTypeByTypeAndVersion(String name, String version, String model); - Either getGroupTypeByTypeAndVersion(String name, String version, boolean inTransaction); + Either getGroupTypeByTypeAndVersion(String name, String version, String model, boolean inTransaction); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IPolicyTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IPolicyTypeOperation.java index bba124ec0d..fce683e52f 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IPolicyTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IPolicyTypeOperation.java @@ -26,7 +26,7 @@ import org.openecomp.sdc.be.model.PolicyTypeDefinition; public interface IPolicyTypeOperation { - Either getLatestPolicyTypeByType(String policyTypeName); + Either getLatestPolicyTypeByType(String policyTypeName, String modelName); Either addPolicyType(PolicyTypeDefinition policyType); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java index 7cf0d29a13..621ba97cb3 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java @@ -20,7 +20,6 @@ package org.openecomp.sdc.be.model.operations.impl; import static org.openecomp.sdc.be.dao.janusgraph.JanusGraphUtils.buildNotInPredicate; -import static org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR; import com.google.common.base.Strings; import fj.data.Either; @@ -30,6 +29,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -312,41 +312,19 @@ public class GroupTypeOperation implements IGroupTypeOperation { } } - public Either getLatestGroupTypeByType(String type) { - return getLatestGroupTypeByType(type, true); + public Either getLatestGroupTypeByType(String type, String model) { + return getLatestGroupTypeByType(type, model, true); } - public Either getLatestGroupTypeByType(String type, boolean inTransaction) { + public Either getLatestGroupTypeByType(String type, String model, boolean inTransaction) { Map mapCriteria = new HashMap<>(); mapCriteria.put(GraphPropertiesDictionary.TYPE.getProperty(), type); mapCriteria.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true); - return getGroupTypeByCriteria(type, mapCriteria, inTransaction); - } - - public Either getLatestGroupTypeByType(final String groupType, final String model) { - final Either groupTypeRes = janusGraphGenericDao - .getNode(GraphPropertiesDictionary.TYPE.getProperty(), groupType, GroupTypeData.class, model); - if (groupTypeRes.isRight()) { - final JanusGraphOperationStatus status = groupTypeRes.right().value(); - log.error("GroupTypeData cannot be found in graph. status is {}", status); - return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)); - } - Either groupTypeDefinition = getGroupTypeByUid(groupTypeRes.left().value().getUniqueId()); - if (groupTypeDefinition.isRight()) { - final StorageOperationStatus status = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(groupTypeRes.right().value()); - log.error("GroupTypeDefinition cannot be found in graph. status is {}", status); - return Either.right(status); - } - final Either, JanusGraphOperationStatus> modelName = janusGraphGenericDao.getParentNode( - UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.PolicyType), groupTypeRes.left().value().getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, - NodeTypeEnum.Model, ModelData.class); - if (modelName.isLeft()) { - groupTypeDefinition.left().value().setModel(modelName.left().value().getLeft().getName()); - } - return groupTypeDefinition; + return getGroupTypeByCriteria(type, mapCriteria, model, inTransaction); } public Either getGroupTypeByCriteria(String type, Map properties, + String model, boolean inTransaction) { Either result = null; try { @@ -355,8 +333,8 @@ public class GroupTypeOperation implements IGroupTypeOperation { result = Either.right(StorageOperationStatus.INVALID_ID); return result; } - Either, StorageOperationStatus> groupTypeEither = janusGraphGenericDao - .getByCriteria(NodeTypeEnum.GroupType, properties, GroupTypeData.class).right() + Either, StorageOperationStatus> groupTypeEither = janusGraphGenericDao + .getByCriteriaForModel(NodeTypeEnum.GroupType, properties, model, GroupTypeData.class).right() .map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus); if (groupTypeEither.isRight()) { result = Either.right(groupTypeEither.right().value()); @@ -373,10 +351,24 @@ public class GroupTypeOperation implements IGroupTypeOperation { private Either buildGroupTypeDefinition(String uniqueId, GroupTypeData groupTypeNode) { GroupTypeDefinition groupType = new GroupTypeDefinition(groupTypeNode.getGroupTypeDataDefinition()); + Optional modelName = getAssociatedModelName(uniqueId); + if(modelName.isPresent()) { + groupType.setModel(modelName.get()); + } return fillDerivedFrom(uniqueId, groupType).left().map(derivedFrom -> fillProperties(uniqueId, groupType, derivedFrom)).left() .bind(props -> fillCapabilities(uniqueId, groupType)); } + public Optional getAssociatedModelName(String uniqueId) { + final Either, JanusGraphOperationStatus> modelName = janusGraphGenericDao.getParentNode( + UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.GroupType), uniqueId, GraphEdgeLabels.MODEL_ELEMENT, + NodeTypeEnum.Model, ModelData.class); + if(modelName.isRight()) { + return Optional.empty(); + } + return Optional.ofNullable(modelName.left().value().getLeft().getName()); + } + private Either fillCapabilities(String uniqueId, GroupTypeDefinition groupType) { return getCapablities(uniqueId).left().map(capabilities -> { groupType.setCapabilities(asCapabilitiesMap(capabilities)); @@ -436,15 +428,15 @@ public class GroupTypeOperation implements IGroupTypeOperation { return derivedFrom; } - public Either getGroupTypeByTypeAndVersion(String type, String version) { - return getGroupTypeByTypeAndVersion(type, version, false); + public Either getGroupTypeByTypeAndVersion(String type, String version, String model) { + return getGroupTypeByTypeAndVersion(type, version, model, false); } - public Either getGroupTypeByTypeAndVersion(String type, String version, boolean inTransaction) { + public Either getGroupTypeByTypeAndVersion(String type, String version, String model, boolean inTransaction) { Map mapCriteria = new HashMap<>(); mapCriteria.put(GraphPropertiesDictionary.TYPE.getProperty(), type); mapCriteria.put(GraphPropertiesDictionary.VERSION.getProperty(), version); - return getGroupTypeByCriteria(type, mapCriteria, inTransaction); + return getGroupTypeByCriteria(type, mapCriteria, model, inTransaction); } /** @@ -618,7 +610,7 @@ public class GroupTypeOperation implements IGroupTypeOperation { String groupTypeId = updatedGroupType.getUniqueId(); if (StringUtils.equals(updatedGroupType.getDerivedFrom(), currDerivedFromGroupType)) { return Strings.isNullOrEmpty(currDerivedFromGroupType) ? Either.right(StorageOperationStatus.OK) - : getLatestGroupTypeByType(currDerivedFromGroupType, true).left().map(def -> null); + : getLatestGroupTypeByType(currDerivedFromGroupType, updatedGroupType.getModel()).left().map(def -> null); } StorageOperationStatus status = isLegalToReplaceParent(currDerivedFromGroupType, updatedGroupType.getDerivedFrom(), updatedGroupType.getType()); @@ -628,7 +620,7 @@ public class GroupTypeOperation implements IGroupTypeOperation { log.debug( "#updateGroupDerivedFrom - updating group derived from relation for group type with id {}. old derived type {}. new derived type {}", groupTypeId, currDerivedFromGroupType, updatedGroupType.getDerivedFrom()); - StorageOperationStatus deleteDerivedRelationStatus = deleteDerivedFromGroupType(groupTypeId, currDerivedFromGroupType); + StorageOperationStatus deleteDerivedRelationStatus = deleteDerivedFromGroupType(groupTypeId, currDerivedFromGroupType, updatedGroupType.getModel()); if (deleteDerivedRelationStatus != StorageOperationStatus.OK) { return Either.right(deleteDerivedRelationStatus); } @@ -651,13 +643,13 @@ public class GroupTypeOperation implements IGroupTypeOperation { derivedFromGroup -> derivedFromOperation.addDerivedFromRelation(gtUniqueId, derivedFromGroup.getUniqueId(), NodeTypeEnum.GroupType)); } - private StorageOperationStatus deleteDerivedFromGroupType(String groupTypeId, String derivedFromType) { + private StorageOperationStatus deleteDerivedFromGroupType(String groupTypeId, String derivedFromType, String model) { if (derivedFromType == null) { return StorageOperationStatus.OK; } log.debug("#deleteDerivedFromGroupType - deleting derivedFrom relation for group type with id {} and its derived type {}", groupTypeId, derivedFromType); - return getLatestGroupTypeByType(derivedFromType, true).either( + return getLatestGroupTypeByType(derivedFromType, model).either( derivedFromNode -> derivedFromOperation.removeDerivedFromRelation(groupTypeId, derivedFromNode.getUniqueId(), NodeTypeEnum.GroupType), err -> err); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java index 9bc4cfc4b8..99a284168e 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperation.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -66,35 +67,23 @@ public class PolicyTypeOperation extends AbstractOperation implements IPolicyTyp @Autowired private OperationUtils operationUtils; + @Override - public Either getLatestPolicyTypeByType(String type) { + public Either getLatestPolicyTypeByType(String type, String model) { Map mapCriteria = new HashMap<>(); mapCriteria.put(GraphPropertiesDictionary.TYPE.getProperty(), type); mapCriteria.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true); - return getPolicyTypeByCriteria(type, mapCriteria); + return getPolicyTypeByCriteria(type, mapCriteria, model); } - public Either getLatestPolicyTypeByType(String type, String model) { - final Either policyTypesRes = janusGraphGenericDao - .getNode(GraphPropertiesDictionary.TYPE.getProperty(), type, PolicyTypeData.class, model); - if (policyTypesRes.isRight()) { - final StorageOperationStatus status = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(policyTypesRes.right().value()); - log.error("PolicyTypeData cannot be found in graph. status is {}", status); - return Either.right(status); - } - Either policyTypeDefinition = getPolicyTypeByUid(policyTypesRes.left().value().getUniqueId()); - if (policyTypeDefinition.isRight()) { - final StorageOperationStatus status = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(policyTypesRes.right().value()); - log.error("PolicyTypeDefinition cannot be found in graph. status is {}", status); - return Either.right(status); - } + public Optional getAssociatedModelName(String uniqueId) { final Either, JanusGraphOperationStatus> modelName = janusGraphGenericDao.getParentNode( - UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.PolicyType), policyTypesRes.left().value().getUniqueId(), GraphEdgeLabels.MODEL_ELEMENT, + UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.PolicyType), uniqueId, GraphEdgeLabels.MODEL_ELEMENT, NodeTypeEnum.Model, ModelData.class); - if (modelName.isLeft()) { - policyTypeDefinition.left().value().setModel(modelName.left().value().getLeft().getName()); + if (modelName.isRight()) { + return Optional.empty(); } - return policyTypeDefinition; + return Optional.ofNullable(modelName.left().value().getLeft().getName()); } @Override @@ -176,7 +165,7 @@ public class PolicyTypeOperation extends AbstractOperation implements IPolicyTyp return janusGraphGenericDao.createRelation(from , to, GraphEdgeLabels.MODEL_ELEMENT, Collections.emptyMap()).right().map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus); } - private Either getPolicyTypeByCriteria(String type, Map properties) { + private Either getPolicyTypeByCriteria(String type, Map properties, String model) { Either result; if (type == null || type.isEmpty()) { log.error("type is empty"); @@ -184,7 +173,7 @@ public class PolicyTypeOperation extends AbstractOperation implements IPolicyTyp return result; } Either, JanusGraphOperationStatus> eitherPolicyData = janusGraphGenericDao - .getByCriteria(NodeTypeEnum.PolicyType, properties, PolicyTypeData.class); + .getByCriteriaForModel(NodeTypeEnum.PolicyType, properties, model, PolicyTypeData.class); if (eitherPolicyData.isRight()) { result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(eitherPolicyData.right().value())); } else { @@ -204,6 +193,10 @@ public class PolicyTypeOperation extends AbstractOperation implements IPolicyTyp private Either createPolicyTypeDefinition(String uniqueId, PolicyTypeData policyTypeNode) { PolicyTypeDefinition policyType = new PolicyTypeDefinition(policyTypeNode.getPolicyTypeDataDefinition()); + Optional modelName = getAssociatedModelName(uniqueId); + if (modelName.isPresent()) { + policyType.setModel(modelName.get()); + } return fillDerivedFrom(uniqueId, policyType).left().map(derivedFrom -> fillProperties(uniqueId, policyType, derivedFrom)).left() .map(props -> policyType); } @@ -294,7 +287,7 @@ public class PolicyTypeOperation extends AbstractOperation implements IPolicyTyp log.debug( "#updatePolicyDerivedFrom - updating policy derived from relation for policy type with id {}. old derived type {}. new derived type {}", policyTypeId, currDerivedFromPolicyType, updatedPolicyType.getDerivedFrom()); - StorageOperationStatus deleteDerivedRelationStatus = deleteDerivedFromPolicyType(policyTypeId, currDerivedFromPolicyType); + StorageOperationStatus deleteDerivedRelationStatus = deleteDerivedFromPolicyType(policyTypeId, currDerivedFromPolicyType, updatedPolicyType.getModel()); if (deleteDerivedRelationStatus != StorageOperationStatus.OK) { return Either.right(deleteDerivedRelationStatus); } @@ -312,13 +305,13 @@ public class PolicyTypeOperation extends AbstractOperation implements IPolicyTyp derivedFromPolicy -> derivedFromOperation.addDerivedFromRelation(ptUniqueId, derivedFromPolicy.getUniqueId(), NodeTypeEnum.PolicyType)); } - private StorageOperationStatus deleteDerivedFromPolicyType(String policyTypeId, String derivedFromType) { + private StorageOperationStatus deleteDerivedFromPolicyType(String policyTypeId, String derivedFromType, String model) { if (derivedFromType == null) { return StorageOperationStatus.OK; } log.debug("#deleteDerivedFromPolicyType - deleting derivedFrom relation for policy type with id {} and its derived type {}", policyTypeId, derivedFromType); - return getLatestPolicyTypeByType(derivedFromType).either( + return getLatestPolicyTypeByType(derivedFromType, model).either( derivedFromNode -> derivedFromOperation.removeDerivedFromRelation(policyTypeId, derivedFromNode.getUniqueId(), NodeTypeEnum.PolicyType), err -> err); } 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 4e4a95d2cc..48202c3ec5 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 @@ -145,7 +145,7 @@ public class GroupTypeOperationTest extends ModelTestBase { assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - addGroupTypeResult = groupTypeOperation.getGroupTypeByTypeAndVersion("org.openecomp.groups.NetworkCollection", "1.0"); + addGroupTypeResult = groupTypeOperation.getGroupTypeByTypeAndVersion("org.openecomp.groups.NetworkCollection", "1.0", null); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); @@ -344,6 +344,7 @@ public class GroupTypeOperationTest extends ModelTestBase { Either updateGroupTypeResult = groupTypeOperation.updateGroupType(newGroupTypeDefinition, addGroupTypeResult.left().value()); assertTrue(updateGroupTypeResult.isRight()); assertEquals(StorageOperationStatus.MATCH_NOT_FOUND, updateGroupTypeResult.right().value()); + } @Test @@ -454,7 +455,7 @@ public class GroupTypeOperationTest extends ModelTestBase { assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); - addGroupTypeResult = groupTypeOperation.getGroupTypeByTypeAndVersion("org.openecomp.groups.PrivateCollection", "1.0"); + addGroupTypeResult = groupTypeOperation.getGroupTypeByTypeAndVersion("org.openecomp.groups.PrivateCollection", "1.0", null); assertTrue("check group type added", addGroupTypeResult.isLeft()); compareBetweenCreatedToSent(groupTypeDefinition, addGroupTypeResult.left().value()); @@ -541,12 +542,7 @@ public class GroupTypeOperationTest extends ModelTestBase { @Test public void testAddGroupTypeWithModel() { - createRootGroupTypeNode(); - - GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition(); - groupTypeDefinition.setDescription("groups l2-networks in network collection"); - groupTypeDefinition.setType("org.openecomp.groups.PrivateCollection"); - groupTypeDefinition.setVersion("1.0"); + GroupTypeDefinition groupTypeDefinition = createGroupTypeDef(); groupTypeDefinition.setModel("testModel"); Model model = new Model("testModel"); modelOperation.createModel(model , true); @@ -554,7 +550,7 @@ public class GroupTypeOperationTest extends ModelTestBase { Either addGroupType = groupTypeOperation.addGroupType(groupTypeDefinition); assertTrue(addGroupType.isLeft()); Either eitherGroupTypeFetched = - groupTypeOperation.getLatestGroupTypeByType(groupTypeDefinition.getType(), groupTypeDefinition.getModel()); + groupTypeOperation.getLatestGroupTypeByType(groupTypeDefinition.getType(), groupTypeDefinition.getModel()); assertTrue(eitherGroupTypeFetched.isLeft()); assertEquals(groupTypeDefinition.getModel(), eitherGroupTypeFetched.left().value().getModel()); } @@ -712,7 +708,7 @@ public class GroupTypeOperationTest extends ModelTestBase { updatedType.setIcon("icon"); groupTypeOperation.updateGroupType(updatedType, currGroupType.left().value()); - Either fetchedUpdatedType = groupTypeOperation.getLatestGroupTypeByType(createdType.getType()); + Either fetchedUpdatedType = groupTypeOperation.getLatestGroupTypeByType(createdType.getType(), createdType.getModel()); GroupTypeDefinition fetchedGroupType = fetchedUpdatedType.left().value(); assertThat(fetchedGroupType.getProperties()).isEmpty(); assertThat(fetchedGroupType) @@ -762,7 +758,7 @@ public class GroupTypeOperationTest extends ModelTestBase { Either currGroupType = groupTypeOperation.addGroupType(groupType1); groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); - Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType()); + Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), groupType1.getModel()); assertThat(latestGroupType.left().value().getDerivedFrom()).isEqualTo(rootGroupType.getType()); verifyDerivedFromNodeEqualsToRootGroupType(rootGroupType, latestGroupType.left().value().getUniqueId()); } @@ -778,7 +774,7 @@ public class GroupTypeOperationTest extends ModelTestBase { Either updateGroupTypeRes = groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); assertThat(updateGroupTypeRes.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND); - Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType()); + Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), groupType1.getModel()); assertThat(latestGroupType.left().value().getDerivedFrom()).isEqualTo(rootGroupType.getType()); } @@ -795,7 +791,7 @@ public class GroupTypeOperationTest extends ModelTestBase { groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); - Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType()); + Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType(), groupType1.getModel()); assertThat(latestGroupType.left().value().getDerivedFrom()).isEqualTo(derivedType1.getType()); } @@ -813,7 +809,7 @@ public class GroupTypeOperationTest extends ModelTestBase { Either updateResult = groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value()); assertThat(updateResult.right().value()).isEqualTo(StorageOperationStatus.GENERAL_ERROR); - Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(updatedGroupType.getType()); + Either latestGroupType = groupTypeOperation.getLatestGroupTypeByType(updatedGroupType.getType(), updatedGroupType.getModel()); assertThat(latestGroupType.left().value().getDerivedFrom()).isEqualTo(rootGroupType.getType()); } 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 e25344f8bb..d849ec647d 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 @@ -107,7 +107,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { @Test public void testGetLatestPolicyTypeByType() { PolicyTypeDefinition policyTypeCreated = policyTypeOperation.addPolicyType(createPolicyTypeDef()).left().value(); - Either eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyTypeCreated.getType()); + Either eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyTypeCreated.getType(), policyTypeCreated.getModel()); assertTrue(eitherPolicyTypeFetched.isLeft()); PolicyTypeDefinition policyTypeFetched = eitherPolicyTypeFetched.left().value(); assertEquals(policyTypeFetched.toString(), policyTypeCreated.toString()); @@ -134,7 +134,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { String derivedFromRootType = rootPolicyType.getType(); PolicyTypeDefinition policyType1 = createPolicyTypeDef("tosca.policies.type1", "desc1", derivedFromRootType); policyTypeOperation.addPolicyType(policyType1); - Either eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType()); + Either eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); assertThat(eitherPolicyTypeFetched.left().value().getDerivedFrom()).isEqualTo(rootPolicyType.getType()); } @@ -145,7 +145,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { PolicyTypeDefinition policyType1 = createPolicyTypeDef("tosca.policies.type1", null, prop1, prop2); PolicyTypeDefinition policyType2 = createPolicyTypeDef("tosca.policies.type2", "desc3", policyType1.getType(), null); addPolicyTypesToDB(policyType1, policyType2); - Either latestPolicyType2 = policyTypeOperation.getLatestPolicyTypeByType(policyType2.getType()); + Either latestPolicyType2 = policyTypeOperation.getLatestPolicyTypeByType(policyType2.getType(), policyType2.getModel()); assertThat(latestPolicyType2.isLeft()).isTrue(); assertThat(latestPolicyType2.left().value().getProperties()) .usingElementComparatorOnFields("defaultValue", "name", "type") @@ -166,7 +166,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { addPolicyTypesToDB(rootPolicyType, policyType1, policyType2, policyType3, policyType4); - Either latestPolicyType3 = policyTypeOperation.getLatestPolicyTypeByType(policyType4.getType()); + Either latestPolicyType3 = policyTypeOperation.getLatestPolicyTypeByType(policyType4.getType(), policyType4.getModel()); assertThat(latestPolicyType3.isLeft()).isTrue(); assertThat(latestPolicyType3.left().value().getProperties()) .usingElementComparatorOnFields("defaultValue", "name", "type") @@ -220,7 +220,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { Either addedPolicyTypeResult = policyTypeOperation.addPolicyType(policyType1); assertThat(addedPolicyTypeResult.isLeft()).isTrue(); - Either fetchedPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType()); + Either fetchedPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); PolicyTypeDefinition fetchedPolicyTypeVal = fetchedPolicyType.left().value(); assertThat(fetchedPolicyTypeVal.getDerivedFrom()).isEqualTo(derivedFromRootType); verifyDerivedFromNodeEqualsToRootPolicyType(rootPolicyType, fetchedPolicyTypeVal.getUniqueId()); @@ -245,7 +245,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { updatedType.setIcon("icon"); policyTypeOperation.updatePolicyType(updatedType, currPolicyType.left().value()); - Either fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(createdType.getType()); + Either fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(createdType.getType(), createdType.getModel()); PolicyTypeDefinition fetchedPolicyType = fetchedUpdatedType.left().value(); assertThat(fetchedPolicyType.getProperties()).isEmpty(); assertThat(fetchedPolicyType) @@ -266,7 +266,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value()); - Either fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(policyType.getType()); + Either fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(policyType.getType(), policyType.getModel()); assertThat(fetchedUpdatedType.left().value().getProperties()) .usingElementComparatorOnFields("name", "defaultValue", "type") .containsExactlyInAnyOrder(updatedProp1, prop3); @@ -282,7 +282,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { Either currPolicyType = policyTypeOperation.addPolicyType(policyType1); policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value()); - Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType()); + Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); assertThat(latestPolicyType.left().value().getDerivedFrom()).isEqualTo(rootPolicyType.getType()); verifyDerivedFromNodeEqualsToRootPolicyType(rootPolicyType, latestPolicyType.left().value().getUniqueId()); } @@ -297,7 +297,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value()); - Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType()); + Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); assertThat(latestPolicyType.left().value().getDerivedFrom()).isNull(); verifyDerivedFromRelationDoesntExist(latestPolicyType.left().value().getUniqueId()); } @@ -315,7 +315,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value()); - Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType()); + Either latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel()); assertThat(latestPolicyType.left().value().getDerivedFrom()).isEqualTo(rootPolicyType.getType()); verifyDerivedFromNodeEqualsToRootPolicyType(rootPolicyType, latestPolicyType.left().value().getUniqueId()); } -- cgit 1.2.3-korg