summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2021-07-26 12:50:21 +0100
committerMichael Morris <michael.morris@est.tech>2021-08-04 15:21:35 +0000
commit4959218f8ced87d458151d14a38891b1fdc70c7d (patch)
treed76430e0ff7862a8401186e635de0ed51bf9bc04 /catalog-model/src/test/java
parent865af7fcb1c1af73498dedaf426ee55e9f373537 (diff)
Consider component model when retrieving group and policy types
Issue-ID: SDC-3659 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: I6d58e51e70085adf114e6efd0c29b00b14358b39
Diffstat (limited to 'catalog-model/src/test/java')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java24
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java20
2 files changed, 20 insertions, 24 deletions
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<GroupTypeDefinition, StorageOperationStatus> 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<GroupTypeDefinition, StorageOperationStatus> addGroupType = groupTypeOperation.addGroupType(groupTypeDefinition);
assertTrue(addGroupType.isLeft());
Either<GroupTypeDefinition, StorageOperationStatus> 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<GroupTypeDefinition, StorageOperationStatus> fetchedUpdatedType = groupTypeOperation.getLatestGroupTypeByType(createdType.getType());
+ Either<GroupTypeDefinition, StorageOperationStatus> 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<GroupTypeDefinition, StorageOperationStatus> currGroupType = groupTypeOperation.addGroupType(groupType1);
groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value());
- Either<GroupTypeDefinition, StorageOperationStatus> latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType());
+ Either<GroupTypeDefinition, StorageOperationStatus> 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<GroupTypeDefinition, StorageOperationStatus> updateGroupTypeRes = groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value());
assertThat(updateGroupTypeRes.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND);
- Either<GroupTypeDefinition, StorageOperationStatus> latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType());
+ Either<GroupTypeDefinition, StorageOperationStatus> 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<GroupTypeDefinition, StorageOperationStatus> latestGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType1.getType());
+ Either<GroupTypeDefinition, StorageOperationStatus> 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<GroupTypeDefinition, StorageOperationStatus> updateResult = groupTypeOperation.updateGroupType(updatedGroupType, currGroupType.left().value());
assertThat(updateResult.right().value()).isEqualTo(StorageOperationStatus.GENERAL_ERROR);
- Either<GroupTypeDefinition, StorageOperationStatus> latestGroupType = groupTypeOperation.getLatestGroupTypeByType(updatedGroupType.getType());
+ Either<GroupTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyTypeCreated.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> eitherPolicyTypeFetched = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> latestPolicyType2 = policyTypeOperation.getLatestPolicyTypeByType(policyType2.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> latestPolicyType3 = policyTypeOperation.getLatestPolicyTypeByType(policyType4.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> addedPolicyTypeResult = policyTypeOperation.addPolicyType(policyType1);
assertThat(addedPolicyTypeResult.isLeft()).isTrue();
- Either<PolicyTypeDefinition, StorageOperationStatus> fetchedPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(createdType.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> fetchedUpdatedType = policyTypeOperation.getLatestPolicyTypeByType(policyType.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> currPolicyType = policyTypeOperation.addPolicyType(policyType1);
policyTypeOperation.updatePolicyType(updatedPolicyType, currPolicyType.left().value());
- Either<PolicyTypeDefinition, StorageOperationStatus> latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> 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<PolicyTypeDefinition, StorageOperationStatus> latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType());
+ Either<PolicyTypeDefinition, StorageOperationStatus> latestPolicyType = policyTypeOperation.getLatestPolicyTypeByType(policyType1.getType(), policyType1.getModel());
assertThat(latestPolicyType.left().value().getDerivedFrom()).isEqualTo(rootPolicyType.getType());
verifyDerivedFromNodeEqualsToRootPolicyType(rootPolicyType, latestPolicyType.left().value().getUniqueId());
}