diff options
author | andre.schmid <andre.schmid@est.tech> | 2022-06-20 14:59:26 +0100 |
---|---|---|
committer | andre.schmid <andre.schmid@est.tech> | 2022-06-20 14:59:26 +0100 |
commit | ce3e2816ec3aa034bdef323c1a33b71485e87eb0 (patch) | |
tree | 06a0a2a442c1662dc7e646c7f3217eb390cc4f31 | |
parent | 097ca1640d7fe865649827635118bfa633fed805 (diff) |
Allow to delete an interface operation from VFC
Issue-ID: SDC-4055
Change-Id: I43e79315dce12e2060f8b1dbdfcae29da46fc02e
Signed-off-by: stasys10 <stasys.jurgaitis@est.tech>
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Signed-off-by: andre.schmid <andre.schmid@est.tech>
8 files changed, 352 insertions, 298 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index 10c50566d4..eb3561afc0 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -172,6 +172,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private static final String UPDATE_ARTIFACT = "Update Artifact"; private static final String FOUND_DEPLOYMENT_ARTIFACT = "Found deployment artifact {}"; private static final String VALID_ARTIFACT_LABEL_NAME = "'A-Z', 'a-z', '0-9', '-', '@', '+' and space."; + private final ArtifactTypeOperation artifactTypeOperation; private Gson gson = new GsonBuilder().setPrettyPrinting().create(); @javax.annotation.Resource private IInterfaceLifecycleOperation interfaceLifecycleOperation; @@ -181,7 +182,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private IElementOperation elementOperation; @javax.annotation.Resource private IHeatParametersOperation heatParametersOperation; - private final ArtifactTypeOperation artifactTypeOperation; private ArtifactCassandraDao artifactCassandraDao; private ToscaExportHandler toscaExportUtils; private CsarUtils csarUtils; @@ -3131,7 +3131,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { json.put(Constants.ARTIFACT_GROUP_TYPE, artifactGroupType.getType()); json.put(Constants.REQUIRED_ARTIFACTS, (updatedRequiredArtifacts == null || updatedRequiredArtifacts.isEmpty()) ? new ArrayList<>() : updatedRequiredArtifacts.stream().filter( - e -> e.getType().equals(ArtifactTypeEnum.HEAT_ARTIFACT.getType()) || e.getType().equals(ArtifactTypeEnum.HEAT_NESTED.getType())) + e -> e.getType().equals(ArtifactTypeEnum.HEAT_ARTIFACT.getType()) || e.getType().equals(ArtifactTypeEnum.HEAT_NESTED.getType())) .map(ArtifactTemplateInfo::getFileName).collect(Collectors.toList())); json.put(Constants.ARTIFACT_HEAT_PARAMS, (heatParameters == null || heatParameters.isEmpty()) ? new ArrayList<>() : heatParameters); return json; @@ -3693,7 +3693,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { operation.setImplementation(implementationArtifact); gotInterface.setOperationsMap(operationsMap); Either<List<InterfaceDefinition>, StorageOperationStatus> interfaceDefinitionStorageOperationStatusEither = interfaceOperation - .updateInterfaces(storedComponent.getUniqueId(), Collections.singletonList(gotInterface)); + .updateInterfaces(storedComponent, Collections.singletonList(gotInterface)); if (interfaceDefinitionStorageOperationStatusEither.isRight()) { StorageOperationStatus storageOperationStatus = interfaceDefinitionStorageOperationStatusEither.right().value(); ActionStatus actionStatus = componentsUtils.convertFromStorageResponseForDataType(storageOperationStatus); @@ -4261,6 +4261,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); } + public Map<String, ArtifactTypeDefinition> getAllToscaArtifacts(final String modelName) { + if (StringUtils.isNotEmpty(modelName)) { + artifactTypeOperation.validateModel(modelName); + } + return artifactTypeOperation.getAllArtifactTypes(modelName); + } + public enum ArtifactOperationEnum { CREATE, UPDATE, DELETE, DOWNLOAD, LINK; @@ -4268,11 +4275,4 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return operation == CREATE || operation == LINK; } } - - public Map<String, ArtifactTypeDefinition> getAllToscaArtifacts(final String modelName) { - if (StringUtils.isNotEmpty(modelName)) { - artifactTypeOperation.validateModel(modelName); - } - return artifactTypeOperation.getAllArtifactTypes(modelName); - } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java index 6b861a104e..69f7ee0f88 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java @@ -34,6 +34,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import java.util.Optional; import java.util.UUID; @@ -56,6 +57,7 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.CapabilityDefinition; +import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstanceInterface; import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.InputDefinition; @@ -76,9 +78,8 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -@Component("interfaceOperationBusinessLogic") +@org.springframework.stereotype.Component("interfaceOperationBusinessLogic") public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { private static final Logger LOGGER = LoggerFactory.getLogger(InterfaceOperationBusinessLogic.class); @@ -105,22 +106,22 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { public Either<List<InterfaceDefinition>, ResponseFormat> deleteInterfaceOperation(String componentId, String interfaceId, List<String> operationsToDelete, User user, boolean lock) { validateUserExists(user.getUserId()); - Either<org.openecomp.sdc.be.model.Component, ResponseFormat> componentEither = getComponentDetails(componentId); + Either<Component, ResponseFormat> componentEither = getComponentDetails(componentId); if (componentEither.isRight()) { return Either.right(componentEither.right().value()); } - org.openecomp.sdc.be.model.Component storedComponent = componentEither.left().value(); + Component storedComponent = componentEither.left().value(); lockComponentResult(lock, storedComponent, DELETE_INTERFACE_OPERATION); try { Optional<InterfaceDefinition> optionalInterface = getInterfaceDefinitionFromComponentByInterfaceId(storedComponent, interfaceId); - if (!optionalInterface.isPresent()) { + if (optionalInterface.isEmpty()) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_NOT_FOUND_IN_COMPONENT, interfaceId)); } InterfaceDefinition interfaceDefinition = optionalInterface.get(); Map<String, Operation> operationsCollection = new HashMap<>(); for (String operationId : operationsToDelete) { Optional<Map.Entry<String, Operation>> optionalOperation = getOperationFromInterfaceDefinition(interfaceDefinition, operationId); - if (!optionalOperation.isPresent()) { + if (optionalOperation.isEmpty()) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_OPERATION_NOT_FOUND, storedComponent.getUniqueId())); } Operation storedOperation = optionalOperation.get().getValue(); @@ -130,7 +131,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { return Either.right(validateDeleteOperationContainsNoMappedOutputResponse.right().value()); } String artifactUniqueId = storedOperation.getImplementation().getUniqueId(); - if (!InterfaceOperationUtils.isArtifactInUse(storedComponent, operationId, artifactUniqueId)) { + if (artifactUniqueId != null && !InterfaceOperationUtils.isArtifactInUse(storedComponent, operationId, artifactUniqueId)) { Either<ArtifactDefinition, StorageOperationStatus> getArtifactEither = artifactToscaOperation .getArtifactById(storedComponent.getUniqueId(), artifactUniqueId); if (getArtifactEither.isLeft()) { @@ -155,18 +156,23 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { } } operationsCollection.put(operationId, interfaceDefinition.getOperationsMap().get(operationId)); - interfaceDefinition.getOperations().remove(operationId); + final Optional<String> operationKeyOptional = interfaceDefinition.getOperations().entrySet() + .stream().filter(entry -> operationId.equals(entry.getValue().getUniqueId())) + .map(Entry::getKey).findFirst(); + if (operationKeyOptional.isEmpty()) { + return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_OPERATION_NOT_FOUND, storedComponent.getUniqueId())); + } + interfaceDefinition.getOperations().remove(operationKeyOptional.get()); } - Either<List<InterfaceDefinition>, StorageOperationStatus> deleteOperationEither = interfaceOperation - .updateInterfaces(storedComponent.getUniqueId(), Collections.singletonList(interfaceDefinition)); - if (deleteOperationEither.isRight()) { + final Either<List<InterfaceDefinition>, StorageOperationStatus> updateInterfaceResultEither; + updateInterfaceResultEither = interfaceOperation.updateInterfaces(storedComponent, Collections.singletonList(interfaceDefinition)); + if (updateInterfaceResultEither.isRight()) { janusGraphDao.rollback(); return Either.right(componentsUtils.getResponseFormat( - componentsUtils.convertFromStorageResponse(deleteOperationEither.right().value(), storedComponent.getComponentType()))); + componentsUtils.convertFromStorageResponse(updateInterfaceResultEither.right().value(), storedComponent.getComponentType()))); } if (interfaceDefinition.getOperations().isEmpty()) { - Either<String, StorageOperationStatus> deleteInterfaceEither = interfaceOperation - .deleteInterface(storedComponent.getUniqueId(), interfaceDefinition.getUniqueId()); + final var deleteInterfaceEither = interfaceOperation.deleteInterface(storedComponent, interfaceDefinition.getUniqueId()); if (deleteInterfaceEither.isRight()) { janusGraphDao.rollback(); return Either.right(componentsUtils.getResponseFormat( @@ -187,8 +193,8 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { } } - private Either<org.openecomp.sdc.be.model.Component, ResponseFormat> getComponentDetails(String componentId) { - Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> componentStorageOperationStatusEither = toscaOperationFacade + private Either<Component, ResponseFormat> getComponentDetails(String componentId) { + Either<Component, StorageOperationStatus> componentStorageOperationStatusEither = toscaOperationFacade .getToscaElement(componentId); if (componentStorageOperationStatusEither.isRight()) { return Either.right( @@ -197,7 +203,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { return Either.left(componentStorageOperationStatusEither.left().value()); } - private Either<Boolean, ResponseFormat> lockComponentResult(boolean lock, org.openecomp.sdc.be.model.Component component, String action) { + private Either<Boolean, ResponseFormat> lockComponentResult(boolean lock, Component component, String action) { if (lock) { try { lockComponent(component.getUniqueId(), component, action); @@ -212,11 +218,11 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { public Either<List<InterfaceDefinition>, ResponseFormat> getInterfaceOperation(String componentId, String interfaceId, List<String> operationsToGet, User user, boolean lock) { validateUserExists(user); - Either<org.openecomp.sdc.be.model.Component, ResponseFormat> componentEither = getComponentDetails(componentId); + Either<Component, ResponseFormat> componentEither = getComponentDetails(componentId); if (componentEither.isRight()) { return Either.right(componentEither.right().value()); } - org.openecomp.sdc.be.model.Component storedComponent = componentEither.left().value(); + Component storedComponent = componentEither.left().value(); lockComponentResult(lock, storedComponent, GET_INTERFACE_OPERATION); try { Optional<InterfaceDefinition> optionalInterface = getInterfaceDefinitionFromComponentByInterfaceId(storedComponent, interfaceId); @@ -254,11 +260,11 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { User user, boolean isUpdate, String errorContext, boolean lock) { validateUserExists(user); - Either<org.openecomp.sdc.be.model.Component, ResponseFormat> componentEither = getComponentDetails(componentId); + Either<Component, ResponseFormat> componentEither = getComponentDetails(componentId); if (componentEither.isRight()) { return Either.right(componentEither.right().value()); } - org.openecomp.sdc.be.model.Component storedComponent = componentEither.left().value(); + Component storedComponent = componentEither.left().value(); lockComponentResult(lock, storedComponent, errorContext); Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = getAllInterfaceLifecycleTypes(storedComponent.getModel()); if (interfaceLifecycleTypes.isRight()) { @@ -332,8 +338,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { } interfacesCollection.add(interfaceDef); } - Either<List<InterfaceDefinition>, StorageOperationStatus> addCreateOperationEither = interfaceOperation - .updateInterfaces(storedComponent.getUniqueId(), interfacesCollection); + final var addCreateOperationEither = interfaceOperation.updateInterfaces(storedComponent, interfacesCollection); if (addCreateOperationEither.isRight()) { janusGraphDao.rollback(); return Either.right(componentsUtils.getResponseFormat( @@ -365,7 +370,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { return Either.left(interfaceLifecycleTypes.left().value()); } - private Either<InterfaceDefinition, ResponseFormat> getOrCreateInterfaceDefinition(org.openecomp.sdc.be.model.Component component, + private Either<InterfaceDefinition, ResponseFormat> getOrCreateInterfaceDefinition(Component component, InterfaceDefinition interfaceDefinition, InterfaceDefinition storedInterfaceDef) { if (storedInterfaceDef != null) { @@ -373,8 +378,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { } interfaceDefinition.setUniqueId(UUID.randomUUID().toString()); interfaceDefinition.setToscaResourceName(interfaceDefinition.getType()); - Either<List<InterfaceDefinition>, StorageOperationStatus> interfaceCreateEither = interfaceOperation - .addInterfaces(component.getUniqueId(), Collections.singletonList(interfaceDefinition)); + final var interfaceCreateEither = interfaceOperation.addInterfaces(component, Collections.singletonList(interfaceDefinition)); if (interfaceCreateEither.isRight()) { janusGraphDao.rollback(); return Either.right(componentsUtils @@ -383,13 +387,13 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { return Either.left(interfaceCreateEither.left().value().get(0)); } - private void updateOperationInputDefs(org.openecomp.sdc.be.model.Component component, Collection<Operation> interfaceOperations) { + private void updateOperationInputDefs(Component component, Collection<Operation> interfaceOperations) { interfaceOperations.stream().filter(operation -> Objects.nonNull(operation.getInputs())).forEach( operation -> operation.getInputs().getListToscaDataDefinition() .forEach(inp -> component.getInputs().forEach(in -> updateOperationInputDefinition(component, inp, in)))); } - private void updateOperationInputDefinition(org.openecomp.sdc.be.model.Component component, OperationInputDefinition operationInput, + private void updateOperationInputDefinition(Component component, OperationInputDefinition operationInput, InputDefinition componentInput) { if (operationInput.getInputId().equals(componentInput.getUniqueId())) { //Set the default value, value and schema only for inputs mapped to component inputs @@ -404,7 +408,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { operationInput.setToscaDefaultValue(getInputToscaDefaultValue(operationInput, component)); } - private String getInputToscaDefaultValue(OperationInputDefinition input, org.openecomp.sdc.be.model.Component component) { + private String getInputToscaDefaultValue(OperationInputDefinition input, Component component) { Map<String, List<String>> defaultInputValue = null; if (isOperationInputMappedToComponentInput(input, component.getInputs())) { String propertyName = input.getInputId().substring(input.getInputId().indexOf('.') + 1); @@ -433,7 +437,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { return new Gson().toJson(defaultInputValue); } - private void setParentPropertyTypeAndInputPath(OperationInputDefinition input, org.openecomp.sdc.be.model.Component component) { + private void setParentPropertyTypeAndInputPath(OperationInputDefinition input, Component component) { if (CollectionUtils.isEmpty(component.getInputs())) { return; } @@ -477,18 +481,18 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { public Either<List<OperationInputDefinition>, ResponseFormat> getInputsListForOperation(String componentId, String componentInstanceId, String interfaceId, String operationId, User user) { - Either<org.openecomp.sdc.be.model.Component, ResponseFormat> componentEither = getComponentDetails(componentId); + Either<Component, ResponseFormat> componentEither = getComponentDetails(componentId); if (componentEither.isRight()) { return Either.right(componentEither.right().value()); } - org.openecomp.sdc.be.model.Component storedComponent = componentEither.left().value(); + Component storedComponent = componentEither.left().value(); validateUserExists(user.getUserId()); Either<Boolean, ResponseFormat> lockResult = lockComponentResult(true, storedComponent, GET_INTERFACE_OPERATION); if (lockResult.isRight()) { return Either.right(lockResult.right().value()); } try { - org.openecomp.sdc.be.model.Component parentComponent = componentEither.left().value(); + Component parentComponent = componentEither.left().value(); Map<String, List<ComponentInstanceInterface>> componentInstanceInterfaces = parentComponent.getComponentInstancesInterfaces(); if (MapUtils.isEmpty(componentInstanceInterfaces)) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_OPERATION_NOT_FOUND, componentInstanceId)); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java index 0734bc5ec6..c13a46500f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java @@ -93,8 +93,8 @@ import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; -import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; @@ -146,8 +146,9 @@ import org.openecomp.sdc.exception.ResponseFormat; @RunWith(MockitoJUnitRunner.Silent.class) public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { + public static final Resource resource = Mockito.mock(Resource.class); private static final User USER = new User("John", "Doh", "jh0003", "jh0003@gmail.com", "ADMIN", - System.currentTimeMillis()); + System.currentTimeMillis()); private static final String RESOURCE_INSTANCE_NAME = "Service-111"; private static final String INSTANCE_ID = "S-123-444-ghghghg"; private static final String ARTIFACT_NAME = "service-Myservice-template.yml"; @@ -158,10 +159,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3"; private static final String RESOURCE_SUBCATEGORY = "Router"; private static final String ARTIFACT_PLACEHOLDER_FILE_EXTENSION = "fileExtension"; - public static final Resource resource = Mockito.mock(Resource.class); - - @InjectMocks - private ArtifactsBusinessLogic artifactBL; private static User user = null; private static Resource resourceResponse = null; final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class); @@ -172,6 +169,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { JanusGraphDao mockJanusGraphDao = Mockito.mock(JanusGraphDao.class); @Mock JanusGraphDao janusGraphDao; + @InjectMocks + private ArtifactsBusinessLogic artifactBL; @Mock private UserBusinessLogic userBusinessLogic; @Mock @@ -217,21 +216,21 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { public void initMocks() { MockitoAnnotations.openMocks(this); Either<ArtifactDefinition, StorageOperationStatus> NotFoundResult = Either - .right(StorageOperationStatus.NOT_FOUND); + .right(StorageOperationStatus.NOT_FOUND); Either<Map<String, ArtifactDefinition>, StorageOperationStatus> NotFoundResult2 = Either - .right(StorageOperationStatus.NOT_FOUND); + .right(StorageOperationStatus.NOT_FOUND); when(artifactOperation.getArtifacts(Mockito.anyString(), eq(NodeTypeEnum.Service), Mockito.anyBoolean())) - .thenReturn(NotFoundResult2); + .thenReturn(NotFoundResult2); when(artifactOperation.getArtifacts(Mockito.anyString(), eq(NodeTypeEnum.Resource), Mockito.anyBoolean())) - .thenReturn(NotFoundResult2); + .thenReturn(NotFoundResult2); Either<Map<String, InterfaceDefinition>, StorageOperationStatus> notFoundInterfaces = Either - .right(StorageOperationStatus.NOT_FOUND); + .right(StorageOperationStatus.NOT_FOUND); when(lifecycleOperation.getAllInterfacesOfResource(Mockito.anyString(), Mockito.anyBoolean())) - .thenReturn(notFoundInterfaces); + .thenReturn(notFoundInterfaces); - when(userOperation.getUserData("jh0003", false)).thenReturn(Either.left(USER)); + when(userOperation.getUserData("jh0003", false)).thenReturn(Either.left(USER)); when(elementOperation.getAllArtifactTypes()).thenReturn(getAllTypes()); @@ -254,9 +253,9 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK); Either<Component, StorageOperationStatus> resourceStorageOperationStatusEither = Either - .right(StorageOperationStatus.BAD_REQUEST); + .right(StorageOperationStatus.BAD_REQUEST); when(toscaOperationFacade.getToscaElement(resourceResponse.getUniqueId())) - .thenReturn(resourceStorageOperationStatusEither); + .thenReturn(resourceStorageOperationStatusEither); } @Test @@ -278,7 +277,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { } ArtifactDefinition afterConvert = RepresentationUtils.convertJsonToArtifactDefinition(jsonArtifact, - ArtifactDefinition.class, false); + ArtifactDefinition.class, false); assertEquals(ad, afterConvert); } @@ -330,7 +329,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { ArtifactDefinition origEnvArtifact = new ArtifactDefinition(); ComponentInstance ci = new ComponentInstance(); ci.setUniqueId("ciid"); - ci.setDeploymentArtifacts(fillDeploymentArtifacts(heatArtifact,envArtifact, origEnvArtifact)); + ci.setDeploymentArtifacts(fillDeploymentArtifacts(heatArtifact, envArtifact, origEnvArtifact)); GroupInstance groupInstance = new GroupInstance(); groupInstance.setGroupInstanceArtifacts(new ArrayList<>(Arrays.asList(heatArtifact.getUniqueId(), envArtifact.getUniqueId()))); groupInstance.setCustomizationUUID("custUid"); @@ -342,17 +341,19 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { service.setComponentInstances(Collections.singletonList(ci)); service.setUniqueId("suid"); - when (artifactToscaOperation.updateArtifactOnResource(heatArtifact, service, - heatArtifact.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE.getNodeType(), ci.getUniqueId(), false)).thenReturn(Either.left(heatArtifact)); + when(artifactToscaOperation.updateArtifactOnResource(heatArtifact, service, + heatArtifact.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE.getNodeType(), ci.getUniqueId(), false)).thenReturn( + Either.left(heatArtifact)); when(toscaOperationFacade.generateCustomizationUUIDOnInstance(service.getUniqueId(), ci.getUniqueId())) - .thenReturn(StorageOperationStatus.OK); - when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service),eq(ci.getUniqueId()), any(List.class))) - .thenReturn(Either.left(new ArrayList())); - when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), new ArrayList<>(Arrays.asList("guid")))) - .thenReturn(StorageOperationStatus.OK); - artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE, + .thenReturn(StorageOperationStatus.OK); + when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service), eq(ci.getUniqueId()), any(List.class))) + .thenReturn(Either.left(new ArrayList())); + when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), + new ArrayList<>(Arrays.asList("guid")))) + .thenReturn(StorageOperationStatus.OK); + artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE), - "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); + "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); assertThat(ci.getDeploymentArtifacts().get("HEAT").getTimeout()).isEqualTo(envArtifact.getTimeout()); assertThat(ci.getDeploymentArtifacts().get("HEAT_ENV").getTimeout()).isEqualTo(origEnvArtifact.getTimeout()); } @@ -364,7 +365,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { ArtifactDefinition origEnvArtifact = new ArtifactDefinition(); ComponentInstance ci = new ComponentInstance(); ci.setUniqueId("ciid"); - ci.setDeploymentArtifacts(fillDeploymentArtifacts(heatArtifact,envArtifact, origEnvArtifact)); + ci.setDeploymentArtifacts(fillDeploymentArtifacts(heatArtifact, envArtifact, origEnvArtifact)); GroupInstance groupInstance = new GroupInstance(); groupInstance.setGroupInstanceArtifacts(new ArrayList<>(Arrays.asList(heatArtifact.getUniqueId(), envArtifact.getUniqueId()))); groupInstance.setCustomizationUUID("custUid"); @@ -377,17 +378,20 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { service.setUniqueId("suid"); envArtifact.setTimeout(130); - when (artifactToscaOperation.updateArtifactOnResource(heatArtifact, service, - heatArtifact.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE.getNodeType(), ci.getUniqueId(), false)).thenReturn(Either.left(heatArtifact)); + when(artifactToscaOperation.updateArtifactOnResource(heatArtifact, service, + heatArtifact.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE.getNodeType(), ci.getUniqueId(), false)).thenReturn( + Either.left(heatArtifact)); when(toscaOperationFacade.generateCustomizationUUIDOnInstance(service.getUniqueId(), ci.getUniqueId())) - .thenReturn(StorageOperationStatus.OK); - when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service),eq(ci.getUniqueId()), any(List.class))) - .thenReturn(Either.left(new ArrayList())); - when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), new ArrayList<>(Arrays.asList("guid")))) - .thenReturn(StorageOperationStatus.OK); + .thenReturn(StorageOperationStatus.OK); + when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service), eq(ci.getUniqueId()), any(List.class))) + .thenReturn(Either.left(new ArrayList())); + when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), + new ArrayList<>(Arrays.asList("guid")))) + .thenReturn(StorageOperationStatus.OK); try { - artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE), - "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); + artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, + new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE), + "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); } catch (ComponentException exp) { assertThat(exp.getActionStatus()).isEqualTo(ActionStatus.ARTIFACT_INVALID_TIMEOUT); return; @@ -402,7 +406,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { ArtifactDefinition origEnvArtifact = new ArtifactDefinition(); ComponentInstance ci = new ComponentInstance(); ci.setUniqueId("ciid"); - ci.setDeploymentArtifacts(fillDeploymentArtifacts(heatArtifact,envArtifact, origEnvArtifact)); + ci.setDeploymentArtifacts(fillDeploymentArtifacts(heatArtifact, envArtifact, origEnvArtifact)); GroupInstance groupInstance = new GroupInstance(); groupInstance.setGroupInstanceArtifacts(new ArrayList<>(Arrays.asList(heatArtifact.getUniqueId(), envArtifact.getUniqueId()))); groupInstance.setCustomizationUUID("custUid"); @@ -415,17 +419,20 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { service.setUniqueId("suid"); envArtifact.setTimeout(-1); - when (artifactToscaOperation.updateArtifactOnResource(heatArtifact, service, - heatArtifact.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE.getNodeType(), ci.getUniqueId(), false)).thenReturn(Either.left(heatArtifact)); + when(artifactToscaOperation.updateArtifactOnResource(heatArtifact, service, + heatArtifact.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE.getNodeType(), ci.getUniqueId(), false)).thenReturn( + Either.left(heatArtifact)); when(toscaOperationFacade.generateCustomizationUUIDOnInstance(service.getUniqueId(), ci.getUniqueId())) - .thenReturn(StorageOperationStatus.OK); - when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service),eq(ci.getUniqueId()), any(List.class))) - .thenReturn(Either.left(new ArrayList())); - when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), new ArrayList<>(Arrays.asList("guid")))) - .thenReturn(StorageOperationStatus.OK); + .thenReturn(StorageOperationStatus.OK); + when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service), eq(ci.getUniqueId()), any(List.class))) + .thenReturn(Either.left(new ArrayList())); + when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), + new ArrayList<>(Arrays.asList("guid")))) + .thenReturn(StorageOperationStatus.OK); try { - artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE), - "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); + artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, + new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE), + "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); } catch (ComponentException exp) { assertThat(exp.getActionStatus()).isEqualTo(ActionStatus.ARTIFACT_INVALID_TIMEOUT); return; @@ -440,7 +447,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { ArtifactDefinition origEnvArtifact = new ArtifactDefinition(); ComponentInstance ci = new ComponentInstance(); ci.setUniqueId("ciid"); - ci.setDeploymentArtifacts(fillDeploymentArtifacts(heatArtifact,envArtifact, origEnvArtifact)); + ci.setDeploymentArtifacts(fillDeploymentArtifacts(heatArtifact, envArtifact, origEnvArtifact)); envArtifact.setTimeout(heatArtifact.getTimeout()); GroupInstance groupInstance = new GroupInstance(); groupInstance.setGroupInstanceArtifacts(new ArrayList<>(Arrays.asList(heatArtifact.getUniqueId(), envArtifact.getUniqueId()))); @@ -454,12 +461,12 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { service.setUniqueId("suid"); when(toscaOperationFacade.generateCustomizationUUIDOnInstance(service.getUniqueId(), ci.getUniqueId())) - .thenReturn(StorageOperationStatus.OK); - when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service),eq(ci.getUniqueId()), any(List.class))) - .thenReturn(Either.left(new ArrayList())); - artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE, + .thenReturn(StorageOperationStatus.OK); + when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service), eq(ci.getUniqueId()), any(List.class))) + .thenReturn(Either.left(new ArrayList())); + artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE), - "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); + "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); assertThat(ci.getDeploymentArtifacts().get("HEAT").getTimeout()).isEqualTo(origEnvArtifact.getTimeout()); } @@ -479,13 +486,13 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { service.setUniqueId("suid"); when(toscaOperationFacade.generateCustomizationUUIDOnInstance(service.getUniqueId(), ci.getUniqueId())) - .thenReturn(StorageOperationStatus.OK); - when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service),eq(ci.getUniqueId()), any(List.class))) - .thenReturn(Either.left(new ArrayList())); + .thenReturn(StorageOperationStatus.OK); + when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service), eq(ci.getUniqueId()), any(List.class))) + .thenReturn(Either.left(new ArrayList())); assertThatThrownBy(() -> { - artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE, + artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE), - "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); + "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true); }).isInstanceOf(ComponentException.class); } @@ -496,15 +503,16 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { try { artifactBL.handleUpdate("uid", ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE), - "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, null, true); + "uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, null, true); fail(); - } catch(ComponentException exp) { + } catch (ComponentException exp) { assertThat(exp.getActionStatus()).isEqualTo(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED); assertThat(exp.getParams()[0]).isEqualTo("invalid"); } } - private Map<String, ArtifactDefinition> fillDeploymentArtifacts(ArtifactDefinition heatArtifact, ArtifactDefinition envArtifact, ArtifactDefinition origEnvArtifact) { + private Map<String, ArtifactDefinition> fillDeploymentArtifacts(ArtifactDefinition heatArtifact, ArtifactDefinition envArtifact, + ArtifactDefinition origEnvArtifact) { heatArtifact.setArtifactType("HEAT"); heatArtifact.setTimeout(60); heatArtifact.setEsId("es"); @@ -525,7 +533,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { deploymentArtifacts.put(heatArtifact.getArtifactType(), heatArtifact); //deploymentArtifacts.put(envArtifact.getArtifactType(), envArtifact); deploymentArtifacts.put(envArtifact.getArtifactType(), origEnvArtifact); - return deploymentArtifacts; + return deploymentArtifacts; } @Test @@ -543,7 +551,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { jsonArtifact.getAsJsonObject().addProperty("artifactType", " HEAT"); ArtifactDefinition afterConvert = RepresentationUtils.convertJsonToArtifactDefinition(jsonArtifact.toString(), - ArtifactDefinition.class, false); + ArtifactDefinition.class, false); assertNull(afterConvert); } @@ -572,7 +580,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { jsonArtifact.getAsJsonObject().addProperty("artifactType", " HEAT"); ArtifactDefinition afterConvert = RepresentationUtils.convertJsonToArtifactDefinition(jsonArtifact.toString(), - ArtifactDefinition.class, false); + ArtifactDefinition.class, false); assertNull(afterConvert); } @@ -587,7 +595,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { jsonArtifact.getAsJsonObject().add("artifactType", null); try { RepresentationUtils.convertJsonToArtifactDefinition(jsonArtifact.toString(), - ArtifactDefinition.class, true); + ArtifactDefinition.class, true); fail(); } catch (ComponentException exp) { assertThat(exp.getActionStatus()).isEqualTo(ActionStatus.MANDATORY_PROPERTY_MISSING_VALUE); @@ -606,7 +614,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { try { RepresentationUtils.convertJsonToArtifactDefinition(jsonArtifact.toString(), - ArtifactDefinition.class, false); + ArtifactDefinition.class, false); fail(); } catch (ComponentException exp) { assertThat(exp.getActionStatus()).isEqualTo(ActionStatus.MISSING_MANDATORY_PROPERTY); @@ -625,7 +633,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { try { RepresentationUtils.convertJsonToArtifactDefinition(jsonArtifact.toString(), - ArtifactDefinition.class, true); + ArtifactDefinition.class, true); fail(); } catch (ComponentException exp) { assertThat(exp.getActionStatus()).isEqualTo(ActionStatus.MISSING_MANDATORY_PROPERTY); @@ -649,7 +657,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { jsonArtifact.getAsJsonObject().addProperty("artifactType", " HEAT"); ArtifactDefinition afterConvert = RepresentationUtils.convertJsonToArtifactDefinition(jsonArtifact.toString(), - ArtifactDefinition.class, false); + ArtifactDefinition.class, false); assertNull(afterConvert); } @@ -668,7 +676,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { jsonArtifact.getAsJsonObject().addProperty("artifactType", " HEAT"); ArtifactDefinition afterConvert = RepresentationUtils.convertJsonToArtifactDefinition(jsonArtifact.toString(), - ArtifactDefinition.class, true); + ArtifactDefinition.class, true); assertNull(afterConvert); } @@ -723,51 +731,51 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { List<org.openecomp.sdc.be.model.Component> serviceList = new ArrayList<>(); serviceList.add(service); Either<List<org.openecomp.sdc.be.model.Component>, StorageOperationStatus> getServiceRes = Either - .left(serviceList); + .left(serviceList); when(toscaOperationFacade.getBySystemName(ComponentTypeEnum.SERVICE, serviceName)).thenReturn(getServiceRes); byte[] downloadServiceArtifactByNamesRes = artifactBL - .downloadServiceArtifactByNames(serviceName, serviceVersion, artifactName); + .downloadServiceArtifactByNames(serviceName, serviceVersion, artifactName); assertThat(downloadServiceArtifactByNamesRes != null - && downloadServiceArtifactByNamesRes.length == payload.length).isTrue(); + && downloadServiceArtifactByNamesRes.length == payload.length).isTrue(); } @Test public void createHeatEnvPlaceHolder_vf_emptyHeatParameters() throws Exception { ArtifactDefinition heatArtifact = new ArtifactBuilder() - .addHeatParam(ObjectGenerator.buildHeatParam("defVal1", "val1")) - .addHeatParam(ObjectGenerator.buildHeatParam("defVal2", "val2")).build(); + .addHeatParam(ObjectGenerator.buildHeatParam("defVal1", "val1")) + .addHeatParam(ObjectGenerator.buildHeatParam("defVal2", "val2")).build(); Resource component = new Resource(); component.setComponentType(ComponentTypeEnum.RESOURCE); - when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(USER); + when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(USER); when(artifactToscaOperation.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class), - eq(component), eq(NodeTypeEnum.Resource), eq(true), eq("parentId"))) - .thenReturn(Either.left(new ArtifactDefinition())); + eq(component), eq(NodeTypeEnum.Resource), eq(true), eq("parentId"))) + .thenReturn(Either.left(new ArtifactDefinition())); ArtifactDefinition heatEnvPlaceHolder = artifactBL.createHeatEnvPlaceHolder( - new ArrayList<>(), heatArtifact, HEAT_VF_ENV_NAME, "parentId", NodeTypeEnum.Resource, "parentName", USER, component, - Collections.emptyMap()); + new ArrayList<>(), heatArtifact, HEAT_VF_ENV_NAME, "parentId", NodeTypeEnum.Resource, "parentName", USER, component, + Collections.emptyMap()); assertNull(heatEnvPlaceHolder.getListHeatParameters()); } @Test public void createHeatEnvPlaceHolder_resourceInstance_copyHeatParamasCurrValuesToHeatEnvDefaultVal() - throws Exception { + throws Exception { HeatParameterDefinition heatParam1 = ObjectGenerator.buildHeatParam("defVal1", "val1"); HeatParameterDefinition heatParam2 = ObjectGenerator.buildHeatParam("defVal2", "val2"); HeatParameterDefinition heatParam3 = ObjectGenerator.buildHeatParam("defVal3", "val3"); ArtifactDefinition heatArtifact = new ArtifactBuilder().addHeatParam(heatParam1).addHeatParam(heatParam2) - .addHeatParam(heatParam3).build(); + .addHeatParam(heatParam3).build(); Resource component = new Resource(); - when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(USER); + when(userBusinessLogic.getUser(anyString(), anyBoolean())).thenReturn(USER); when(artifactToscaOperation.addHeatEnvArtifact(any(ArtifactDefinition.class), any(ArtifactDefinition.class), - eq(component), eq(NodeTypeEnum.Resource), eq(true), eq("parentId"))) - .thenReturn(Either.left(new ArtifactDefinition())); + eq(component), eq(NodeTypeEnum.Resource), eq(true), eq("parentId"))) + .thenReturn(Either.left(new ArtifactDefinition())); ArtifactDefinition heatEnvPlaceHolder = artifactBL.createHeatEnvPlaceHolder( - new ArrayList<>(), heatArtifact, HEAT_ENV_NAME, "parentId", NodeTypeEnum.ResourceInstance, "parentName", USER, component, - Collections.emptyMap()); + new ArrayList<>(), heatArtifact, HEAT_ENV_NAME, "parentId", NodeTypeEnum.ResourceInstance, "parentName", USER, component, + Collections.emptyMap()); ArtifactDefinition heatEnvArtifact = heatEnvPlaceHolder; List<HeatParameterDefinition> listHeatParameters = heatEnvArtifact.getListHeatParameters(); @@ -789,11 +797,11 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(), - any(NodeTypeEnum.class), any(String.class), eq(true))).thenReturn(Either.left(artifactDefinition)); + any(NodeTypeEnum.class), any(String.class), eq(true))).thenReturn(Either.left(artifactDefinition)); when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK); when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat()); artifactBL.generateAndSaveHeatEnvArtifact(artifactDefinition, String.valueOf(PAYLOAD), - ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME, USER, INSTANCE_ID, true, true); + ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME, USER, INSTANCE_ID, true, true); } @Test @@ -808,11 +816,11 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(), - any(NodeTypeEnum.class), any(String.class), eq(true))).thenReturn(Either.left(artifactDefinition)); + any(NodeTypeEnum.class), any(String.class), eq(true))).thenReturn(Either.left(artifactDefinition)); when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK); when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat()); artifactBL.generateAndSaveHeatEnvArtifact(artifactDefinition, String.valueOf(PAYLOAD), - ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME, USER, INSTANCE_ID, true, false); + ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME, USER, INSTANCE_ID, true, false); verify(janusGraphDao, times(1)).commit(); } @@ -827,11 +835,11 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), any(), - any(NodeTypeEnum.class), any(String.class), eq(true))).thenReturn(Either.left(artifactDefinition)); + any(NodeTypeEnum.class), any(String.class), eq(true))).thenReturn(Either.left(artifactDefinition)); when(artifactCassandraDao.saveArtifact(any())).thenReturn(CassandraOperationStatus.OK); when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(new ResponseFormat()); artifactBL.generateAndSaveHeatEnvArtifact(artifactDefinition, String.valueOf(PAYLOAD), - ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME, USER, INSTANCE_ID, true, false); + ComponentTypeEnum.SERVICE, new Service(), RESOURCE_INSTANCE_NAME, USER, INSTANCE_ID, true, false); verify(janusGraphDao, times(1)).commit(); return artifactDefinition; } @@ -873,7 +881,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // test 1 testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "composeArtifactId", - new Object[]{resourceId, artifactId, artifactInfo, interfaceName, operationName}); + new Object[]{resourceId, artifactId, artifactInfo, interfaceName, operationName}); } @Test @@ -897,7 +905,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "convertToOperation", - new Object[]{artifactInfo, operationName}); + new Object[]{artifactInfo, operationName}); } @Test @@ -910,7 +918,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "createInterfaceArtifactNameFromOperation", - new Object[]{operationName, artifactName}); + new Object[]{operationName, artifactName}); } @Test @@ -923,7 +931,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); Deencapsulation.invoke(testSubject, "fetchArtifactsFromComponent", - artifactId, component, artifacts); + artifactId, component, artifacts); } @Test @@ -943,7 +951,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); - testSubject.validateArtifact(componentId, componentType, operation, artifactId, artifactInfo, auditingAction, user, component, shouldLock, inTransaction); + testSubject.validateArtifact(componentId, componentType, operation, artifactId, artifactInfo, auditingAction, user, component, shouldLock, + inTransaction); } @Test @@ -957,7 +966,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { boolean shouldLock = false; boolean inTransaction = false; - // default test testSubject = createTestSubject(); testSubject.handleHeatEnvDownload(componentId, componentType, user, component, artifactInfo, shouldLock, inTransaction); @@ -973,7 +981,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "artifactGenerationRequired", - new Object[]{component, artifactInfo}); + new Object[]{component, artifactInfo}); } @Test @@ -999,7 +1007,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); testSubject.updateGroupForHeat(artifactInfo, artifactInfo, artifactInfo, - artifactInfo, component); + artifactInfo, component); } @@ -1021,7 +1029,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { testSubject = createTestSubject(); testSubject.setComponentsUtils(MockGenerator.mockComponentUtils()); testSubject.handleAuditing(auditingActionEnum, component, componentId, user, artifactDefinition, - prevArtifactUuid, currentArtifactUuid, responseFormat, componentTypeEnum, resourceInstanceName); + prevArtifactUuid, currentArtifactUuid, responseFormat, componentTypeEnum, resourceInstanceName); } @Test @@ -1035,7 +1043,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); Deencapsulation.invoke(testSubject, "ignoreUnupdateableFieldsInUpdate", - operation, artifactInfo, artifactInfo); + operation, artifactInfo, artifactInfo); } @Test @@ -1052,7 +1060,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "findArtifact", new Object[]{component, - componentType, parentId, operation, artifactId}); + componentType, parentId, operation, artifactId}); } @@ -1066,7 +1074,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "validateInformationalArtifact", - new Object[]{artifactInfo, component}); + new Object[]{artifactInfo, component}); } @@ -1110,7 +1118,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "findArtifact", - new Object[]{artifactId, component, parentId, componentType}); + new Object[]{artifactId, component, parentId, componentType}); } @@ -1121,7 +1129,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { Map<String, ArtifactDefinition> artifacts = new HashMap<>(); ComponentInstance instance = new ComponentInstance(); - // default test testSubject = createTestSubject(); Deencapsulation.invoke(testSubject, "fetchArtifactsFromInstance", new Object[]{artifactId, artifacts, instance}); @@ -1139,7 +1146,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "generateCustomizationUUIDOnInstance", - new Object[]{componentId, instanceId, componentType}); + new Object[]{componentId, instanceId, componentType}); } @Test @@ -1152,7 +1159,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "findComponentInstance", - new Object[]{componentInstanceId, component}); + new Object[]{componentInstanceId, component}); } @Test(expected = ComponentException.class) @@ -1278,7 +1285,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { }).doesNotThrowAnyException(); } - @Test(expected=ComponentException.class) + @Test(expected = ComponentException.class) public void testValidateResourceType_invalidResourceType() { final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); final ArtifactDefinition artifactInfo = buildArtifactPayload(); @@ -1334,7 +1341,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "validateFirstUpdateHasPayload", - new Object[]{artifactInfo, artifactInfo}); + new Object[]{artifactInfo, artifactInfo}); } @Test @@ -1388,7 +1395,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "validateArtifactTypeNotChanged", - new Object[]{artifactInfo, artifactInfo}); + new Object[]{artifactInfo, artifactInfo}); } @@ -1402,7 +1409,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "validateOrSetArtifactGroupType", - new Object[]{artifactInfo, artifactInfo}); + new Object[]{artifactInfo, artifactInfo}); } @Test @@ -1417,7 +1424,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { testSubject = createTestSubject(); type = null; Deencapsulation.invoke(testSubject, "checkAndSetUnUpdatableFields", user, - artifactInfo, artifactInfo, ArtifactGroupTypeEnum.class); + artifactInfo, artifactInfo, ArtifactGroupTypeEnum.class); } @Test @@ -1426,7 +1433,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { List<HeatParameterDefinition> heatParameters = new ArrayList<>(); List<HeatParameterDefinition> currentParameters = new ArrayList<>(); - // default test testSubject = createTestSubject(); Deencapsulation.invoke(testSubject, "checkAndSetUnupdatableHeatParams", new Object[]{heatParameters, currentParameters}); @@ -1452,77 +1458,75 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { ArtifactsBusinessLogic testSubject = getTestSubject(); Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload", - new Object[] { artifactInfo, isArtifactMetadataUpdate }); + new Object[]{artifactInfo, isArtifactMetadataUpdate}); assertArrayEquals(payload, result.left().value()); } - - - @Test - public void testGivenInValidVesEventsArtifactPayload_WhenHandlePayload_ThenResultIsInvalidYaml() { - final int expectedStatus = 100; - when(componentsUtils.getResponseFormat(eq(ActionStatus.INVALID_YAML), any(String.class))).thenReturn(new ResponseFormat(expectedStatus)); - final byte[] payload = "invalidYaml".getBytes(); - ArtifactDefinition artifactInfo = createArtifactInfo(payload, "ves_events_file.yaml", ArtifactTypeEnum.VES_EVENTS); + public void testGivenInValidVesEventsArtifactPayload_WhenHandlePayload_ThenResultIsInvalidYaml() { + final int expectedStatus = 100; + when(componentsUtils.getResponseFormat(eq(ActionStatus.INVALID_YAML), any(String.class))).thenReturn(new ResponseFormat(expectedStatus)); + final byte[] payload = "invalidYaml".getBytes(); + ArtifactDefinition artifactInfo = createArtifactInfo(payload, "ves_events_file.yaml", ArtifactTypeEnum.VES_EVENTS); final boolean isArtifactMetadataUpdate = false; ArtifactsBusinessLogic testSubject = getTestSubject(); testSubject.setComponentsUtils(componentsUtils); Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload", - new Object[]{artifactInfo, isArtifactMetadataUpdate}); + new Object[]{artifactInfo, isArtifactMetadataUpdate}); int status = result.right().value().getStatus(); assertEquals(expectedStatus, status); } @Test - public void testGivenEmptyVesEventsArtifactPayload_WhenHandlePayload_ThenResultIsMissingData() { - final int expectedStatus = 101; - when(componentsUtils.getResponseFormat(eq(ActionStatus.MISSING_DATA), any(String.class))).thenReturn(new ResponseFormat(expectedStatus)); - final byte[] payload = "".getBytes(); - ArtifactDefinition artifactInfo = createArtifactInfo(payload, "ves_events_file.yaml", ArtifactTypeEnum.VES_EVENTS); + public void testGivenEmptyVesEventsArtifactPayload_WhenHandlePayload_ThenResultIsMissingData() { + final int expectedStatus = 101; + when(componentsUtils.getResponseFormat(eq(ActionStatus.MISSING_DATA), any(String.class))).thenReturn(new ResponseFormat(expectedStatus)); + final byte[] payload = "".getBytes(); + ArtifactDefinition artifactInfo = createArtifactInfo(payload, "ves_events_file.yaml", ArtifactTypeEnum.VES_EVENTS); final boolean isArtifactMetadataUpdate = false; ArtifactsBusinessLogic testSubject = getTestSubject(); testSubject.setComponentsUtils(componentsUtils); Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload", - new Object[]{artifactInfo, isArtifactMetadataUpdate}); + new Object[]{artifactInfo, isArtifactMetadataUpdate}); - int status = result.right().value().getStatus(); - assertEquals(expectedStatus, status); + int status = result.right().value().getStatus(); + assertEquals(expectedStatus, status); } @Test - public void testGivenValidHeatArtifactPayload_WhenHandlePayload_ThenResultIsDecodedPayload() { - final byte[] payload = "heat_template_version: 1.0".getBytes(); - ArtifactDefinition artifactInfo = createArtifactInfo(payload, "heat_template.yaml", ArtifactTypeEnum.HEAT); + public void testGivenValidHeatArtifactPayload_WhenHandlePayload_ThenResultIsDecodedPayload() { + final byte[] payload = "heat_template_version: 1.0".getBytes(); + ArtifactDefinition artifactInfo = createArtifactInfo(payload, "heat_template.yaml", ArtifactTypeEnum.HEAT); final boolean isArtifactMetadataUpdate = false; ArtifactsBusinessLogic testSubject = getTestSubject(); Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload", - new Object[]{artifactInfo, isArtifactMetadataUpdate}); + new Object[]{artifactInfo, isArtifactMetadataUpdate}); assertArrayEquals(payload, result.left().value()); } @Test - public void testGivenInValidHeatArtifactPayload_WhenHandlePayload_ThenResultIsInvalidYaml() { - final int expectedStatus = 1000; - when(componentsUtils.getResponseFormat(eq(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT), any(String.class))).thenReturn(new ResponseFormat(expectedStatus)); - final byte[] payload = "validYaml: butNoHeatTemplateVersion".getBytes(); - ArtifactDefinition artifactInfo = createArtifactInfo(payload, "heat_template.yaml", ArtifactTypeEnum.HEAT); + public void testGivenInValidHeatArtifactPayload_WhenHandlePayload_ThenResultIsInvalidYaml() { + final int expectedStatus = 1000; + when(componentsUtils.getResponseFormat(eq(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT), any(String.class))).thenReturn( + new ResponseFormat(expectedStatus)); + final byte[] payload = "validYaml: butNoHeatTemplateVersion".getBytes(); + ArtifactDefinition artifactInfo = createArtifactInfo(payload, "heat_template.yaml", ArtifactTypeEnum.HEAT); final boolean isArtifactMetadataUpdate = false; ArtifactsBusinessLogic testSubject = getTestSubject(); testSubject.setComponentsUtils(componentsUtils); Either<byte[], ResponseFormat> result = Deencapsulation.invoke(testSubject, "handlePayload", - new Object[]{artifactInfo, isArtifactMetadataUpdate}); + new Object[]{artifactInfo, isArtifactMetadataUpdate}); int status = result.right().value().getStatus(); assertEquals(expectedStatus, status); @@ -1552,8 +1556,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "validateUserRole", - new Object[]{user, auditingAction, componentId, artifactId, componentType, - operation}); + new Object[]{user, auditingAction, componentId, artifactId, componentType, + operation}); assertNull(result); } @@ -1568,7 +1572,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "detectAuditingType", - new Object[]{operation, origMd5}); + new Object[]{operation, origMd5}); assertNotNull(result); } @@ -1583,7 +1587,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "detectAuditingType", - new Object[]{operation, origMd5}); + new Object[]{operation, origMd5}); assertNull(result); } @@ -1610,7 +1614,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "isArtifactMetadataUpdate", - new Object[]{auditingActionEnum}); + new Object[]{auditingActionEnum}); assertThat(result).isTrue(); } @@ -1623,7 +1627,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "isArtifactMetadataUpdate", - new Object[]{auditingActionEnum}); + new Object[]{auditingActionEnum}); assertThat(result).isFalse(); } @@ -1662,8 +1666,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // test 1 testSubject = createTestSubject(); Deencapsulation.invoke(testSubject, "setArtifactPlaceholderCommonFields", - resourceId, user, artifactInfo); - assertEquals(resourceId + "." +ARTIFACT_LABEL, artifactInfo.getUniqueId()); + resourceId, user, artifactInfo); + assertEquals(resourceId + "." + ARTIFACT_LABEL, artifactInfo.getUniqueId()); assertEquals(user.getFullName(), artifactInfo.getCreatorFullName()); } @@ -1678,7 +1682,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "createEsHeatEnvArtifactDataFromString", - new Object[]{artifactDefinition, payloadStr}); + new Object[]{artifactDefinition, payloadStr}); assertThat(result.isLeft()).isTrue(); } @@ -1707,7 +1711,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "generateHeatEnvPayload", - new Object[]{artifactDefinition}); + new Object[]{artifactDefinition}); assertThat(result.isEmpty()).isFalse(); } @@ -1745,7 +1749,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { testSubject = createTestSubject(); artifactId = ""; result = testSubject.buildJsonForUpdateArtifact(artifactId, artifactName, artifactType, artifactGroupType, - label, displayName, description, artifactContent, updatedRequiredArtifacts, heatParameters); + label, displayName, description, artifactContent, updatedRequiredArtifacts, heatParameters); assertThat(MapUtils.isNotEmpty(result)).isTrue(); } @@ -1756,10 +1760,10 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { List<HeatParameterDefinition> currentHeatEnvParams = new ArrayList<>(); List<HeatParameterDefinition> updatedHeatEnvParams = new ArrayList<>(); - // default test testSubject = createTestSubject(); - boolean result = Deencapsulation.invoke(testSubject, "replaceCurrHeatValueWithUpdatedValue", new Object[]{currentHeatEnvParams, updatedHeatEnvParams}); + boolean result = Deencapsulation.invoke(testSubject, "replaceCurrHeatValueWithUpdatedValue", + new Object[]{currentHeatEnvParams, updatedHeatEnvParams}); assertThat(result).isFalse(); } @@ -1783,7 +1787,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); - boolean result = Deencapsulation.invoke(testSubject, "replaceCurrHeatValueWithUpdatedValue", new Object[]{currentHeatEnvParams, updatedHeatEnvParams}); + boolean result = Deencapsulation.invoke(testSubject, "replaceCurrHeatValueWithUpdatedValue", + new Object[]{currentHeatEnvParams, updatedHeatEnvParams}); assertThat(result).isTrue(); assertEquals(hpdUpd.getCurrentValue(), hpdOrig.getCurrentValue()); } @@ -1820,7 +1825,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); Deencapsulation.invoke(testSubject, "setHeatCurrentValuesOnHeatEnvDefaultValues", - artifact, artifactInfo); + artifact, artifactInfo); assertNotEquals(artifact, artifactInfo); assertEquals(1, artifact.getListHeatParameters().size()); @@ -1896,7 +1901,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { // default test testSubject = createTestSubject(); result = testSubject.handleArtifactsForInnerVfcComponent(artifactsToHandle, component, user, - vfcsNewCreatedArtifacts, operation, shouldLock, inTransaction); + vfcsNewCreatedArtifacts, operation, shouldLock, inTransaction); assertThat(CollectionUtils.isEmpty(result)).isTrue(); } @@ -2137,29 +2142,28 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { user.setRole(Role.ADMIN.name()); when(userValidations.validateUserExists(Mockito.eq("userId"))) - .thenReturn(user); + .thenReturn(user); when(toscaOperationFacade.getToscaFullElement(any())) - .thenReturn(Either.left(resource)); + .thenReturn(Either.left(resource)); when(artifactToscaOperation.getArtifactById(any(), any(), any(), any())) - .thenReturn(Either.left(artifactDefinition)); + .thenReturn(Either.left(artifactDefinition)); when(artifactsResolver.findArtifactOnComponent(any(), any(ComponentTypeEnum.class), anyString())) - .thenReturn(artifactDefinition); + .thenReturn(artifactDefinition); when(graphLockOperation.lockComponent(eq(resource.getUniqueId()), any(NodeTypeEnum.class))) - .thenReturn(StorageOperationStatus.OK); - when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), anyString(), any(NodeTypeEnum.class), any(), anyBoolean())) - .thenReturn(Either.left(artifactDefinition)); - when(artifactCassandraDao.saveArtifact(any(DAOArtifactData.class))) - .thenReturn(CassandraOperationStatus.OK); - when(toscaOperationFacade.getToscaElement(anyString())) - .thenReturn(Either.left(resource)); - when(interfaceOperation.updateInterfaces(anyString(), anyList())) - .thenReturn(Either.left(interfaceDefinitionsList)); + .thenReturn(StorageOperationStatus.OK); + when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(), anyString(), any(NodeTypeEnum.class), any(), + anyBoolean())) + .thenReturn(Either.left(artifactDefinition)); + when(artifactCassandraDao.saveArtifact(any(DAOArtifactData.class))).thenReturn(CassandraOperationStatus.OK); + when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(resource)); + when(interfaceOperation.updateInterfaces(any(Component.class), anyList())).thenReturn(Either.left(interfaceDefinitionsList)); when(artifactToscaOperation.getAllInstanceArtifacts(resource.getUniqueId(), componentId)).thenReturn(Either.left(artifactDefinitionMap)); when(toscaOperationFacade.generateCustomizationUUIDOnInstance(any(), any())).thenReturn(StorageOperationStatus.OK); - Either<ArtifactDefinition, Operation> result = artifactBL.handleArtifactRequest(componentId, user.getUserId(), ComponentTypeEnum.RESOURCE_INSTANCE - , operationInfo, artifactDefinition.getUniqueId(), artifactDefinition, requestMd5, "data", "iuuid", - null, componentId, "resources"); + Either<ArtifactDefinition, Operation> result = artifactBL.handleArtifactRequest(componentId, user.getUserId(), + ComponentTypeEnum.RESOURCE_INSTANCE + , operationInfo, artifactDefinition.getUniqueId(), artifactDefinition, requestMd5, "data", "iuuid", + null, componentId, "resources"); assertThat(result.isLeft()).isTrue(); ArtifactDefinition leftValue = result.left().value(); @@ -2185,16 +2189,17 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { byte[] csar = "test.csar".getBytes(); when(csarUtils.createCsar(any(Component.class), anyBoolean(), anyBoolean())) - .thenReturn(Either.left(csar)); - when(artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(Component.class), anyString(), any(NodeTypeEnum.class), anyString(), anyBoolean())) - .thenReturn(Either.left(artifactDefinition)); + .thenReturn(Either.left(csar)); + when( + artifactToscaOperation.updateArtifactOnResource(any(ArtifactDefinition.class), any(Component.class), anyString(), any(NodeTypeEnum.class), + anyString(), anyBoolean())) + .thenReturn(Either.left(artifactDefinition)); when(artifactCassandraDao.saveArtifact(any(DAOArtifactData.class))) - .thenReturn(CassandraOperationStatus.OK); + .thenReturn(CassandraOperationStatus.OK); Either<ArtifactDefinition, Operation> result - = artifactBL.generateAndSaveToscaArtifact(artifactDefinition, resource, user, inCertificationRequest, - shouldLock, inTransaction, fetchTemplatesFromDB); - + = artifactBL.generateAndSaveToscaArtifact(artifactDefinition, resource, user, inCertificationRequest, + shouldLock, inTransaction, fetchTemplatesFromDB); Assert.assertEquals(artifactDefinition.getUniqueId(), result.left().value().getUniqueId()); } @@ -2213,10 +2218,10 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { csarArtifact.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA); when(csarUtils.createCsar(any(Component.class), anyBoolean(), anyBoolean())) - .thenReturn(Either.left(generatedCsar)); + .thenReturn(Either.left(generatedCsar)); ImmutablePair<String, byte[]> result = - testSubject.handleDownloadToscaModelRequest(resource, csarArtifact); + testSubject.handleDownloadToscaModelRequest(resource, csarArtifact); assertEquals(csarArtifact.getArtifactName(), result.getKey()); } @@ -2257,18 +2262,18 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { user.setUserId("userId"); when(userValidations.validateUserExists(eq(user.getUserId()))) - .thenReturn(user); + .thenReturn(user); when(toscaOperationFacade.getToscaFullElement(eq(componentId))) - .thenReturn(Either.left(resource)); + .thenReturn(Either.left(resource)); when(artifactToscaOperation.getArtifactById(anyString(), anyString(), any(ComponentTypeEnum.class), anyString())) - .thenReturn(Either.left(artifactDefinition)); + .thenReturn(Either.left(artifactDefinition)); when(artifactCassandraDao.getArtifact(any())) - .thenReturn(Either.left(daoArtifactData)); + .thenReturn(Either.left(daoArtifactData)); when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); ImmutablePair<String, byte[]> result = - artifactBL.handleDownloadRequestById(componentId, artifactId, user.getUserId(), ComponentTypeEnum.RESOURCE, - parentId, null); + artifactBL.handleDownloadRequestById(componentId, artifactId, user.getUserId(), ComponentTypeEnum.RESOURCE, + parentId, null); Assert.assertEquals(artifactDefinition.getArtifactName(), result.getKey()); } @@ -2280,8 +2285,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { try { ImmutablePair<String, byte[]> result = - artifactBL.handleDownloadRequestById(componentId, artifactId, userId, ComponentTypeEnum.RESOURCE, componentId - , null); + artifactBL.handleDownloadRequestById(componentId, artifactId, userId, ComponentTypeEnum.RESOURCE, componentId + , null); } catch (ComponentException e) { assertEquals(e.getActionStatus(), ActionStatus.MISSING_INFORMATION); return; @@ -2306,15 +2311,15 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { service.setUniqueId(componentId); when(toscaOperationFacade.getToscaElement(eq(componentId), any(ComponentParametersView.class))) - .thenReturn(Either.left(service)); + .thenReturn(Either.left(service)); when(graphLockOperation.lockComponent(eq(componentId), any(NodeTypeEnum.class))) - .thenReturn(StorageOperationStatus.OK); + .thenReturn(StorageOperationStatus.OK); when(artifactToscaOperation.getArtifacts(any(), any(NodeTypeEnum.class), any(ArtifactGroupTypeEnum.class), any())) - .thenReturn(Either.left(artifactDefinitionMap)); + .thenReturn(Either.left(artifactDefinitionMap)); Map<String, ArtifactDefinition> result = - artifactBL.handleGetArtifactsByType(ComponentTypeEnum.SERVICE.name(), parentId, ComponentTypeEnum.SERVICE, - componentId, artifactGroupType, userId); + artifactBL.handleGetArtifactsByType(ComponentTypeEnum.SERVICE.name(), parentId, ComponentTypeEnum.SERVICE, + componentId, artifactGroupType, userId); Assert.assertEquals(artifactDefinition.getArtifactName(), result.get("artifact1").getArtifactName()); } @@ -2367,15 +2372,15 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { resource.setDeploymentArtifacts(deploymentArtifacts); when(graphLockOperation.lockComponent(eq(parentId), any(NodeTypeEnum.class))) - .thenReturn(StorageOperationStatus.OK); + .thenReturn(StorageOperationStatus.OK); when(toscaOperationFacade.getToscaElement(eq(parentId))) - .thenReturn(Either.left(resource)); + .thenReturn(Either.left(resource)); when(artifactToscaOperation.isCloneNeeded(any(), any(ArtifactDefinition.class), any(NodeTypeEnum.class))) - .thenReturn(Either.left(Boolean.FALSE)); + .thenReturn(Either.left(Boolean.FALSE)); when(artifactToscaOperation.removeArtifactOnGraph(any(ArtifactDefinition.class), any(), any(), any(NodeTypeEnum.class), anyBoolean())) - .thenReturn(Either.left(artifactDataDefinition)); + .thenReturn(Either.left(artifactDataDefinition)); when(artifactCassandraDao.deleteArtifact(any())) - .thenReturn(CassandraOperationStatus.OK); + .thenReturn(CassandraOperationStatus.OK); Either<ArtifactDefinition, ResponseFormat> result = artifactBL.handleDelete( parentId, artifactId, user, resource, true, false); @@ -2390,9 +2395,9 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { String resourceVersion = "1.0"; String artifactName = "artifactName"; - try{ + try { artifactBL.downloadRsrcArtifactByNames(serviceName, serviceVersion, resourceName, resourceVersion, artifactName); - } catch(ComponentException e) { + } catch (ComponentException e) { assertEquals(ActionStatus.INVALID_CONTENT, e.getActionStatus()); return; } @@ -2430,11 +2435,12 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { serviceList.add(service); resource.setDeploymentArtifacts(artifacts); - when(toscaOperationFacade.getComponentByNameAndVersion(eq(ComponentTypeEnum.RESOURCE), eq(resourceName), eq(version), eq(JsonParseFlagEnum.ParseMetadata))) - .thenReturn(Either.left(resource)); + when(toscaOperationFacade.getComponentByNameAndVersion(eq(ComponentTypeEnum.RESOURCE), eq(resourceName), eq(version), + eq(JsonParseFlagEnum.ParseMetadata))) + .thenReturn(Either.left(resource)); doReturn(Either.left(serviceList)).when(toscaOperationFacade).getBySystemName(eq(ComponentTypeEnum.SERVICE), eq(serviceName)); when(artifactCassandraDao.getArtifact(any())) - .thenReturn(Either.left(esArtifactData)); + .thenReturn(Either.left(esArtifactData)); byte[] result = artifactBL.downloadRsrcArtifactByNames(serviceName, version, resourceName, version, artifactName); Assert.assertEquals(esArtifactData.getDataAsArray(), result); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java index bc67281035..786c98d1a7 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java @@ -26,27 +26,40 @@ import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.InterfaceDefinition; +import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; @org.springframework.stereotype.Component("interfaces-operation") public class InterfaceOperation extends BaseOperation { - public Either<List<InterfaceDefinition>, StorageOperationStatus> addInterfaces(String componentId, + public Either<List<InterfaceDefinition>, StorageOperationStatus> addInterfaces(final Component component, List<InterfaceDefinition> interfaceDefinitions) { - return addOrUpdateInterfaces(false, componentId, interfaceDefinitions); + final String componentId = component.getUniqueId(); + if (isVfc(component)) { + return addOrUpdateInterfaces(componentId, VertexTypeEnum.INTERFACE_ARTIFACTS, EdgeLabelEnum.INTERFACE_ARTIFACTS, interfaceDefinitions, + false); + } else { + return addOrUpdateInterfaces(componentId, VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceDefinitions, false); + } } - private Either<List<InterfaceDefinition>, StorageOperationStatus> addOrUpdateInterfaces(boolean isUpdateAction, String componentId, - List<InterfaceDefinition> interfaceDefinitions) { - List<ToscaDataDefinition> interfaceDataDefinitions = interfaceDefinitions.stream().map(InterfaceDataDefinition::new) + private Either<List<InterfaceDefinition>, StorageOperationStatus> addOrUpdateInterfaces(final String componentId, + final VertexTypeEnum vertexTypeEnum, + final EdgeLabelEnum edgeLabelEnum, + final List<InterfaceDefinition> interfaceDefinitions, + final boolean isUpdateAction) { + final List<ToscaDataDefinition> interfaceDataDefinitions = interfaceDefinitions.stream() + .map(InterfaceDataDefinition::new) .collect(Collectors.toList()); - StorageOperationStatus statusRes = performUpdateToscaAction(isUpdateAction, componentId, interfaceDataDefinitions, EdgeLabelEnum.INTERFACE, - VertexTypeEnum.INTERFACE); - if (!statusRes.equals(StorageOperationStatus.OK)) { - return Either.right(statusRes); + final StorageOperationStatus status = performUpdateToscaAction(isUpdateAction, componentId, interfaceDataDefinitions, edgeLabelEnum, + vertexTypeEnum); + if (!status.equals(StorageOperationStatus.OK)) { + return Either.right(status); } return Either.left(interfaceDefinitions); } @@ -60,25 +73,43 @@ public class InterfaceOperation extends BaseOperation { } } - public Either<List<InterfaceDefinition>, StorageOperationStatus> updateInterfaces(String componentId, - List<InterfaceDefinition> interfaceDefinitions) { - return addOrUpdateInterfaces(true, componentId, interfaceDefinitions); + public Either<List<InterfaceDefinition>, StorageOperationStatus> updateInterfaces(final Component component, + final List<InterfaceDefinition> interfaceDefinitions) { + final String componentId = component.getUniqueId(); + if (isVfc(component)) { + return addOrUpdateInterfaces(componentId, VertexTypeEnum.INTERFACE_ARTIFACTS, EdgeLabelEnum.INTERFACE_ARTIFACTS, interfaceDefinitions, + true); + } else { + return addOrUpdateInterfaces(componentId, VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceDefinitions, true); + } + } + + public Either<String, StorageOperationStatus> deleteInterface(final Component component, final String interfacesToDelete) { + final String componentId = component.getUniqueId(); + if (isVfc(component)) { + return deleteInterface(componentId, interfacesToDelete, EdgeLabelEnum.INTERFACE_ARTIFACTS, VertexTypeEnum.INTERFACE_ARTIFACTS); + } else { + return deleteInterface(componentId, interfacesToDelete, EdgeLabelEnum.INTERFACE, VertexTypeEnum.INTERFACE); + } + } + + private boolean isVfc(Component component) { + return component instanceof Resource && ((Resource) component).getResourceType() == ResourceTypeEnum.VFC; } - public Either<String, StorageOperationStatus> deleteInterface(String componentId, String interfacesToDelete) { - StorageOperationStatus statusRes = deleteToscaDataElements(componentId, EdgeLabelEnum.INTERFACE, - Collections.singletonList(interfacesToDelete)); + private Either<String, StorageOperationStatus> deleteInterface(final String componentId, final String interfacesToDelete, + final EdgeLabelEnum edgeLabel, final VertexTypeEnum vertexType) { + StorageOperationStatus statusRes = deleteToscaDataElements(componentId, edgeLabel, Collections.singletonList(interfacesToDelete)); if (!statusRes.equals(StorageOperationStatus.OK)) { return Either.right(statusRes); } - Either<Map<String, InterfaceDataDefinition>, JanusGraphOperationStatus> componentEither = getDataFromGraph(componentId, - EdgeLabelEnum.INTERFACE); - if (componentEither.isRight()) { - return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(componentEither.right().value())); + Either<Map<String, InterfaceDataDefinition>, JanusGraphOperationStatus> interfaceEither = getDataFromGraph(componentId, edgeLabel); + if (interfaceEither.isRight()) { + return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(interfaceEither.right().value())); } - Map<String, InterfaceDataDefinition> interfaceDataDefinitionMap = componentEither.left().value(); + final Map<String, InterfaceDataDefinition> interfaceDataDefinitionMap = interfaceEither.left().value(); if (MapUtils.isEmpty(interfaceDataDefinitionMap)) { - statusRes = removeToscaData(componentId, EdgeLabelEnum.INTERFACE, VertexTypeEnum.INTERFACE); + statusRes = removeToscaData(componentId, edgeLabel, vertexType); if (!statusRes.equals(StorageOperationStatus.OK)) { return Either.right(statusRes); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperationTest.java index 7353c511db..44d0fbdf1e 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperationTest.java @@ -357,10 +357,7 @@ public class InterfaceOperationTest extends ModelTestBase { private void testAddSingleInterface(Component component) { InterfaceDefinition interfaceDefinition = buildInterfaceDefinition("1"); - Either<List<InterfaceDefinition>, StorageOperationStatus> res = interfaceOperation - .addInterfaces(component.getUniqueId(), - Collections.singletonList( - interfaceDefinition)); + final var res = interfaceOperation.addInterfaces(component, Collections.singletonList(interfaceDefinition)); Assert.assertTrue(res.isLeft()); Assert.assertEquals("1", res.left().value().get(0).getUniqueId()); } @@ -398,8 +395,7 @@ public class InterfaceOperationTest extends ModelTestBase { List<InterfaceDefinition> interfaceDefinitions = new ArrayList<>(); interfaceDefinitions.add(interfaceDefinition1); interfaceDefinitions.add(interfaceDefinition2); - Either<List<InterfaceDefinition>, StorageOperationStatus> res = - interfaceOperation.addInterfaces(component.getUniqueId(), interfaceDefinitions); + final var res = interfaceOperation.addInterfaces(component, interfaceDefinitions); Assert.assertTrue(res.isLeft()); Assert.assertEquals(2, res.left().value().size()); } @@ -411,17 +407,13 @@ public class InterfaceOperationTest extends ModelTestBase { private void testUpdateInterface(Component component) { InterfaceDefinition interfaceDefinition = buildInterfaceDefinition("1"); - Either<List<InterfaceDefinition>, StorageOperationStatus> res = interfaceOperation - .addInterfaces(component.getUniqueId(), - Collections.singletonList( - interfaceDefinition)); + var res = interfaceOperation.addInterfaces(component, Collections.singletonList(interfaceDefinition)); Assert.assertTrue(res.isLeft()); List<InterfaceDefinition> value = res.left().value(); InterfaceDefinition createdInterfaceDef = value.get(0); String newDescription = "New Description"; createdInterfaceDef.setDescription(newDescription); - res = interfaceOperation - .updateInterfaces(component.getUniqueId(), Collections.singletonList(createdInterfaceDef)); + res = interfaceOperation.updateInterfaces(component, Collections.singletonList(createdInterfaceDef)); assertTrue(res.isLeft()); assertEquals(newDescription, res.left().value().get(0).getDescription()); } @@ -438,14 +430,10 @@ public class InterfaceOperationTest extends ModelTestBase { private void testDeleteInterface(Component component) { InterfaceDefinition interfaceDefinition = buildInterfaceDefinition("1"); - Either<List<InterfaceDefinition>, StorageOperationStatus> res = interfaceOperation - .addInterfaces(component.getUniqueId(), - Collections.singletonList( - interfaceDefinition)); + var res = interfaceOperation.addInterfaces(component, Collections.singletonList(interfaceDefinition)); Assert.assertTrue(res.isLeft()); List<InterfaceDefinition> value = res.left().value(); - Either<String, StorageOperationStatus> deleteInterfaceOperationRes = - interfaceOperation.deleteInterface(component.getUniqueId(), value.get(0).getUniqueId()); + final var deleteInterfaceOperationRes = interfaceOperation.deleteInterface(component, value.get(0).getUniqueId()); assertTrue(deleteInterfaceOperationRes.isLeft()); } @@ -459,8 +447,7 @@ public class InterfaceOperationTest extends ModelTestBase { Component component = createResource(); InterfaceDefinition interfaceDefinition = buildInterfaceDefinitionWithoutOperation(); interfaceDefinition.setOperationsMap(createMockOperationMap()); - Either<List<InterfaceDefinition>, StorageOperationStatus> res = interfaceOperation.updateInterfaces( - component.getUniqueId(), Collections.singletonList(interfaceDefinition)); + final var res = interfaceOperation.updateInterfaces(component, Collections.singletonList(interfaceDefinition)); Assert.assertTrue(res.isRight()); } diff --git a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.html b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.html index f3043ffebd..bf36df0593 100644 --- a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.html +++ b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.html @@ -69,15 +69,20 @@ <span class="cell header-cell field-description header-description"> {{ 'INTERFACE_HEADER_DESCRIPTION' | translate }} </span> + <span class="cell field-delete" *ngIf="!readonly"><span class="delete-col-header"></span></span> </div> - <div class="data-row" *ngFor="let operation of interface1.operations" (click)="onSelectInterfaceOperation(interface1, operation)"> - <span class="cell field-name">{{operation.name}}</span> - <span class="cell field-description" [ngClass]="{'collapsed': operation.isCollapsed}"> - {{operation.getDescriptionEllipsis()}} + <div class="data-row" *ngFor="let operation of interface1.operations"> + <span class="cell field-name" + (click)="onSelectInterfaceOperation(interface1, operation)">{{operation.name}}</span> + <span class="cell field-description" (click)="onSelectInterfaceOperation(interface1, operation)" + [ngClass]="{'collapsed': operation.isCollapsed}">{{operation.getDescriptionEllipsis()}} <span class="more-or-less link" (click)="operation.toggleCollapsed($event)"> {{!operation.isEllipsis ? '' : operation.isCollapsed ? 'More' : 'Less'}} - </span> </span> + </span> + <span class="cell field-delete" *ngIf="!readonly"> + <button class="table-delete-btn" (click)="onRemoveOperation(operation)"></button> + </span> </div> </div> </div> diff --git a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.less b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.less index 2b76c8c0ec..464732e016 100644 --- a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.less +++ b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.less @@ -20,10 +20,21 @@ */ @import '../../../../assets/styles/variables.less'; @import '../../../../assets/styles/override.less'; - +@import '../../../../assets/styles/sprite-old.less'; .interface-definition { font-size: 14px; + .delete-col-header{ + .sprite; + .sprite.e-sdc-small-icon-delete; + } + + .field-delete{ + display: flex; + align-items: center; + justify-content: center; + } + .interface-empty-msg { .bold-message { font-family: @font-opensans-bold; @@ -184,10 +195,18 @@ .data-row { cursor: pointer; + .table-delete-btn{ + .sprite; + .sprite.e-sdc-small-icon-delete; + border: none; + display: none !important; + } &:hover { background: @sdcui_color_light-silver; - + .table-delete-btn{ + display: inline-block !important; + } .cell { &.field-name { color: @sdcui_color_dark-blue; diff --git a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts index 5372fc919d..2a25ad90df 100644 --- a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts @@ -398,8 +398,10 @@ export class InterfaceDefinitionComponent { return this.interfaces.filter((interfaceData) => interfaceData.operations && interfaceData.operations.length > 0).length > 0; } - onRemoveOperation = (event: Event, operation: OperationModel): void => { - event.stopPropagation(); + onRemoveOperation(operation: OperationModel): void { + if (this.readonly) { + return; + } const deleteButton: IModalButtonComponent = { id: 'deleteButton', |