diff options
author | davsad <david.sadlier@est.tech> | 2021-07-24 19:40:56 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-08-06 15:22:51 +0000 |
commit | 0ed125f98ae8ea9e80c855a640c328654660d081 (patch) | |
tree | 2ff63490ba093726164a1199aeef6605bb3652ff /catalog-be | |
parent | 84aa83e9203d6f890cc5f425a00ac748d47c5c8f (diff) |
Consider component model when retrieving interface types
Issue-ID: SDC-3414
Signed-off-by: davsad <david.sadlier@est.tech>
Change-Id: Ie16a2604cfdff042e32bfa4f9a3a509b5da22226
Diffstat (limited to 'catalog-be')
9 files changed, 95 insertions, 79 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java index 62e6ce5182..de8f2934d5 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java @@ -75,8 +75,9 @@ public class InterfaceDefinitionHandler { * @param interfaceDefinitionToscaMap the TOSCA interface definition structure * @return an interface definition representation */ - public InterfaceDefinition create(final Map<String, Object> interfaceDefinitionToscaMap) { + public InterfaceDefinition create(final Map<String, Object> interfaceDefinitionToscaMap, final String model) { final InterfaceDefinition interfaceDefinition = new InterfaceDefinition(); + interfaceDefinition.setModel(model); if (interfaceDefinitionToscaMap.containsKey(TYPE.getElementName())) { final Object typeObj = interfaceDefinitionToscaMap.get(TYPE.getElementName()); if (!(typeObj instanceof String)) { @@ -101,18 +102,18 @@ public class InterfaceDefinitionHandler { operationMap = handleLegacyOperations(interfaceDefinitionToscaMap); } if (!operationMap.isEmpty()) { - validateOperations(interfaceDefinition.getType(), operationMap); + validateOperations(interfaceDefinition.getType(), operationMap, model); interfaceDefinition.setOperations(operationMap); } return interfaceDefinition; } - private void validateOperations(final String interfaceType, final Map<String, OperationDataDefinition> operationMap) { + private void validateOperations(final String interfaceType, final Map<String, OperationDataDefinition> operationMap, final String model) { if (MapUtils.isEmpty(operationMap)) { return; } Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceDefinitionMapEither = interfaceOperationBusinessLogic - .getAllInterfaceLifecycleTypes(); + .getAllInterfaceLifecycleTypes(model); if (interfaceDefinitionMapEither.isRight() || MapUtils.isEmpty(interfaceDefinitionMapEither.left().value())) { throw new ByActionStatusComponentException(ActionStatus.INTERFACE_UNKNOWN, interfaceType); } 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 e23818c957..d633141fdf 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 @@ -258,7 +258,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { } org.openecomp.sdc.be.model.Component storedComponent = componentEither.left().value(); lockComponentResult(lock, storedComponent, errorContext); - Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = getAllInterfaceLifecycleTypes(); + Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = getAllInterfaceLifecycleTypes(storedComponent.getModel()); if (interfaceLifecycleTypes.isRight()) { return Either.right(interfaceLifecycleTypes.right().value()); } @@ -349,9 +349,9 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic { } } - public Either<Map<String, InterfaceDefinition>, ResponseFormat> getAllInterfaceLifecycleTypes() { + public Either<Map<String, InterfaceDefinition>, ResponseFormat> getAllInterfaceLifecycleTypes(final String model) { Either<Map<String, InterfaceDefinition>, StorageOperationStatus> interfaceLifecycleTypes = interfaceLifecycleTypeOperation - .getAllInterfaceLifecycleTypes(); + .getAllInterfaceLifecycleTypes(model); if (interfaceLifecycleTypes.isRight()) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_LIFECYCLE_TYPES_NOT_FOUND)); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java index a7defab60a..6efdab4a96 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java @@ -24,7 +24,6 @@ package org.openecomp.sdc.be.components.impl; import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataType; import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataTypeDefinitionWithName; -import fj.data.Either; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -37,7 +36,9 @@ import java.util.Set; import java.util.function.Function; import java.util.regex.Pattern; import java.util.stream.Collectors; + import javax.servlet.ServletContext; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -97,6 +98,8 @@ import org.springframework.stereotype.Component; import org.springframework.web.context.WebApplicationContext; import org.yaml.snakeyaml.Yaml; +import fj.data.Either; + @Component("resourceImportManager") public class ResourceImportManager { @@ -351,7 +354,7 @@ public class ResourceImportManager { Map<String, Object> jsonInterfaces = toscaInterfaces.left().value(); Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>(); for (final Entry<String, Object> interfaceNameValue : jsonInterfaces.entrySet()) { - final Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue.getValue()); + final Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue.getValue(), resource.getModel()); if (eitherInterface.isRight()) { log.info("error when creating interface:{}, for resource:{}", interfaceNameValue.getKey(), resource.getName()); } else { @@ -365,7 +368,7 @@ public class ResourceImportManager { } } - private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(final Object interfaceJson) { + private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(final Object interfaceJson, final String model) { try { if (interfaceJson instanceof String) { final InterfaceDefinition interfaceDefinition = new InterfaceDefinition(); @@ -374,7 +377,7 @@ public class ResourceImportManager { } if (interfaceJson instanceof Map) { final Map<String, Object> interfaceJsonMap = (Map<String, Object>) interfaceJson; - final InterfaceDefinition interfaceDefinition = interfaceDefinitionHandler.create(interfaceJsonMap); + final InterfaceDefinition interfaceDefinition = interfaceDefinitionHandler.create(interfaceJsonMap, model); return Either.left(interfaceDefinition); } return Either.right(ResultStatusEnum.GENERAL_ERROR); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java index c3c42e27f5..ac195f9315 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java @@ -19,22 +19,11 @@ */ package org.openecomp.sdc.be.servlets; -import com.jcabi.aspects.Loggable; -import fj.data.Either; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.servers.Server; -import io.swagger.v3.oas.annotations.servers.Servers; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; + import javax.inject.Inject; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -47,8 +36,8 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + import org.apache.commons.collections4.ListUtils; -import org.glassfish.jersey.media.multipart.FormDataParam; import org.openecomp.sdc.be.components.impl.CapabilitiesBusinessLogic; import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; @@ -79,6 +68,20 @@ import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.stereotype.Controller; +import com.jcabi.aspects.Loggable; + +import fj.data.Either; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.servers.Server; +import io.swagger.v3.oas.annotations.servers.Servers; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.tags.Tags; + @Loggable(prepend = true, value = Loggable.DEBUG, trim = false) @Path("/v1/catalog") @Tags({@Tag(name = "SDCE-2 APIs")}) @@ -145,7 +148,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "404", description = "Interface lifecycle types not found")}) @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response getInterfaceLifecycleTypes(@Context final HttpServletRequest request, - @HeaderParam(value = Constants.USER_ID_HEADER) String userId) { + @HeaderParam(value = Constants.USER_ID_HEADER) String userId, + @Parameter(description = "model") @QueryParam("model") String modelName) { Wrapper<Response> responseWrapper = new Wrapper<>(); Wrapper<User> userWrapper = new Wrapper<>(); try { @@ -154,7 +158,7 @@ public class TypesFetchServlet extends AbstractValidationsServlet { String url = request.getMethod() + " " + request.getRequestURI(); log.info("Start handle request of {} | modifier id is {}", url, userId); Either<Map<String, InterfaceDefinition>, ResponseFormat> allInterfaceLifecycleTypes = interfaceOperationBusinessLogic - .getAllInterfaceLifecycleTypes(); + .getAllInterfaceLifecycleTypes(modelName); if (allInterfaceLifecycleTypes.isRight()) { log.info("Failed to get all interface lifecycle types. Reason - {}", allInterfaceLifecycleTypes.right().value()); Response errorResponse = buildErrorResponse(allInterfaceLifecycleTypes.right().value()); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java index 4f815a316d..3fe3bd5c42 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java @@ -693,7 +693,7 @@ public class ToscaExportHandler { log.debug("start convert node type for {}", component.getUniqueId()); ToscaNodeType toscaNodeType = createNodeType(component); Either<Map<String, InterfaceDefinition>, StorageOperationStatus> lifecycleTypeEither = interfaceLifecycleOperation - .getAllInterfaceLifecycleTypes(); + .getAllInterfaceLifecycleTypes(component.getModel()); if (lifecycleTypeEither.isRight()) { log.debug("Failed to fetch all interface types :", lifecycleTypeEither.right().value()); return Either.right(ToscaError.GENERAL_ERROR); @@ -1077,7 +1077,7 @@ public class ToscaExportHandler { } Either<Map<String, InterfaceDefinition>, StorageOperationStatus> lifecycleTypeEither = - interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(); + interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(serviceComponent.getModel()); if (lifecycleTypeEither.isRight()) { log.debug("Failed to retrieve global interface types :", lifecycleTypeEither.right().value()); return Either.right(ToscaError.GENERAL_ERROR); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index a9368b2b01..00e0681c8d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -34,12 +34,13 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; -import fj.data.Either; import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; + +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -87,6 +88,8 @@ import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.PolicyException; import org.openecomp.sdc.exception.ResponseFormat; +import fj.data.Either; + public class ResourceImportManagerTest { static ResourceImportManager importManager; @@ -236,7 +239,7 @@ public class ResourceImportManagerTest { operations.put("configure", new OperationDataDefinition()); interfaceDefinition.setOperations(operations ); interfaceTypes.put("tosca.interfaces.node.lifecycle.standard", interfaceDefinition); - when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(interfaceTypes)); + when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(interfaceTypes)); final ImmutablePair<Resource, ActionStatus> createResource = importManager .importNormativeResource(jsonContent, resourceMD, user, true, true); @@ -261,7 +264,7 @@ public class ResourceImportManagerTest { operations.put("configure", new OperationDataDefinition()); interfaceDefinition.setOperations(operations ); interfaceTypes.put("tosca.interfaces.node.lifecycle.standard", interfaceDefinition); - when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(interfaceTypes)); + when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(interfaceTypes)); ImmutablePair<Resource, ActionStatus> createResource = importManager.importNormativeResource(jsonContent, resourceMD, user, true, true); assertNull(createResource.left.getInterfaces()); @@ -285,7 +288,7 @@ public class ResourceImportManagerTest { operations.put("configure", new OperationDataDefinition()); interfaceDefinition.setOperations(operations ); interfaceTypes.put("tosca.interfaces.node.lifecycle.standard", interfaceDefinition); - when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(interfaceTypes)); + when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(interfaceTypes)); ImmutablePair<Resource, ActionStatus> createResource = importManager.importNormativeResource(jsonContent, resourceMD, user, true, true); assertNull(createResource.left.getInterfaces()); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java index f819eceb43..83fa8e2da5 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java @@ -29,7 +29,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.when; -import fj.data.Either; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.nio.file.Path; @@ -39,7 +38,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; + import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -53,6 +54,8 @@ import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.yaml.snakeyaml.Yaml; +import fj.data.Either; + @ExtendWith(MockitoExtension.class) class InterfaceDefinitionHandlerTest { @@ -84,20 +87,20 @@ class InterfaceDefinitionHandlerTest { operations.put(DELETE_OPERATION, new OperationDataDefinition()); interfaceLifecyleStandard.setOperations(operations); interfaceTypes.put(INTERFACE_TYPE, interfaceLifecyleStandard); - when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(interfaceTypes)); + when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(StringUtils.EMPTY)).thenReturn(Either.left(interfaceTypes)); } @Test void testCreateWithLegacyOperationDeclarationSuccess() throws FileNotFoundException { final Map<String, Object> load = loadYaml(Paths.get("interfaceDefinition-legacy.yaml")); - final InterfaceDefinition actualInterfaceDefinition = interfaceDefinitionHandler.create(load); + final InterfaceDefinition actualInterfaceDefinition = interfaceDefinitionHandler.create(load, StringUtils.EMPTY); assertInterfaceDefinition(actualInterfaceDefinition); } @Test void testCreateWithOperationSuccess() throws FileNotFoundException { final Map<String, Object> load = loadYaml(Paths.get("interfaceDefinition-tosca1.3.yaml")); - final InterfaceDefinition actualInterfaceDefinition = interfaceDefinitionHandler.create(load); + final InterfaceDefinition actualInterfaceDefinition = interfaceDefinitionHandler.create(load, StringUtils.EMPTY); assertInterfaceDefinition(actualInterfaceDefinition); } 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 3ab235c779..724bf6ab34 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 @@ -16,7 +16,21 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -57,19 +71,7 @@ import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class InterfaceOperationBusinessLogicTest { @@ -147,7 +149,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void createInterfaceOperationTestOnExistingInterface() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left( Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)))); @@ -161,7 +163,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void createInterfaceOperationTestOnExistingInterfaceInputsFromCapProp() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left( Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)))); @@ -200,7 +202,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void createInterfaceOperationWithoutInterfaceTest() { resource.getInterfaces().clear(); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(interfaceOperation.addInterfaces(any(), any())).thenReturn(Either.left( Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)))); @@ -217,7 +219,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void createInterfaceOperationWithoutInterfaceTestFail() { resource.getInterfaces().clear(); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(interfaceOperation.addInterfaces(any(), any())) .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR)); @@ -231,7 +233,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void shouldFailWhenCreateInterfaceOperationFailedTest() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(interfaceOperation.updateInterfaces(any(), any())) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); @@ -242,7 +244,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void updateInterfaceOperationTestWithArtifactSuccess() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean())) .thenReturn(Either.left(new ArtifactDefinition())); @@ -260,7 +262,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void updateInterfaceOperationTestWithArtifactFailure() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition())); when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean())) @@ -275,7 +277,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void updateInterfaceOperationTestWithoutArtifact() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left( @@ -290,7 +292,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void updateInterfaceOperationTestDoesntExist() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation = interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId, @@ -302,7 +304,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void createInterfaceOperationTestFailOnException() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(interfaceOperation.updateInterfaces(any(), any())).thenThrow(new RuntimeException()); Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither = @@ -315,7 +317,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void createInterfaceOperationTestFailOnFetchinGlobalTypes() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither = interfaceOperationBusinessLogic.createInterfaceOperation(resourceId, @@ -327,7 +329,7 @@ public class InterfaceOperationBusinessLogicTest { @Test public void createInterfaceOperationTestFailOnValidation() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(interfaceOperationValidation .validateInterfaceOperations(any(), any(), any(), anyMap(), anyBoolean())) @@ -510,10 +512,10 @@ public class InterfaceOperationBusinessLogicTest { @Test public void testGetAllInterfaceLifecycleTypes_TypesNotFound() { - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); Either<Map<String, InterfaceDefinition>, ResponseFormat> response = - interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(); + interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(any()); Assert.assertTrue(response.isRight()); } @@ -524,10 +526,10 @@ public class InterfaceOperationBusinessLogicTest { interfaceDefinition.setType(interfaceId); Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>(); interfaceDefinitionMap.put(interfaceDefinition.getUniqueId(), interfaceDefinition); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(interfaceDefinitionMap)); Either<Map<String, InterfaceDefinition>, ResponseFormat> response = - interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(); + interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(StringUtils.EMPTY); Assert.assertEquals(1, response.left().value().size()); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java index acd4cb4128..5c8d522482 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java @@ -239,7 +239,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); // default test when component is Resource @@ -264,7 +264,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { ((Resource) component).setInterfaces(new HashMap<>()); when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); // default test when convertInterfaceNodeType is right result = testSubject.exportComponentInterface(component, false); @@ -296,7 +296,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { component.setName(RESOURCE_NAME); component.setToscaResourceName(RESOURCE_NAME); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); // when convertRequirements is called, make it return the same value as 3rd (index=2) argument. @@ -581,7 +581,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { Either<ToscaTemplate, ToscaError> result; when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST)); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); // default test result = Deencapsulation @@ -600,7 +600,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { component.setInputs(inputs); when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), @@ -729,7 +729,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { when(capabilityRequirementConverter .convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class))) .thenReturn(Either.left(new ToscaNodeTemplate())); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(Collections.emptyMap())); + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap())); when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class))) .thenReturn(Either.left(new ToscaNodeType())); @@ -853,7 +853,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { when(capabilityRequirementConverter .convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class))) .thenReturn(Either.left(new ToscaNodeTemplate())); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(Collections.emptyMap())); + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap())); when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class))) .thenReturn(Either.left(new ToscaNodeType())); @@ -916,7 +916,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { when(capabilityRequirementConverter .convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class))) .thenReturn(Either.right(ToscaError.GENERAL_ERROR)); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(Collections.emptyMap())); + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap())); when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); @@ -967,7 +967,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { componentCache.put("uid", component); when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.right(false)); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(Collections.emptyMap())); + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap())); when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); @@ -1022,7 +1022,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { doReturn(Either.left(component)).when(toscaOperationFacade).getToscaFullElement("id"); when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.left(component)); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(Collections.emptyMap())); + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap())); when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType())); @@ -1087,7 +1087,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))) .thenReturn(Either.left(new Resource())); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container); Assert.assertTrue(result.isRight()); @@ -1105,7 +1105,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { componentInstances.add(instance); container.setComponentInstances(componentInstances); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); Component proxyResource = new Resource(); @@ -1163,7 +1163,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { componentInstances.add(instance); containerService.setComponentInstances(componentInstances); - when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()) + when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())) .thenReturn(Either.left(Collections.emptyMap())); when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Service.class), |