diff options
author | aribeiro <anderson.ribeiro@est.tech> | 2021-06-24 11:19:45 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-07-15 13:22:58 +0000 |
commit | 4f4f7fb796475bb4a332e798c80438b33ce7712a (patch) | |
tree | 88b0f7285acfa2e49c5ba3ad3cc4b04bf9c58dc7 /catalog-model/src/test/java/org | |
parent | 53df976426f8845adf58e8ff9355764343a38549 (diff) |
Allow only types from selected model in service creation
Issue-ID: SDC-3629
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Change-Id: I98edb8a1133b2df8d884782f3fb2758b42b94158
Diffstat (limited to 'catalog-model/src/test/java/org')
2 files changed, 32 insertions, 25 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 9187604f66..062f668b05 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 @@ -20,11 +20,24 @@ package org.openecomp.sdc.be.model.operations.impl; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphVertex; +import static com.google.common.collect.Sets.newHashSet; +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import fj.data.Either; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.tinkerpop.gremlin.structure.Edge; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphVertex; import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; @@ -36,7 +49,12 @@ 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.NodeTypeEnum; -import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.be.model.CapabilityDefinition; +import org.openecomp.sdc.be.model.CapabilityTypeDefinition; +import org.openecomp.sdc.be.model.ComponentInstanceProperty; +import org.openecomp.sdc.be.model.GroupTypeDefinition; +import org.openecomp.sdc.be.model.ModelTestBase; +import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.tosca.ToscaType; import org.openecomp.sdc.be.resources.data.CapabilityTypeData; @@ -44,18 +62,6 @@ import org.openecomp.sdc.be.resources.data.GroupTypeData; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import static com.google.common.collect.Sets.newHashSet; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.*; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:application-context-test.xml") public class GroupTypeOperationTest extends ModelTestBase { @@ -92,7 +98,7 @@ public class GroupTypeOperationTest extends ModelTestBase { groupTypeOperation.addGroupType(type1); groupTypeOperation.addGroupType(type2); - List<GroupTypeDefinition> allGroupTypesNoExclusion = groupTypeOperation.getAllGroupTypes(null); + List<GroupTypeDefinition> allGroupTypesNoExclusion = groupTypeOperation.getAllGroupTypes(null, null); assertThat(allGroupTypesNoExclusion) .usingElementComparatorOnFields("type", "icon", "name") .containsExactlyInAnyOrder(rootGroupDefinition, type1, type2); @@ -107,7 +113,7 @@ public class GroupTypeOperationTest extends ModelTestBase { groupTypeOperation.addGroupType(type1); groupTypeOperation.addGroupType(type2); - List<GroupTypeDefinition> allGroupTypes = groupTypeOperation.getAllGroupTypes(newHashSet("type1", "type2")); + List<GroupTypeDefinition> allGroupTypes = groupTypeOperation.getAllGroupTypes(newHashSet("type1", "type2"), null); assertThat(allGroupTypes) .usingElementComparatorOnFields("type") .containsExactly(rootGroupDefinition); 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 518de1eb1d..47bc484193 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 @@ -26,29 +26,28 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphVertex; import fj.data.Either; import java.util.Iterator; import java.util.List; import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphVertex; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; +import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao; 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.dao.janusgraph.HealingJanusGraphGenericDao; import org.openecomp.sdc.be.datatypes.elements.PolicyTypeDataDefinition; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.PolicyTypeDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; -import org.openecomp.sdc.be.model.operations.StorageException; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.PolicyTypeData; import org.springframework.beans.factory.annotation.Autowired; @@ -156,9 +155,10 @@ public class PolicyTypeOperationTest extends ModelTestBase { .containsExactlyInAnyOrder(prop1, prop2, prop3); } - @Test(expected = StorageException.class) + @Test public void getAllPolicyTypes_noPolicies() { - policyTypeOperation.getAllPolicyTypes(null); + final List<PolicyTypeDefinition> result = policyTypeOperation.getAllPolicyTypes(null, null); + assertThat(result).isEmpty(); } @Test @@ -166,7 +166,7 @@ public class PolicyTypeOperationTest extends ModelTestBase { PolicyTypeDefinition policyType1 = createPolicyTypeDef(); PolicyTypeDefinition policyType2 = createPolicyTypeDef("tosca.policies.test1", "desc1", "tosca.policies.Root"); addPolicyTypesToDB(policyType1, policyType2); - List<PolicyTypeDefinition> allPolicyTypesWithNoExcluded = policyTypeOperation.getAllPolicyTypes(null); + List<PolicyTypeDefinition> allPolicyTypesWithNoExcluded = policyTypeOperation.getAllPolicyTypes(null, null); assertThat(allPolicyTypesWithNoExcluded).hasSize(2); assertThat(allPolicyTypesWithNoExcluded).usingElementComparatorOnFields("uniqueId", "description", "version", "type") .containsExactlyInAnyOrder(policyType1, policyType2); @@ -180,7 +180,8 @@ public class PolicyTypeOperationTest extends ModelTestBase { policyTypeOperation.addPolicyType(policyType1); policyTypeOperation.addPolicyType(policyType2); policyTypeOperation.addPolicyType(policyType3); - List<PolicyTypeDefinition> allPolicyTypes = policyTypeOperation.getAllPolicyTypes(newHashSet("tosca.policies.test1", "tosca.policies.test2")); + List<PolicyTypeDefinition> allPolicyTypes = policyTypeOperation.getAllPolicyTypes(newHashSet("tosca.policies.test1", "tosca.policies.test2"), + null); assertThat(allPolicyTypes).hasSize(1); assertThat(allPolicyTypes).usingElementComparatorOnFields("type") .containsExactly(policyType1); |