aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java80
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java16
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java30
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java56
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/test/utils/InterfaceOperationTestUtils.java (renamed from catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java)39
5 files changed, 154 insertions, 67 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 5678a628c5..492f5bf850 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -63,6 +63,8 @@ import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.be.model.jsontitan.operations.InterfaceOperation;
+import org.openecomp.sdc.be.model.jsontitan.utils.InterfaceUtils;
import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.*;
@@ -169,6 +171,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
@Autowired
private CsarBusinessLogic csarBusinessLogic;
+ @Autowired
+ private InterfaceOperation interfaceOperation;
+
+ public void setInterfaceOperation(InterfaceOperation interfaceOperation) {
+ this.interfaceOperation = interfaceOperation;
+ }
+
public LifecycleBusinessLogic getLifecycleBusinessLogic() {
return lifecycleBusinessLogic;
}
@@ -217,6 +226,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
this.applicationDataTypeCache = applicationDataTypeCache;
}
+ public void setInterfaceTypeOperation(IInterfaceLifecycleOperation interfaceTypeOperation) {
+ this.interfaceTypeOperation = interfaceTypeOperation;
+ }
+
/**
* the method returns a list of all the resources that are certified, the
* returned resources are only abstract or only none abstract according to
@@ -3974,6 +3987,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
newResource.setDerivedFrom(null);
}
+ Either<Boolean, ResponseFormat> validateAndUpdateInterfacesEither = validateAndUpdateInterfaces(resourceIdToUpdate, newResource);
+ if (validateAndUpdateInterfacesEither.isRight()) {
+ log.error("failed to validate and update Interfaces");
+ rollbackNeeded = true;
+ throw new ComponentException(validateAndUpdateInterfacesEither.right().value());
+ }
+
Either<Resource, ResponseFormat> dataModelResponse = updateResourceMetadata(resourceIdToUpdate, newResource,
user, currentResource, false, true);
if (dataModelResponse.isRight()) {
@@ -5153,4 +5173,64 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
+ private Either<Boolean, ResponseFormat> validateAndUpdateInterfaces(String resourceId, Resource resourceUpdate) {
+ Either<Resource, StorageOperationStatus> resourceStorageOperationStatusEither =
+ toscaOperationFacade.getToscaElement(resourceId);
+ if (resourceStorageOperationStatusEither.isRight()) {
+ StorageOperationStatus errorStatus = resourceStorageOperationStatusEither.right().value();
+ log.error("Failed to fetch resource information by resource id {}, error {}", resourceId, errorStatus);
+ return Either.right(componentsUtils
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(errorStatus)));
+ }
+
+ Resource storedResource = resourceStorageOperationStatusEither.left().value();
+ Map<String, InterfaceDefinition> storedResourceInterfaces = storedResource.getInterfaces();
+
+ if(!storedResource.getName().equals(resourceUpdate.getName()) ) {
+ Collection<InterfaceDefinition> interfaceDefinitionListFromToscaName = InterfaceUtils
+ .getInterfaceDefinitionListFromToscaName(storedResource.getInterfaces().values(),
+ storedResource.getName());
+
+ for (InterfaceDefinition interfaceDefinition : storedResourceInterfaces.values()) {
+ Either<InterfaceDefinition, ResponseFormat> updateInterfaceDefinitionEither = updateInterfaceDefinition(resourceUpdate,
+ interfaceDefinition,
+ interfaceDefinitionListFromToscaName);
+ if(updateInterfaceDefinitionEither.isRight()) {
+ return Either.right(updateInterfaceDefinitionEither.right().value());
+ }
+ }
+ }
+
+ return Either.left(Boolean.TRUE);
+ }
+
+ private Either<InterfaceDefinition, ResponseFormat > updateInterfaceDefinition(Resource resourceUpdate,
+ InterfaceDefinition interfaceDefinition,
+ Collection<InterfaceDefinition> interfaceDefinitionListFromToscaName) {
+ interfaceDefinitionListFromToscaName.forEach(interfaceDefinitionFromList -> {
+ if(interfaceDefinitionFromList.getToscaResourceName().equals(interfaceDefinition.getToscaResourceName())) {
+ log.info("Going to Update interface definition toscaResourceName {} to {}",
+ interfaceDefinitionFromList.getToscaResourceName(),
+ InterfaceUtils.createInterfaceToscaResourceName(resourceUpdate.getName()));
+ interfaceDefinition.setToscaResourceName(InterfaceUtils
+ .createInterfaceToscaResourceName(resourceUpdate.getName()));
+ }
+ } );
+ try {
+ Either<InterfaceDefinition, StorageOperationStatus> interfaceUpdate = interfaceOperation
+ .updateInterface(resourceUpdate.getUniqueId(), interfaceDefinition);
+ if (interfaceUpdate.isRight()) {
+ log.error("Failed to Update interface {}. Response is {}. ", resourceUpdate.getName(), interfaceUpdate.right().value());
+ titanDao.rollback();
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(interfaceUpdate.right().value(), ComponentTypeEnum.RESOURCE)));
+ }
+ } catch (Exception e) {
+ log.error("Exception occurred during update interface toscaResourceName : {}", e);
+ titanDao.rollback();
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+
+ return Either.left( interfaceDefinition);
+ }
+
} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
index 5df58cf6d9..dd67921970 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
@@ -25,7 +25,7 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
-import org.openecomp.sdc.be.components.InterfaceOperationTestUtils;
+import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
import org.openecomp.sdc.be.components.validation.InterfaceOperationValidation;
import org.openecomp.sdc.be.components.validation.UserValidations;
@@ -65,7 +65,7 @@ import java.util.stream.Stream;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.when;
-public class InterfaceOperationBusinessLogicTest implements InterfaceOperationTestUtils{
+public class InterfaceOperationBusinessLogicTest {
public static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
public static final String RESOURCE_SUBCATEGORY = "Router";
@@ -169,11 +169,11 @@ public class InterfaceOperationBusinessLogicTest implements InterfaceOperationTe
//InterfaceOperation
when(operationValidator.validateInterfaceOperations(anyCollection(), anyString(), anyBoolean())).thenReturn(Either.left(true));
- when(interfaceOperation.addInterface(anyString(), anyObject())).thenReturn(Either.left(mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
- when(interfaceOperation.updateInterface(anyString(), anyObject())).thenReturn(Either.left(mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
+ when(interfaceOperation.addInterface(anyString(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
+ when(interfaceOperation.updateInterface(anyString(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
when(interfaceOperation.deleteInterface(anyObject(), anyObject())).thenReturn(Either.left(new HashSet<>()));
when(interfaceOperation.deleteInterface(any(),any())).thenReturn(Either.left(new HashSet<>()));
- when(interfaceOperation.updateInterface(any(),any())).thenReturn(Either.left(mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
+ when(interfaceOperation.updateInterface(any(),any())).thenReturn(Either.left(InterfaceOperationTestUtils.mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
when(mockTitanDao.commit()).thenReturn(TitanOperationStatus.OK);
// BL object
@@ -293,7 +293,7 @@ public class InterfaceOperationBusinessLogicTest implements InterfaceOperationTe
Map<String, Operation> operationMap = new HashMap<>();
Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
- interfaceDefinitionMap.put("int1", createInterface("int1", "Interface 1",
+ interfaceDefinitionMap.put("int1", InterfaceOperationTestUtils.createInterface("int1", "Interface 1",
"lifecycle", "org.openecomp.interfaces.node.lifecycle." + RESOURCE_NAME, operationMap));
resource.setInterfaces(interfaceDefinitionMap);
List<InputDefinition> inputDefinitionList = new ArrayList<>();
@@ -315,7 +315,7 @@ public class InterfaceOperationBusinessLogicTest implements InterfaceOperationTe
resource.setName(RESOURCE_NAME);
resource.addCategory(RESOURCE_CATEGORY1, RESOURCE_SUBCATEGORY);
resource.setDescription("My short description");
- resource.setInterfaces(createMockInterfaceDefinition(RESOURCE_NAME));
+ resource.setInterfaces(InterfaceOperationTestUtils.createMockInterfaceDefinition(RESOURCE_NAME));
List<InputDefinition> inputDefinitionList = new ArrayList<>();
inputDefinitionList.add(createInputDefinition("uniqueId1"));
@@ -338,7 +338,7 @@ public class InterfaceOperationBusinessLogicTest implements InterfaceOperationTe
resource.setName(RESOURCE_NAME);
resource.addCategory(RESOURCE_CATEGORY1, RESOURCE_SUBCATEGORY);
resource.setDescription("Resource name for response");
- resource.setInterfaces(createMockInterfaceDefinition(RESOURCE_NAME));
+ resource.setInterfaces(InterfaceOperationTestUtils.createMockInterfaceDefinition(RESOURCE_NAME));
return resource;
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
index f8ece0ba76..f7e95867ec 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
@@ -23,25 +23,25 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarInfo;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
-import org.openecomp.sdc.be.components.impl.ImportUtilsTest;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -57,12 +57,14 @@ import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
+import org.openecomp.sdc.be.model.jsontitan.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.CacheMangerOperation;
import org.openecomp.sdc.be.model.operations.impl.CsarOperation;
@@ -96,9 +98,6 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -117,10 +116,8 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.when;
public class ResourceBusinessLogicTest {
@@ -130,6 +127,10 @@ public class ResourceBusinessLogicTest {
private static final String UPDATED_SUBCATEGORY = "Gateway";
+ private String resourceId = "resourceId1";
+ private String operationId = "uniqueId1";
+ Resource resourceUpdate;
+
private static final String RESOURCE_NAME = "My-Resource_Name with space";
private static final String RESOURCE_TOSCA_NAME = "My-Resource_Tosca_Name";
private static final String GENERIC_VF_NAME = "org.openecomp.resource.abstract.nodes.VF";
@@ -151,6 +152,9 @@ public class ResourceBusinessLogicTest {
WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
UserValidations userValidations = Mockito.mock(UserValidations.class);
WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
+ IInterfaceLifecycleOperation interfaceTypeOperation = Mockito.mock(IInterfaceLifecycleOperation.class);
+ InterfaceOperation interfaceOperation = Mockito.mock(InterfaceOperation.class);
+
@InjectMocks
ResourceBusinessLogic bl = new ResourceBusinessLogic();
ResponseFormatManager responseManager = null;
@@ -218,7 +222,7 @@ public class ResourceBusinessLogicTest {
/*when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.VF, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);
when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.PNF, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);
when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.CR, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount);*/
-
+ when(interfaceOperation.updateInterface(anyString(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
@@ -234,6 +238,7 @@ public class ResourceBusinessLogicTest {
when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(eitherCreate);
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<>();
when(applicationDataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
+ when(mockTitanDao.commit()).thenReturn(TitanOperationStatus.OK);
// BL object
artifactManager.setNodeTemplateOperation(nodeTemplateOperation);
@@ -254,6 +259,9 @@ public class ResourceBusinessLogicTest {
toscaOperationFacade.setTopologyTemplateOperation(topologyTemplateOperation);
bl.setToscaOperationFacade(toscaOperationFacade);
bl.setUserValidations(userValidations);
+ bl.setInterfaceTypeOperation(interfaceTypeOperation);
+ bl.setInterfaceOperation(interfaceOperation);
+
csarBusinessLogic.setCsarOperation(csarOperation);
Resource resourceCsar = createResourceObjectCsar(true);
setCanWorkOnResource(resourceCsar);
@@ -352,7 +360,8 @@ public class ResourceBusinessLogicTest {
when(toscaOperationFacade.getLatestComponentByCsarOrName(ComponentTypeEnum.RESOURCE, resource.getCsarUUID(), resource.getSystemName())).thenReturn(resourceLinkedToCsarRes);
Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
-
+ Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
+ when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
Resource createdResource = null;
@@ -921,6 +930,7 @@ public class ResourceBusinessLogicTest {
@Test
public void testResourceNameWrongFormat_UPDATE() {
Resource resource = createResourceObject(true);
+ resource.setInterfaces(InterfaceOperationTestUtils.createMockInterfaceDefinition(RESOURCE_NAME));
Resource updatedResource = createResourceObject(true);
// this is in order to prevent failing with 403 earlier
@@ -942,6 +952,7 @@ public class ResourceBusinessLogicTest {
@Test
public void testResourceNameAfterCertify_UPDATE() {
Resource resource = createResourceObject(true);
+ resource.setInterfaces(InterfaceOperationTestUtils.createMockInterfaceDefinition(RESOURCE_NAME));
Resource updatedResource = createResourceObject(true);
// this is in order to prevent failing with 403 earlier
@@ -965,6 +976,7 @@ public class ResourceBusinessLogicTest {
@Test
public void testResourceNameAlreadyExist_UPDATE() {
Resource resource = createResourceObject(true);
+ resource.setInterfaces(InterfaceOperationTestUtils.createMockInterfaceDefinition(RESOURCE_NAME));
Resource updatedResource = createResourceObject(true);
// this is in order to prevent failing with 403 earlier
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
index a1944f44bc..3d3447d88b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
@@ -25,7 +25,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.be.components.InterfaceOperationTestUtils;
+import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
@@ -43,7 +43,7 @@ import java.util.Set;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-public class InterfaceOperationValidationTest implements InterfaceOperationTestUtils {
+public class InterfaceOperationValidationTest {
private Resource resource = (Resource) getToscaFullElement().left().value();
@@ -69,8 +69,8 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testValidInterfaceOperation() {
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"upgrade");
@@ -81,8 +81,8 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationDescriptionLength() {
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2 - The Spring Initializer provides a project generator to make you " +
"productive with the certain technology stack from the beginning. You can create a skeleton project" +
@@ -97,8 +97,8 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationForEmptyType() {
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList, "");
@@ -109,8 +109,8 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationForEmptyInputParam() {
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"input2");
@@ -121,8 +121,8 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationForNonUniqueType() {
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"CREATE");
@@ -133,8 +133,8 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationTypeLength() {
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,
@@ -149,11 +149,11 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationUniqueInputParamNameInvalid() {
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationInputDefinitionList.add(createMockOperationInputDefinition("label2"));
- operationInputDefinitionList.add(createMockOperationInputDefinition("label2"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label2"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label2"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"create");
@@ -165,9 +165,9 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationUniqueInputParamNameValid() {
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationInputDefinitionList.add(createMockOperationInputDefinition("label2"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label2"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"update");
@@ -180,9 +180,9 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationeInputParamNameEmpty() {
- operationInputDefinitionList.add(createMockOperationInputDefinition(" "));
- operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
- operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition(" "));
+ operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"update");
@@ -196,7 +196,7 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
private Set<Operation> createInterfaceOperationData( String uniqueID, String description, ArtifactDefinition artifactDefinition,
ListDataDefinition<OperationInputDefinition> inputs,
ListDataDefinition<OperationOutputDefinition> outputs, String name) {
- return Sets.newHashSet(createInterfaceOperation(uniqueID, description, artifactDefinition, inputs, outputs, name));
+ return Sets.newHashSet(InterfaceOperationTestUtils.createInterfaceOperation(uniqueID, description, artifactDefinition, inputs, outputs, name));
}
private <T extends Component> Either<T, StorageOperationStatus> getToscaFullElement() {
@@ -212,9 +212,9 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
}
private Map<String, InterfaceDefinition> createMockInterfaceDefinition() {
- Map<String, Operation> operationMap = createMockOperationMap();
+ Map<String, Operation> operationMap = InterfaceOperationTestUtils.createMockOperationMap();
Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
- interfaceDefinitionMap.put("int1", createInterface("int1", "Interface 1",
+ interfaceDefinitionMap.put("int1", InterfaceOperationTestUtils.createInterface("int1", "Interface 1",
"lifecycle", "tosca", operationMap));
return interfaceDefinitionMap;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java b/catalog-be/src/test/java/org/openecomp/sdc/test/utils/InterfaceOperationTestUtils.java
index 589e8be62b..d5bb4b36c6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/test/utils/InterfaceOperationTestUtils.java
@@ -14,8 +14,10 @@
* limitations under the License.
*/
-package org.openecomp.sdc.be.components;
+package org.openecomp.sdc.test.utils;
+import java.util.HashMap;
+import java.util.Map;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition;
@@ -23,13 +25,10 @@ import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Operation;
-import java.util.HashMap;
-import java.util.Map;
-
-public interface InterfaceOperationTestUtils {
+public class InterfaceOperationTestUtils {
- default InterfaceDefinition createInterface(String uniqueID, String description, String type,
- String toscaResourceName, Map<String, Operation> op) {
+ public static InterfaceDefinition createInterface(String uniqueID, String description, String type,
+ String toscaResourceName, Map<String, Operation> op) {
InterfaceDefinition id = new InterfaceDefinition();
id.setType(type);
id.setDescription(description);
@@ -38,31 +37,28 @@ public interface InterfaceOperationTestUtils {
id.setOperationsMap(op);
return id;
}
- default InterfaceDefinition mockInterfaceDefinitionToReturn(String resourceNamme) {
+
+ public static InterfaceDefinition mockInterfaceDefinitionToReturn(String resourceNamme) {
Map<String, Operation> operationMap = createMockOperationMap();
return createInterface("int1", "Interface 1",
- "lifecycle", "org.openecomp.interfaces.node.lifecycle." + resourceNamme, operationMap);
+ "lifecycle", "org.openecomp.interfaces.node.lifecycle." + resourceNamme, operationMap);
}
-
-
- default Operation createInterfaceOperation(String uniqueID, String description, ArtifactDefinition artifactDefinition,
- ListDataDefinition<OperationInputDefinition> inputs,
- ListDataDefinition<OperationOutputDefinition> outputs, String name) {
+ public static Operation createInterfaceOperation(String uniqueID, String description, ArtifactDefinition artifactDefinition,
+ ListDataDefinition<OperationInputDefinition> inputs,
+ ListDataDefinition<OperationOutputDefinition> outputs, String name) {
Operation operation = new Operation();
-
operation.setUniqueId(uniqueID);
operation.setDescription(description);
operation.setImplementation(artifactDefinition);
operation.setInputs(inputs);
operation.setOutputs(outputs);
operation.setName(name);
-
return operation;
}
- default Map<String, Operation> createMockOperationMap() {
+ public static Map<String, Operation> createMockOperationMap() {
Operation operation = new Operation();
ListDataDefinition<OperationInputDefinition> operationInputDefinitionList = new ListDataDefinition<>();
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
@@ -86,26 +82,25 @@ public interface InterfaceOperationTestUtils {
return operationMap;
}
-
- default OperationInputDefinition createMockOperationInputDefinition(String name) {
+ public static OperationInputDefinition createMockOperationInputDefinition(String name) {
OperationInputDefinition operationInputDefinition = new OperationInputDefinition();
operationInputDefinition.setName(name);
operationInputDefinition.setUniqueId("uniqueId1");
return operationInputDefinition;
}
- default OperationOutputDefinition createMockOperationOutputDefinition(String name) {
+ public static OperationOutputDefinition createMockOperationOutputDefinition(String name) {
OperationOutputDefinition operationOutputDefinition = new OperationOutputDefinition();
operationOutputDefinition.setName(name);
operationOutputDefinition.setUniqueId("uniqueId1");
return operationOutputDefinition;
}
- default Map<String, InterfaceDefinition> createMockInterfaceDefinition(String resourceName) {
+ public static Map<String, InterfaceDefinition> createMockInterfaceDefinition(String resourceName) {
Map<String, Operation> operationMap = createMockOperationMap();
Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
interfaceDefinitionMap.put("int1", createInterface("int1", "Interface 1",
- "lifecycle", "org.openecomp.interfaces.node.lifecycle." + resourceName, operationMap));
+ "lifecycle", "org.openecomp.interfaces.node.lifecycle." + resourceName, operationMap));
return interfaceDefinitionMap;
}