summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-06-16 20:09:40 +0100
committervasraz <vasyl.razinkov@est.tech>2023-06-16 20:09:40 +0100
commit4567889be798f0ac1798c7e489d6cf4f9951d2a6 (patch)
tree5a1808acada72b651829d2dc6522e5b6d3b441a9 /catalog-be/src/test/java
parente72d1667c08d3f018b483cebfb077108206b5e49 (diff)
Support additional metadata in external assets api
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ibae9ae54f0c5e4751a9ada8ee93f169da3a017ee Issue-ID: SDC-4520
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java452
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java105
3 files changed, 247 insertions, 312 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java
index f89d899e00..e591832a47 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,279 +20,213 @@
package org.openecomp.sdc.be.ecomp.converters;
-import static org.assertj.core.api.Assertions.assertThat;
-
import fj.data.Either;
-import mockit.Deencapsulation;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.externalapi.servlet.representation.ArtifactMetadata;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.externalapi.servlet.representation.AssetMetadata;
-import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceAssetDetailedMetadata;
-import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceAssetMetadata;
-import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceInstanceMetadata;
-import org.openecomp.sdc.be.externalapi.servlet.representation.ServiceAssetDetailedMetadata;
-import org.openecomp.sdc.be.externalapi.servlet.representation.ServiceAssetMetadata;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Product;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.exception.ResponseFormat;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-public class AssetMetadataConverterTest {
-
- private AssetMetadataConverter createTestSubject() {
- return new AssetMetadataConverter();
- }
-
- @Test
- public void testConvertToAssetMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- List<? extends Component> componentList = null;
- String serverBaseURL = "";
- boolean detailed = false;
- Either<List<? extends AssetMetadata>, ResponseFormat> result;
-
- // test 1
- testSubject = createTestSubject();
- componentList = null;
- result = testSubject.convertToAssetMetadata(componentList, serverBaseURL, detailed);
- assertThat(result.isLeft()).isTrue();
- }
-
- @Test
- public void testConvertToSingleAssetMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- Resource component = new Resource();
- String serverBaseURL = "";
- boolean detailed = false;
- Either<? extends AssetMetadata, ResponseFormat> result;
- component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- component.setComponentType(ComponentTypeEnum.RESOURCE);
- // default test
- testSubject = createTestSubject();
- result = testSubject.convertToSingleAssetMetadata(component, serverBaseURL, detailed);
- assertThat(result.isLeft()).isTrue();
- }
-
- @Test
- public void testConvertToMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- String serverBaseURL = "";
- boolean detailed = false;
- Resource curr = new Resource();
- Either<? extends AssetMetadata, ResponseFormat> result;
- curr.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- curr.setComponentType(ComponentTypeEnum.RESOURCE);
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "convertToMetadata", ComponentTypeEnum.RESOURCE, serverBaseURL,
- detailed, curr);
- assertThat(result.isLeft()).isTrue();
- }
-
- @Test
- public void testGenerateResourceMeatdata() throws Exception {
- AssetMetadataConverter testSubject;
- String serverBaseURL = "";
- Resource curr = new Resource();
- Either<? extends AssetMetadata, ResponseFormat> result;
- curr.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- curr.setComponentType(ComponentTypeEnum.RESOURCE);
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "generateResourceMeatdata", serverBaseURL, true, curr);
- assertThat(result.isLeft()).isTrue();
- }
-
- @Test
- public void testCreateMetadaObject() throws Exception {
- AssetMetadataConverter testSubject;
- AssetMetadata result;
-
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "createMetadaObject", true, ComponentTypeEnum.RESOURCE);
- assertThat(result).isInstanceOf(AssetMetadata.class);
- }
-
- @Test
- public void testGenerateServiceMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- String serverBaseURL = "";
- boolean detailed = false;
- Service curr = new Service();
- curr.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- curr.setDistributionStatus(DistributionStatusEnum.DISTRIBUTED);
-
- Either<? extends AssetMetadata, ResponseFormat> result;
-
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "generateServiceMetadata", serverBaseURL, detailed, curr);
- assertThat(result.isLeft()).isTrue();
- }
-
- @Test
- public void testConvertToAsset() throws Exception {
- AssetMetadataConverter testSubject;
- ResourceAssetMetadata asset = new ResourceAssetMetadata();
- Resource component = new Resource();
- String serverBaseURL = "";
- ResourceAssetMetadata result;
-
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "convertToAsset", asset, component, serverBaseURL, true);
- assertThat(result).isInstanceOf(ResourceAssetMetadata.class);
- }
-
- @Test
- public void testConvertToResourceMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- ResourceAssetMetadata assetToPopulate = new ResourceAssetMetadata();
- Resource resource = new Resource();
- String serverBaseURL = "";
- boolean detailed = false;
- ResourceAssetMetadata result;
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
-
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "convertToResourceMetadata", assetToPopulate, resource,
- serverBaseURL, true);
- assertThat(result).isInstanceOf(ResourceAssetMetadata.class);
- }
-
- @Test
- public void testConvertToServiceAssetMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- ServiceAssetMetadata assetToPopulate = new ServiceAssetMetadata();
- Service service = new Service();
- service.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- service.setDistributionStatus(DistributionStatusEnum.DISTRIBUTED);
- String serverBaseURL = "";
- boolean detailed = false;
- ServiceAssetMetadata result;
-
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "convertToServiceAssetMetadata", assetToPopulate, service,
- serverBaseURL, true);
- assertThat(result).isInstanceOf(ServiceAssetMetadata.class);
- }
-
- @Test
- public void testConvertToResourceDetailedMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- ResourceAssetDetailedMetadata assetToPopulate = new ResourceAssetDetailedMetadata();
- Resource resource = new Resource();
- String serverBaseURL = "";
- Either<ResourceAssetDetailedMetadata, StorageOperationStatus> result;
-
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "convertToResourceDetailedMetadata", assetToPopulate, resource,
- serverBaseURL);
- assertThat(result.isLeft()).isTrue();
- }
-
- @Test
- public void testConvertToServiceDetailedMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- ServiceAssetDetailedMetadata assetToPopulate = new ServiceAssetDetailedMetadata();
- Service service = new Service();
- Either<ServiceAssetDetailedMetadata, StorageOperationStatus> result;
-
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "convertToServiceDetailedMetadata", assetToPopulate, service);
- assertThat(result.isLeft()).isTrue();
- }
-
- @Test
- public void testPopulateResourceWithArtifacts() throws Exception {
- AssetMetadataConverter testSubject;
- ResourceAssetDetailedMetadata asset = new ResourceAssetDetailedMetadata();
- Resource resource = new Resource();
- Map<String, ArtifactDefinition> artifacts = new HashMap<>();
- ResourceAssetDetailedMetadata result;
-
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "populateResourceWithArtifacts", asset, resource, artifacts);
- assertThat(result).isInstanceOf(ResourceAssetDetailedMetadata.class);
- }
-
- @Test
- public void testPopulateServiceWithArtifacts() throws Exception {
- AssetMetadataConverter testSubject;
- ServiceAssetDetailedMetadata asset = new ServiceAssetDetailedMetadata();
- Service service = new Service();
- Map<String, ArtifactDefinition> artifacts = new HashMap<>();
- ServiceAssetDetailedMetadata result;
- service.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- service.setDistributionStatus(DistributionStatusEnum.DISTRIBUTED);
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "populateServiceWithArtifacts",
- asset, Service.class, artifacts);
- assertThat(result).isInstanceOf(ServiceAssetDetailedMetadata.class);
- }
-
- @Test
- public void testPopulateAssetWithArtifacts() throws Exception {
- AssetMetadataConverter testSubject;
- Resource component = new Resource();
- Map<String, ArtifactDefinition> artifacts = new HashMap<>();
- List<ArtifactMetadata> result;
-
- // test 1
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "populateAssetWithArtifacts", component, artifacts);
- assertThat(result).isNull();
- }
-
- @Test
- public void testConvertToArtifactMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- String componentType = "";
- String componentUUID = "";
- String resourceInstanceName = "";
- ArtifactMetadata result;
-
- // test 1
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "convertToArtifactMetadata", artifact, componentType,
- componentUUID, resourceInstanceName);
- assertThat(result).isInstanceOf(ArtifactMetadata.class);
- }
-
- @Test
- public void testConvertToResourceInstanceMetadata() throws Exception {
- AssetMetadataConverter testSubject;
- List<ComponentInstance> componentInstances = new LinkedList<>();
- String componentType = "";
- String componentUUID = "";
- Either<List<ResourceInstanceMetadata>, StorageOperationStatus> result;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class AssetMetadataConverterTest {
+
+ @InjectMocks
+ @Spy
+ private AssetMetadataConverter testSubject;
+ @Mock
+ private ComponentsUtils componentsUtils;
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+
+ @BeforeEach
+ void setUp() {
+ MockitoAnnotations.openMocks(this);
+ }
+
+ @Test
+ void testConvertToAssetMetadata_emptyComponentList() throws Exception {
+ List<? extends Component> componentList = null;
+ String serverBaseURL = "";
+ boolean detailed = false;
+ Either<List<? extends AssetMetadata>, ResponseFormat> result;
+
+ result = testSubject.convertToAssetMetadata(componentList, serverBaseURL, detailed, null);
+ assertTrue(result.isLeft());
+ }
+
+ @Test
+ void testConvertToAssetMetadata_withComponentList_Service_without_additionalMetadataKeysToInclude() throws Exception {
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setEsId("mock");
+ artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ deploymentArtifacts.put("mock", artifactDefinition);
+ Service component = new Service();
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setComponentType(ComponentTypeEnum.SERVICE);
+ component.setDistributionStatus(DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED);
+ ComponentInstance componentInstance = new ComponentInstance();
+ componentInstance.setComponentUid("mock");
+ componentInstance.setOriginType(OriginTypeEnum.VFC);
+ componentInstance.setDeploymentArtifacts(deploymentArtifacts);
+ component.setComponentInstances(Collections.singletonList(componentInstance));
+ component.setDeploymentArtifacts(deploymentArtifacts);
+ component.setCategories(Collections.singletonList(new CategoryDefinition()));
+ Map<String, String> categorySpecificMetadata = new HashMap<>();
+ categorySpecificMetadata.put("mock_key", "mock_value");
+ component.setCategorySpecificMetadata(categorySpecificMetadata);
+ String serverBaseURL = "";
+ boolean detailed = true;
+
+ when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(new Resource()));
+
+ Either<List<? extends AssetMetadata>, ResponseFormat> result;
+ result = testSubject.convertToAssetMetadata(Collections.singletonList(component), serverBaseURL, detailed, null);
+ assertTrue(result.isLeft());
+ }
+
+ @Test
+ void testConvertToAssetMetadata_withComponentList_Service_with_additionalMetadataKeysToInclude() throws Exception {
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setEsId("mock");
+ artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ deploymentArtifacts.put("mock", artifactDefinition);
+ Service component = new Service();
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setComponentType(ComponentTypeEnum.SERVICE);
+ component.setDistributionStatus(DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED);
+ ComponentInstance componentInstance = new ComponentInstance();
+ componentInstance.setComponentUid("mock");
+ componentInstance.setOriginType(OriginTypeEnum.VFC);
+ componentInstance.setDeploymentArtifacts(deploymentArtifacts);
+ component.setComponentInstances(Collections.singletonList(componentInstance));
+ component.setDeploymentArtifacts(deploymentArtifacts);
+ component.setCategories(Collections.singletonList(new CategoryDefinition()));
+ Map<String, String> categorySpecificMetadata = new HashMap<>();
+ categorySpecificMetadata.put("mock_key", "mock_value");
+ component.setCategorySpecificMetadata(categorySpecificMetadata);
+ String serverBaseURL = "";
+ boolean detailed = false;
+
+ Either<List<? extends AssetMetadata>, ResponseFormat> result;
+ List<String> additionalMetadataKeysToInclude = new ArrayList<>();
+ additionalMetadataKeysToInclude.add("description");
+ additionalMetadataKeysToInclude.add("mock_key");
+ result = testSubject.convertToAssetMetadata(Collections.singletonList(component), serverBaseURL, detailed, additionalMetadataKeysToInclude);
+ assertTrue(result.isLeft());
+ }
+
+ @Test
+ void testConvertToAssetMetadata_withComponentList_Resource() throws Exception {
+ ArtifactDefinition artifactDefinition = new ArtifactDefinition();
+ artifactDefinition.setEsId("mock");
+ artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+ deploymentArtifacts.put("mock", artifactDefinition);
+ Resource component = new Resource();
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setComponentType(ComponentTypeEnum.RESOURCE);
+ ComponentInstance componentInstance = new ComponentInstance();
+ componentInstance.setComponentUid("mock");
+ componentInstance.setOriginType(OriginTypeEnum.VFC);
+ componentInstance.setDeploymentArtifacts(deploymentArtifacts);
+ componentInstance.setNormalizedName("mock");
+ component.setComponentInstances(Collections.singletonList(componentInstance));
+ component.setDeploymentArtifacts(deploymentArtifacts);
+ CategoryDefinition categoryDefinition = new CategoryDefinition();
+ categoryDefinition.setSubcategories(Collections.singletonList(new SubCategoryDefinition()));
+ component.setCategories(Collections.singletonList(categoryDefinition));
+ Map<String, String> categorySpecificMetadata = new HashMap<>();
+ categorySpecificMetadata.put("mock_key", "mock_value");
+ component.setCategorySpecificMetadata(categorySpecificMetadata);
+ String serverBaseURL = "";
+ boolean detailed = true;
+
+ when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(new Resource()));
+
+ Either<List<? extends AssetMetadata>, ResponseFormat> result;
+ List<String> additionalMetadataKeysToInclude = new ArrayList<>();
+ additionalMetadataKeysToInclude.add("description");
+ additionalMetadataKeysToInclude.add("mock_key");
+// additionalMetadataKeysToInclude.add("NoSuchElementException");
+ result = testSubject.convertToAssetMetadata(Collections.singletonList(component), serverBaseURL, detailed, additionalMetadataKeysToInclude);
+ assertTrue(result.isLeft());
+ }
+
+ @Test
+ void testConvertToSingleAssetMetadata_Resource() throws Exception {
+
+ Resource component = new Resource();
+ String serverBaseURL = "";
+ boolean detailed = false;
+ Either<? extends AssetMetadata, ResponseFormat> result;
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setComponentType(ComponentTypeEnum.RESOURCE);
+
+ result = testSubject.convertToSingleAssetMetadata(component, serverBaseURL, detailed, null);
+ assertTrue(result.isLeft());
+ }
+
+ @Test
+ void testConvertToSingleAssetMetadata_Product() throws Exception {
+
+ Product component = new Product();
+ String serverBaseURL = "";
+ boolean detailed = false;
+ Either<? extends AssetMetadata, ResponseFormat> result;
+ component.setComponentType(ComponentTypeEnum.PRODUCT);
+
+ when(componentsUtils.getResponseFormatAdditionalProperty(ActionStatus.COMPONENT_INVALID_CATEGORY)).thenReturn(new ResponseFormat());
+
+ result = testSubject.convertToSingleAssetMetadata(component, serverBaseURL, detailed, null);
+ assertTrue(result.isRight());
+ }
+
+ @Test
+ void testConvertToSingleAssetMetadata_Service() throws Exception {
+
+ Service component = new Service();
+ String serverBaseURL = "";
+ boolean detailed = false;
+ Either<? extends AssetMetadata, ResponseFormat> result;
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setComponentType(ComponentTypeEnum.SERVICE);
+ component.setDistributionStatus(DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED);
+
+ result = testSubject.convertToSingleAssetMetadata(component, serverBaseURL, detailed, null);
+ assertTrue(result.isLeft());
+ }
- // default test
- testSubject = createTestSubject();
- result = Deencapsulation.invoke(testSubject, "convertToResourceInstanceMetadata",
- new Object[] { componentInstances, componentType, componentUUID });
- assertThat(result.isLeft()).isTrue();
- }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java
index 87cb31f39b..6c70d68dcc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java
@@ -152,7 +152,7 @@ class AbstractTemplateServletTest extends JerseyTest {
Mockito.doReturn(Either.left(resourceAssetMetadata)).when(assetMetadataConverter)
.convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
- Mockito.eq(true));
+ Mockito.eq(true), Mockito.eq(null));
String appConfigDir = "src/test/abstract/config";
ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
index d11022a886..5452e29fa7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
-import fj.data.Either;
import java.util.Arrays;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -34,6 +33,8 @@ import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
+import fj.data.Either;
import org.apache.http.HttpStatus;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
@@ -97,7 +98,7 @@ class AssetsDataServletTest extends JerseyTest {
private static final LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
private static final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
private static final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito
- .mock(ComponentInstanceBusinessLogic.class);
+ .mock(ComponentInstanceBusinessLogic.class);
@BeforeAll
@@ -110,7 +111,7 @@ class AssetsDataServletTest extends JerseyTest {
when(session.getServletContext()).thenReturn(servletContext);
when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
- .thenReturn(webAppContextWrapper);
+ .thenReturn(webAppContextWrapper);
when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
@@ -123,8 +124,8 @@ class AssetsDataServletTest extends JerseyTest {
when(resource.getSystemName()).thenReturn("mockvfcmt");
Either<Resource, ResponseFormat> eitherRet = Either.left(resource);
when(componentsUtils
- .convertJsonToObjectUsingObjectMapper(Mockito.any(), Mockito.any(), Mockito.eq(Resource.class),
- Mockito.any(), Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
+ .convertJsonToObjectUsingObjectMapper(Mockito.any(), Mockito.any(), Mockito.eq(Resource.class),
+ Mockito.any(), Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
when(webApplicationContext.getBean(ResourceImportManager.class)).thenReturn(resourceImportManager);
when(webApplicationContext.getBean(ElementBusinessLogic.class)).thenReturn(elementBusinessLogic);
@@ -132,20 +133,20 @@ class AssetsDataServletTest extends JerseyTest {
when(subCategoryDefinition.getName()).thenReturn("Monitoring Template");
when(categoryDefinition.getSubcategories()).thenReturn(Arrays.asList(subCategoryDefinition));
when(elementBusinessLogic.getAllResourceCategories())
- .thenReturn(Either.left(Arrays.asList(categoryDefinition)));
+ .thenReturn(Either.left(Arrays.asList(categoryDefinition)));
when(resourceBusinessLogic
- .createResource(Mockito.eq(resource), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
- .thenReturn(resource);
+ .createResource(Mockito.eq(resource), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenReturn(resource);
when(webApplicationContext.getBean(AssetMetadataConverter.class)).thenReturn(assetMetadataConverter);
when(request.isUserInRole(anyString())).thenReturn(true);
Mockito.doReturn(Either.left(resourceAssetMetadata)).when(assetMetadataConverter)
- .convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
- Mockito.eq(true));
+ .convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
+ Mockito.eq(true), Mockito.eq(null));
String appConfigDir = "src/test/resources/config/catalog-be";
ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
- appConfigDir);
+ appConfigDir);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
@@ -166,21 +167,21 @@ class AssetsDataServletTest extends JerseyTest {
private static void mockResponseFormat() {
when(componentsUtils.getResponseFormat(Mockito.any(ActionStatus.class), Mockito.any(String[].class)))
- .thenAnswer((Answer<ResponseFormat>) invocation -> {
- ResponseFormat ret;
- final ActionStatus actionStatus = invocation.getArgument(0);
- switch (actionStatus) {
- case CREATED: {
- ret = new ResponseFormat(HttpStatus.SC_CREATED);
- break;
+ .thenAnswer((Answer<ResponseFormat>) invocation -> {
+ ResponseFormat ret;
+ final ActionStatus actionStatus = invocation.getArgument(0);
+ switch (actionStatus) {
+ case CREATED: {
+ ret = new ResponseFormat(HttpStatus.SC_CREATED);
+ break;
+ }
+ default: {
+ ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ break;
+ }
}
- default: {
- ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- break;
- }
- }
- return ret;
- });
+ return ret;
+ });
}
@@ -188,27 +189,27 @@ class AssetsDataServletTest extends JerseyTest {
void createVfcmtHappyScenario() {
final JSONObject createRequest = buildCreateJsonRequest();
Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON)
- .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
- .header(Constants.USER_ID_HEADER, "mockAttID")
- .post(Entity.json(createRequest.toJSONString()), Response.class);
+ .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+ .header(Constants.USER_ID_HEADER, "mockAttID")
+ .post(Entity.json(createRequest.toJSONString()), Response.class);
assertEquals(HttpStatus.SC_CREATED, response.getStatus());
}
private static final String BASIC_CREATE_REQUEST = "{\r\n" +
- " \"name\": \"VFCMT_1\",\r\n" +
- " \"description\": \"VFCMT Description\",\r\n" +
- " \"resourceType\" : \"VFCMT\",\r\n" +
- " \"category\": \"Template\",\r\n" +
- " \"subcategory\": \"Monitoring Template\",\r\n" +
- " \"vendorName\" : \"DCAE\",\r\n" +
- " \"vendorRelease\" : \"1.0\",\r\n" +
- " \"tags\": [\r\n" +
- " \"VFCMT_1\"\r\n" +
- " ],\r\n" +
- " \"icon\" : \"defaulticon\",\r\n" +
- " \"contactId\": \"cs0008\"\r\n" +
- "}";
+ " \"name\": \"VFCMT_1\",\r\n" +
+ " \"description\": \"VFCMT Description\",\r\n" +
+ " \"resourceType\" : \"VFCMT\",\r\n" +
+ " \"category\": \"Template\",\r\n" +
+ " \"subcategory\": \"Monitoring Template\",\r\n" +
+ " \"vendorName\" : \"DCAE\",\r\n" +
+ " \"vendorRelease\" : \"1.0\",\r\n" +
+ " \"tags\": [\r\n" +
+ " \"VFCMT_1\"\r\n" +
+ " ],\r\n" +
+ " \"icon\" : \"defaulticon\",\r\n" +
+ " \"contactId\": \"cs0008\"\r\n" +
+ "}";
private JSONObject buildCreateJsonRequest() {
@@ -222,16 +223,16 @@ class AssetsDataServletTest extends JerseyTest {
ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
forceSet(TestProperties.CONTAINER_PORT, "0");
return new ResourceConfig()
- .register(new CrudExternalServlet(componentInstanceBusinessLogic, componentsUtils,
- servletUtils, resourceImportManager, elementBusinessLogic, assetMetadataConverter,
- lifecycleBusinessLogic, resourceBusinessLogic, serviceBusinessLogic))
- .register(new AbstractBinder() {
-
- @Override
- protected void configure() {
- bind(request).to(HttpServletRequest.class);
- }
- })
- .property("contextConfig", context);
+ .register(new CrudExternalServlet(componentInstanceBusinessLogic, componentsUtils,
+ servletUtils, resourceImportManager, elementBusinessLogic, assetMetadataConverter,
+ lifecycleBusinessLogic, resourceBusinessLogic, serviceBusinessLogic))
+ .register(new AbstractBinder() {
+
+ @Override
+ protected void configure() {
+ bind(request).to(HttpServletRequest.class);
+ }
+ })
+ .property("contextConfig", context);
}
}