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 --- .../operations/impl/GroupTypeOperationTest.java | 24 +++++++++------------- .../operations/impl/PolicyTypeOperationTest.java | 20 +++++++++--------- 2 files changed, 20 insertions(+), 24 deletions(-) (limited to 'catalog-model/src/test/java/org') 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