summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2021-06-24 11:19:45 +0100
committerMichael Morris <michael.morris@est.tech>2021-07-15 13:22:58 +0000
commit4f4f7fb796475bb4a332e798c80438b33ce7712a (patch)
tree88b0f7285acfa2e49c5ba3ad3cc4b04bf9c58dc7 /catalog-be/src/test/java
parent53df976426f8845adf58e8ff9355764343a38549 (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-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java32
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java17
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java4
3 files changed, 21 insertions, 32 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java
index 2baafdc9cb..d3a27a8615 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java
@@ -21,8 +21,16 @@
*/
package org.openecomp.sdc.be.components.impl;
+import static com.google.common.collect.Sets.newHashSet;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
import com.google.common.collect.ImmutableMap;
import fj.data.Either;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -44,17 +52,6 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.PolicyTypeOperation;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-import static com.google.common.collect.Sets.newHashSet;
-import static java.util.Collections.emptyList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.anySet;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class PolicyTypeBusinessLogicTest {
@@ -89,7 +86,7 @@ public class PolicyTypeBusinessLogicTest {
ResponseFormat userNotExistResponse = new ResponseFormat();
when(userValidations.validateUserExists(eq(USER_ID))).thenThrow(new ByResponseFormatComponentException(userNotExistResponse));
try{
- testInstance.getAllPolicyTypes(USER_ID, COMPONENT_TYPE);
+ testInstance.getAllPolicyTypes(USER_ID, COMPONENT_TYPE, null);
}catch(ByResponseFormatComponentException e){
assertThat(e.getResponseFormat()).isSameAs(userNotExistResponse);
}
@@ -98,8 +95,7 @@ public class PolicyTypeBusinessLogicTest {
@Test
public void getAllPolicyTypes_whenExcludePolicyTypesSetIsNull_passNullExcludedTypesSet() {
when(ConfigurationManager.getConfigurationManager().getConfiguration().getExcludedPolicyTypesMapping()).thenCallRealMethod();
- when(policyTypeOperation.getAllPolicyTypes(anySet())).thenReturn(emptyList());
- List<PolicyTypeDefinition> allPolicyTypes = testInstance.getAllPolicyTypes(USER_ID, COMPONENT_TYPE);
+ List<PolicyTypeDefinition> allPolicyTypes = testInstance.getAllPolicyTypes(USER_ID, COMPONENT_TYPE, null);
assertThat(allPolicyTypes).isEmpty();
}
@@ -108,16 +104,16 @@ public class PolicyTypeBusinessLogicTest {
List<PolicyTypeDefinition> policyTypes = Arrays.asList(new PolicyTypeBuilder().setUniqueId("id1").build(),
new PolicyTypeBuilder().setUniqueId("id2").build(),
new PolicyTypeBuilder().setUniqueId("id3").build());
- when(policyTypeOperation.getAllPolicyTypes(EXCLUDED_POLICY_TYPES)).thenReturn(policyTypes);
- List<PolicyTypeDefinition> allPolicyTypes = testInstance.getAllPolicyTypes(USER_ID, COMPONENT_TYPE);
+ when(policyTypeOperation.getAllPolicyTypes(EXCLUDED_POLICY_TYPES, null)).thenReturn(policyTypes);
+ List<PolicyTypeDefinition> allPolicyTypes = testInstance.getAllPolicyTypes(USER_ID, COMPONENT_TYPE, null);
assertThat(allPolicyTypes).isSameAs(policyTypes);
}
@Test
public void getAllPolicyTypes_noPolicyTypes() {
- when(policyTypeOperation.getAllPolicyTypes(EXCLUDED_POLICY_TYPES)).thenThrow(new StorageException(StorageOperationStatus.NOT_FOUND));
+ when(policyTypeOperation.getAllPolicyTypes(EXCLUDED_POLICY_TYPES, null)).thenThrow(new StorageException(StorageOperationStatus.NOT_FOUND));
try {
- testInstance.getAllPolicyTypes(USER_ID, COMPONENT_TYPE);
+ testInstance.getAllPolicyTypes(USER_ID, COMPONENT_TYPE, null);
}catch(StorageException e){
assertThat(e.getStorageOperationStatus()).isSameAs(StorageOperationStatus.NOT_FOUND);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java
index 1e4e56cb0d..e3de541376 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java
@@ -35,7 +35,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Stream;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
@@ -134,9 +133,9 @@ class GroupTypesEndpointTest extends JerseySpringBaseTest {
@BeforeEach
public void before() throws Exception {
super.setUp();
- when(userValidations.validateUserExists(eq(USER_ID))).thenReturn(user);
+ when(userValidations.validateUserExists(USER_ID)).thenReturn(user);
when(
- janusGraphGenericDao.getByCriteriaWithPredicate(eq(NodeTypeEnum.GroupType), any(), eq(GroupTypeData.class)))
+ janusGraphGenericDao.getByCriteriaWithPredicate(eq(NodeTypeEnum.GroupType), any(), eq(GroupTypeData.class), any()))
.thenReturn(Either.left(buildGroupTypeDataList()));
}
@@ -171,16 +170,15 @@ class GroupTypesEndpointTest extends JerseySpringBaseTest {
void getGroupTypes_validUser_Success() {
List<GroupTypeDefinition> testConfigGroupTypes = buildGroupTypesList();
List<GroupTypeDefinition> fetchedGroupTypes = buildGetGroupTypesCall(USER_ID, COMPONENT_TYPE)
- .get(new GenericType<List<GroupTypeDefinition>>() {
- });
+ .get(new GenericType<>() {});
verifyGroupTypesList(testConfigGroupTypes, fetchedGroupTypes);
}
@Test
- void getGroupTypes_whenNoInteranlComponentType_passEmptyAsExcludedTypes() {
+ void getGroupTypes_whenNoInternalComponentType_passEmptyAsExcludedTypes() {
List<GroupTypeDefinition> testConfigGroupTypes = buildGroupTypesList();
List<GroupTypeDefinition> fetchedGroupTypes = buildGetGroupTypesCallNoInternalComponent(USER_ID)
- .get(new GenericType<List<GroupTypeDefinition>>() {
+ .get(new GenericType<>() {
});
verifyGroupTypesList(testConfigGroupTypes, fetchedGroupTypes);
}
@@ -261,9 +259,4 @@ class GroupTypesEndpointTest extends JerseySpringBaseTest {
return asList(gt1, gt2);
}
- private GroupTypeDefinition[] listOfEmptyGroupTypes(int size) {
- return Stream.generate(GroupTypeDefinition::new).limit(size).toArray(GroupTypeDefinition[]::new);
- }
-
-
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java
index 34377b05cb..89d10322ed 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java
@@ -75,7 +75,7 @@ class PolicyTypesEndpointTest extends JerseySpringBaseTest {
@Test
void getPolicyTypes() {
List<PolicyTypeDefinition> policyTypes = buildPolicyTypesList();
- when(policyTypeBusinessLogic.getAllPolicyTypes(USER_ID, COMPONENT_TYPE)).thenReturn(policyTypes);
+ when(policyTypeBusinessLogic.getAllPolicyTypes(USER_ID, COMPONENT_TYPE, null)).thenReturn(policyTypes);
when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.SC_OK));
List<PolicyTypeDefinition> fetchedPolicyTypes = buildGetPolicyTypesCall()
.get(new GenericType<List<PolicyTypeDefinition>>() {
@@ -86,7 +86,7 @@ class PolicyTypesEndpointTest extends JerseySpringBaseTest {
@Test
void getPolicyTypes_whenNoInternalComponent_passNullAsComponentType() {
List<PolicyTypeDefinition> policyTypes = buildPolicyTypesList();
- when(policyTypeBusinessLogic.getAllPolicyTypes(USER_ID, null)).thenReturn(policyTypes);
+ when(policyTypeBusinessLogic.getAllPolicyTypes(USER_ID, null, null)).thenReturn(policyTypes);
when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.SC_OK));
List<PolicyTypeDefinition> fetchedPolicyTypes = buildGetPolicyTypesCallNoInternalComponent()
.get(new GenericType<List<PolicyTypeDefinition>>() {