aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java83
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java419
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java17
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java22
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentAttributeServletTest.java148
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/OutputsServletTest.java263
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java66
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/AttributeConverterTest.java7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java38
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OutputConverterTest.java67
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/AttributeDefinitionTest.java50
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstOutputsMapTest.java70
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceAttribOutputTest.java55
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceOutputTest.java42
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationTest.java284
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationTest.java26
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java237
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java56
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/GetOutputValueDataDefinitionTest.java40
20 files changed, 1834 insertions, 163 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
index 891d2c83ca..8a2cdef16e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -27,14 +27,15 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anySet;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum.RESOURCE_PARAM_NAME;
import fj.data.Either;
import java.util.ArrayList;
@@ -90,10 +91,10 @@ import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
@@ -1740,7 +1741,7 @@ class ComponentInstanceBusinessLogicTest {
when(containerInstanceTypeData.isAllowedForResourceComponent(eq(ResourceTypeEnum.VF), eq(ResourceTypeEnum.VF)))
.thenReturn(false);
actualException = assertThrows(ByActionStatusComponentException.class, () -> {
- componentInstanceBusinessLogic.createComponentInstance(ComponentTypeEnum.RESOURCE_PARAM_NAME, COMPONENT_ID, USER_ID, ci);
+ componentInstanceBusinessLogic.createComponentInstance(RESOURCE_PARAM_NAME, COMPONENT_ID, USER_ID, ci);
});
//then
assertThat(actualException.getActionStatus()).isEqualTo(ActionStatus.CONTAINER_CANNOT_CONTAIN_INSTANCE);
@@ -1875,14 +1876,85 @@ class ComponentInstanceBusinessLogicTest {
// Check graph db change was committed
verify(janusGraphDao, times(1)).commit();
}
-
+
+ @Test
+ void testGetComponentInstanceAttributesById_success() {
+ final ComponentInstanceAttribute componentInstanceAttribute = new ComponentInstanceAttribute();
+ componentInstanceAttribute.setComponentInstanceId(TO_INSTANCE_ID);
+
+ final HashMap<String, List<ComponentInstanceAttribute>> map = new HashMap<>();
+ map.put(TO_INSTANCE_ID, Arrays.asList(componentInstanceAttribute));
+ resource.setComponentInstancesAttributes(map);
+
+ final Either<Component, StorageOperationStatus> leftServiceOp = Either.left(resource);
+ doReturn(leftServiceOp).when(toscaOperationFacade).getToscaElement(COMPONENT_ID);
+
+ final List<ComponentInstanceAttribute> result = componentInstanceBusinessLogic
+ .getComponentInstanceAttributesById(RESOURCE_PARAM_NAME, COMPONENT_ID, TO_INSTANCE_ID, USER_ID);
+ assertThat(result).isNotNull().isNotEmpty();
+ verify(toscaOperationFacade, times(1)).getToscaElement(COMPONENT_ID);
+ }
+
+ @Test
+ void testGetComponentInstanceAttributesById_fail_missing_ComponentInstancesAttributes() {
+ final Either<Component, StorageOperationStatus> leftServiceOp = Either.left(resource);
+ doReturn(leftServiceOp).when(toscaOperationFacade).getToscaElement(COMPONENT_ID);
+
+ final List<ComponentInstanceAttribute> result = componentInstanceBusinessLogic
+ .getComponentInstanceAttributesById(RESOURCE_PARAM_NAME, COMPONENT_ID, TO_INSTANCE_ID, USER_ID);
+ assertThat(result).isNotNull().isEmpty();
+ verify(toscaOperationFacade, times(1)).getToscaElement(COMPONENT_ID);
+ }
+
+ @Test
+ void testGetComponentInstanceAttributesById_fail_getToscaElement() {
+ final ComponentInstanceAttribute componentInstanceAttribute = new ComponentInstanceAttribute();
+ componentInstanceAttribute.setComponentInstanceId(TO_INSTANCE_ID);
+
+ final HashMap<String, List<ComponentInstanceAttribute>> map = new HashMap<>();
+ map.put(TO_INSTANCE_ID, Arrays.asList(componentInstanceAttribute));
+ resource.setComponentInstancesAttributes(map);
+
+ final Either<Object, StorageOperationStatus> right = Either.right(StorageOperationStatus.BAD_REQUEST);
+ doReturn(right).when(toscaOperationFacade).getToscaElement(COMPONENT_ID);
+ doReturn(ActionStatus.BAD_REQUEST_MISSING_RESOURCE).when(componentsUtils).convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST);
+
+ assertThrows(ByActionStatusComponentException.class, () -> {
+ final List<ComponentInstanceAttribute> result = componentInstanceBusinessLogic
+ .getComponentInstanceAttributesById(RESOURCE_PARAM_NAME, COMPONENT_ID, TO_INSTANCE_ID, USER_ID);
+
+ });
+
+ }
+
+ @Test
+ void testGetComponentInstanceAttributesById_fail_getResourceInstanceById() {
+ final ComponentInstanceAttribute componentInstanceAttribute = new ComponentInstanceAttribute();
+ componentInstanceAttribute.setComponentInstanceId(TO_INSTANCE_ID);
+
+ final HashMap<String, List<ComponentInstanceAttribute>> map = new HashMap<>();
+ map.put(TO_INSTANCE_ID, Arrays.asList(componentInstanceAttribute));
+ resource.setComponentInstancesAttributes(map);
+
+ final Either<Component, StorageOperationStatus> leftServiceOp = Either.left(resource);
+ doReturn(leftServiceOp).when(toscaOperationFacade).getToscaElement(COMPONENT_ID);
+ doReturn(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND_ON_SERVICE).when(componentsUtils).convertFromStorageResponse(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND);
+
+ assertThrows(ByActionStatusComponentException.class, () -> {
+ final List<ComponentInstanceAttribute> result = componentInstanceBusinessLogic
+ .getComponentInstanceAttributesById(RESOURCE_PARAM_NAME, COMPONENT_ID, "", USER_ID);
+
+ });
+
+ }
+
private ComponentInstance createServiceSubstitutionComponentInstance() {
final ComponentInstance instanceToBeCreated = new ComponentInstance();
instanceToBeCreated.setName(COMPONENT_INSTANCE_NAME);
instanceToBeCreated.setUniqueId(COMPONENT_INSTANCE_ID);
instanceToBeCreated.setComponentUid(ORIGIN_COMPONENT_ID);
instanceToBeCreated.setOriginType(OriginTypeEnum.ServiceSubstitution);
-
+
return instanceToBeCreated;
}
@@ -1896,7 +1968,6 @@ class ComponentInstanceBusinessLogicTest {
return originComponent;
}
-
private Component createServiceSubstitutionServiceDerivedFromComponent() {
final Resource component = new Resource();
component.setLifecycleState(LifecycleStateEnum.CERTIFIED);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java
new file mode 100644
index 0000000000..4c74b5f640
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java
@@ -0,0 +1,419 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.components.impl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import fj.data.Either;
+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 java.util.Optional;
+import java.util.stream.Collectors;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.attribute.AttributeDeclarationOrchestrator;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
+import org.openecomp.sdc.be.components.validation.UserValidations;
+import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstOutputsMap;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribOutput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.OutputDefinition;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.AttributeOperation;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+class OutputsBusinessLogicTest {
+
+ private static final String COMPONENT_INSTANCE_ID = "instanceId";
+ private static final String COMPONENT_ID = "componentId";
+ private static final String USER_ID = "userId";
+ private static final String OUTPUT_ID = "outputId";
+ private static final String OUTPUT_TYPE = "string";
+ private static final String LISTOUTPUT_NAME = "listOutput";
+ private static final String LISTOUTPUT_SCHEMA_TYPE = "org.onap.datatypes.listoutput";
+ private static final String LISTOUTPUT_PROP1_NAME = "prop1";
+ private static final String LISTOUTPUT_PROP1_TYPE = "string";
+ private static final String LISTOUTPUT_PROP2_NAME = "prop2";
+ private static final String LISTOUTPUT_PROP2_TYPE = "integer";
+ private static final String OLD_VALUE = "old value";
+ private static final String NEW_VALUE = "new value";
+ private final ConfigurationManager configurationManager =
+ new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be"));
+
+ @Mock
+ private ComponentsUtils componentsUtilsMock;
+
+ @Mock
+ private UserBusinessLogic userAdminMock;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacadeMock;
+
+ @Mock
+ private UserValidations userValidations;
+
+ @Mock
+ private IGraphLockOperation graphLockOperation;
+
+ @Mock
+ private AttributeDeclarationOrchestrator attributeDeclarationOrchestrator;
+
+ @Mock
+ private ApplicationDataTypeCache applicationDataTypeCache;
+
+ @Mock
+ private AttributeOperation attributeOperation;
+
+ @Mock
+ private JanusGraphDao janusGraphDao;
+
+ @InjectMocks
+ private OutputsBusinessLogic testInstance;
+
+ private Service service;
+
+ private Map<String, List<ComponentInstanceOutput>> instanceOutputMap;
+ private List<ComponentInstanceOutput> outputsList;
+
+ @BeforeEach
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ service = new Service();
+ service.setUniqueId(COMPONENT_ID);
+ service.setLastUpdaterUserId(USER_ID);
+ service.setIsDeleted(false);
+ service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+
+ testInstance.setUserValidations(userValidations);
+ testInstance.setToscaOperationFacade(toscaOperationFacadeMock);
+ testInstance.setGraphLockOperation(graphLockOperation);
+ testInstance.setComponentsUtils(componentsUtilsMock);
+ testInstance.setJanusGraphDao(janusGraphDao);
+ testInstance.setApplicationDataTypeCache(applicationDataTypeCache);
+ testInstance.setAttributeOperation(attributeOperation);
+
+ // add a ComponentInstance
+ final ComponentInstance componentInstance = new ComponentInstance();
+ componentInstance.setUniqueId(COMPONENT_INSTANCE_ID);
+ service.setComponentInstances(Collections.singletonList(componentInstance));
+
+ instanceOutputMap = new HashMap<>();
+ final ComponentInstanceOutput componentInstanceOutput = new ComponentInstanceOutput();
+ componentInstanceOutput.setOutputId(OUTPUT_ID);
+ componentInstanceOutput.setName(OUTPUT_ID);
+ outputsList = Collections.singletonList(componentInstanceOutput);
+ instanceOutputMap.put(COMPONENT_INSTANCE_ID, outputsList);
+ instanceOutputMap.put("someOutputId", Collections.singletonList(new ComponentInstanceOutput()));
+ service.setComponentInstancesOutputs(instanceOutputMap);
+ when(userValidations.validateUserExists(USER_ID)).thenReturn(new User());
+ when(userAdminMock.getUser(USER_ID, false)).thenReturn(new User());
+ }
+
+ @Test
+ void getComponentInstanceOutputs_ComponentInstanceNotExist() {
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ final Either<List<ComponentInstanceOutput>, ResponseFormat> componentInstanceOutputs = testInstance
+ .getComponentInstanceOutputs(USER_ID, COMPONENT_ID, "nonExisting");
+ assertThat(componentInstanceOutputs.isRight()).isTrue();
+ verify(componentsUtilsMock).getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND);
+ }
+
+ @Test
+ void getComponentInstanceOutputs_emptyOutputsMap() {
+ service.setComponentInstancesOutputs(Collections.emptyMap());
+ getComponents_emptyOutputs(service);
+ }
+
+ @Test
+ void getComponentInstanceOutputs_nullOutputsMap() {
+ service.setComponentInstancesOutputs(null);
+ getComponents_emptyOutputs(service);
+ }
+
+ @Test
+ void getComponentInstanceOutputs_instanceHasNoOutputs() {
+ service.setComponentInstancesOutputs(Collections.singletonMap("someOutputId", new ArrayList<>()));
+ getComponents_emptyOutputs(service);
+ }
+
+ @Test
+ void getComponentInstanceOutputs() {
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ final Either<List<ComponentInstanceOutput>, ResponseFormat> componentInstanceOutputs = testInstance
+ .getComponentInstanceOutputs(USER_ID, COMPONENT_ID, COMPONENT_INSTANCE_ID);
+ assertEquals("outputId", componentInstanceOutputs.left().value().get(0).getOutputId());
+ }
+
+ @Test
+ void testDeclareAttributes() {
+ service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ service.setLastUpdaterUserId(USER_ID);
+ final ComponentInstOutputsMap componentInstOutputsMap = new ComponentInstOutputsMap();
+ final Map<String, List<ComponentInstanceAttribOutput>> propertiesForDeclaration = new HashMap<>();
+ propertiesForDeclaration.put(COMPONENT_ID, getPropertiesListForDeclaration());
+
+ final List<OutputDefinition> declaredPropertiesToOutputs = getDeclaredProperties();
+ initMockitoStubbings(declaredPropertiesToOutputs);
+
+ final Either<List<OutputDefinition>, ResponseFormat> declaredPropertiesEither =
+ testInstance.declareAttributes(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, componentInstOutputsMap);
+
+ assertThat(declaredPropertiesEither.isLeft()).isTrue();
+
+ final List<OutputDefinition> declaredProperties = declaredPropertiesEither.left().value();
+ assertThat(CollectionUtils.isNotEmpty(declaredProperties)).isTrue();
+ assertEquals(1, declaredProperties.size());
+ assertEquals(declaredProperties, declaredPropertiesToOutputs);
+ }
+
+ @Test
+ void testDeclareAttributes_fail() {
+ service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ service.setLastUpdaterUserId(USER_ID);
+ final ComponentInstOutputsMap componentInstOutputsMap = new ComponentInstOutputsMap();
+ final Map<String, List<ComponentInstanceAttribOutput>> propertiesForDeclaration = new HashMap<>();
+ propertiesForDeclaration.put(COMPONENT_ID, getPropertiesListForDeclaration());
+
+ final List<OutputDefinition> declaredPropertiesToOutputs = getDeclaredProperties();
+ initMockitoStubbings(declaredPropertiesToOutputs);
+ when(attributeDeclarationOrchestrator.declareAttributesToOutputs(any(), any())).thenThrow(ByResponseFormatComponentException.class);
+ final Either<List<OutputDefinition>, ResponseFormat> declaredPropertiesEither =
+ testInstance.declareAttributes(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, componentInstOutputsMap);
+
+ assertThat(declaredPropertiesEither.isRight()).isTrue();
+
+ }
+
+ private void initMockitoStubbings(List<OutputDefinition> declaredPropertiesToOutputs) {
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(
+ Either.left(service));
+ when(attributeDeclarationOrchestrator.declareAttributesToOutputs(any(), any())).thenReturn(Either.left(
+ declaredPropertiesToOutputs));
+ when(toscaOperationFacadeMock.addOutputsToComponent(any(), any())).thenReturn(Either.left(declaredPropertiesToOutputs));
+ when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
+ when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
+ when(graphLockOperation.unlockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
+ }
+
+ private void getComponents_emptyOutputs(Service service) {
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ final Either<List<ComponentInstanceOutput>, ResponseFormat> componentInstanceOutputs = testInstance
+ .getComponentInstanceOutputs(USER_ID, COMPONENT_ID, COMPONENT_INSTANCE_ID);
+ assertEquals(Collections.emptyList(), componentInstanceOutputs.left().value());
+ }
+
+ private List<ComponentInstanceAttribOutput> getPropertiesListForDeclaration() {
+ return outputsList.stream().map(this::getPropertyForDeclaration).collect(Collectors.toList());
+ }
+
+ private ComponentInstanceAttribOutput getPropertyForDeclaration(ComponentInstanceOutput componentInstanceOutput) {
+ final ComponentInstanceAttribOutput propOutput = new ComponentInstanceAttribOutput();
+ propOutput.setOutput(componentInstanceOutput);
+ propOutput.setAttributesName(componentInstanceOutput.getName());
+
+ return propOutput;
+ }
+
+ private List<OutputDefinition> getDeclaredProperties() {
+ return outputsList.stream().map(OutputDefinition::new).collect(Collectors.toList());
+ }
+
+ private OutputDefinition setUpListOutput() {
+ final OutputDefinition listOutput = new OutputDefinition();
+ listOutput.setName(LISTOUTPUT_NAME);
+ listOutput.setType("list");
+ return listOutput;
+ }
+
+ @Test
+ void test_deleteOutput_listOutput_fail_getComponent() throws Exception {
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ when(componentsUtilsMock.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND)).thenReturn(ActionStatus.RESOURCE_NOT_FOUND);
+
+ try {
+ testInstance.deleteOutput(COMPONENT_ID, USER_ID, LISTOUTPUT_NAME);
+ } catch (ComponentException e) {
+ assertEquals(ActionStatus.RESOURCE_NOT_FOUND, e.getActionStatus());
+ verify(toscaOperationFacadeMock, times(1)).getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class));
+ return;
+ }
+ fail();
+ }
+
+ @Test
+ void test_deleteOutput_listOutput_fail_validateOutput() throws Exception {
+ final OutputDefinition listOutput = setUpListOutput();
+ final String outputId = COMPONENT_ID + "." + listOutput.getName();
+ listOutput.setUniqueId(outputId);
+ service.setOutputs(Collections.singletonList(listOutput));
+ final String NONEXIST_OUTPUT_NAME = "myOutput";
+
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
+ .thenReturn(Either.left(service));
+
+ try {
+ testInstance.deleteOutput(COMPONENT_ID, USER_ID, NONEXIST_OUTPUT_NAME);
+ } catch (ComponentException e) {
+ assertEquals(ActionStatus.OUTPUT_IS_NOT_CHILD_OF_COMPONENT, e.getActionStatus());
+ verify(toscaOperationFacadeMock, times(1)).getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class));
+ return;
+ }
+ fail();
+ }
+
+ @Test
+ void test_deleteOutput_listOutput_fail_lockComponent() throws Exception {
+ final OutputDefinition listOutput = setUpListOutput();
+ final String outputId = COMPONENT_ID + "." + listOutput.getName();
+ listOutput.setUniqueId(outputId);
+ service.setOutputs(Collections.singletonList(listOutput));
+
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
+ .thenReturn(Either.left(service));
+ when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.NOT_FOUND);
+ when(componentsUtilsMock.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND, ComponentTypeEnum.SERVICE))
+ .thenReturn(ActionStatus.SERVICE_NOT_FOUND);
+
+ try {
+ testInstance.deleteOutput(COMPONENT_ID, USER_ID, outputId);
+ } catch (ComponentException e) {
+ assertEquals(ActionStatus.SERVICE_NOT_FOUND, e.getActionStatus());
+ verify(toscaOperationFacadeMock, times(1)).getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class));
+ verify(graphLockOperation, times(1)).lockComponent(COMPONENT_ID, NodeTypeEnum.Service);
+ return;
+ }
+ fail();
+ }
+
+ @Test
+ void test_deleteOutput_listOutput_fail_deleteOutput() throws Exception {
+ final OutputDefinition listOutput = setUpListOutput();
+ final String outputId = COMPONENT_ID + "." + listOutput.getName();
+ listOutput.setUniqueId(outputId);
+ service.setOutputs(Collections.singletonList(listOutput));
+
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
+ .thenReturn(Either.left(service));
+ when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacadeMock.deleteOutputOfResource(service, listOutput.getName())).thenReturn(StorageOperationStatus.BAD_REQUEST);
+ when(componentsUtilsMock.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST)).thenReturn(ActionStatus.INVALID_CONTENT);
+
+ try {
+ testInstance.deleteOutput(COMPONENT_ID, USER_ID, outputId);
+ } catch (ComponentException e) {
+ assertEquals(ActionStatus.INVALID_CONTENT, e.getActionStatus());
+ verify(toscaOperationFacadeMock, times(1)).getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class));
+ verify(graphLockOperation, times(1)).lockComponent(COMPONENT_ID, NodeTypeEnum.Service);
+ verify(toscaOperationFacadeMock, times(1)).deleteOutputOfResource(service, listOutput.getName());
+ return;
+ }
+ fail();
+ }
+
+ @Test
+ void test_deleteOutput_output_fail_unDeclare() throws Exception {
+ final OutputDefinition listOutput = setUpListOutput();
+ final String outputId = COMPONENT_ID + "." + listOutput.getName();
+ listOutput.setUniqueId(outputId);
+ service.setOutputs(Collections.singletonList(listOutput));
+
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
+ .thenReturn(Either.left(service));
+ when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacadeMock.deleteOutputOfResource(service, listOutput.getName())).thenReturn(StorageOperationStatus.OK);
+ when(attributeDeclarationOrchestrator.unDeclareAttributesAsOutputs(service, listOutput)).thenReturn(StorageOperationStatus.BAD_REQUEST);
+ when(componentsUtilsMock.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST)).thenReturn(ActionStatus.INVALID_CONTENT);
+
+ try {
+ testInstance.deleteOutput(COMPONENT_ID, USER_ID, outputId);
+ } catch (ComponentException e) {
+ assertEquals(ActionStatus.INVALID_CONTENT, e.getActionStatus());
+ verify(attributeDeclarationOrchestrator, times(1)).unDeclareAttributesAsOutputs(service, listOutput);
+ return;
+ }
+ fail();
+ }
+
+ @Test
+ void test_deleteOutput_output_success() throws Exception {
+ final OutputDefinition listOutput = setUpListOutput();
+ final String outputId = COMPONENT_ID + "." + listOutput.getName();
+ listOutput.setUniqueId(outputId);
+ service.setOutputs(Collections.singletonList(listOutput));
+
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
+ .thenReturn(Either.left(service));
+ when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacadeMock.deleteOutputOfResource(service, listOutput.getName())).thenReturn(StorageOperationStatus.OK);
+ when(attributeDeclarationOrchestrator.unDeclareAttributesAsOutputs(service, listOutput)).thenReturn(StorageOperationStatus.OK);
+
+ testInstance.deleteOutput(COMPONENT_ID, USER_ID, outputId);
+ verify(attributeDeclarationOrchestrator, times(1)).unDeclareAttributesAsOutputs(service, listOutput);
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
index d219347fc4..09f4ac72de 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
@@ -241,7 +241,7 @@ public class ResourceBusinessLogicTest {
user.setRole(Role.ADMIN.name());
when(mockUserAdmin.getUser("jh0003", false)).thenReturn(user);
- when(userValidations.validateUserExists(eq(user.getUserId()))).thenReturn(user);
+ when(userValidations.validateUserExists(user.getUserId())).thenReturn(user);
when(userValidations.validateUserNotEmpty(eq(user), anyString())).thenReturn(user);
// Servlet Context attributes
when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
@@ -1620,7 +1620,7 @@ public class ResourceBusinessLogicTest {
assertThat(createOrUpdateResource).isNotNull();
Mockito.verify(toscaOperationFacade, times(1))
- .createToscaComponent(eq(resourceToUpdtae));
+ .createToscaComponent(resourceToUpdtae);
Mockito.verify(toscaOperationFacade, Mockito.times(0))
.overrideComponent(any(Resource.class), any(Resource.class));
Mockito.verify(lifecycleBl, Mockito.times(0))
@@ -1663,7 +1663,7 @@ public class ResourceBusinessLogicTest {
assertThat(createOrUpdateResource).isNotNull();
Mockito.verify(toscaOperationFacade, times(1))
- .createToscaComponent(eq(resourceToUpdate));
+ .createToscaComponent(resourceToUpdate);
Mockito.verify(toscaOperationFacade, times(0))
.overrideComponent(any(Resource.class), any(Resource.class));
Mockito.verify(lifecycleBl, times(0))
@@ -2187,6 +2187,7 @@ public class ResourceBusinessLogicTest {
Resource resource = getResourceWithType("HEAT_VOL", "org.openecomp.groups.VfModule");
resource.setGroups(null);
bl.updateVolumeGroup(resource);
+ assertThat(resource.getGroups()).isNull();
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java
index 0c6ba53491..0dad76ebfe 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java
@@ -30,6 +30,7 @@ import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
@@ -132,6 +133,22 @@ public abstract class ComponentBuilder<T extends Component, B extends ComponentB
return self();
}
+ public ComponentBuilder<T, B> addOutput(final OutputDefinition output) {
+ if (component.getOutputs() == null) {
+ component.setOutputs(new ArrayList<>());
+ }
+ component.getOutputs().add(output);
+ return self();
+ }
+
+ public ComponentBuilder<T, B> addOutput(final String outputName) {
+ final OutputDefinition outputDefinition = new OutputDefinition();
+ outputDefinition.setName(outputName);
+ outputDefinition.setUniqueId(outputName);
+ this.addOutput(outputDefinition);
+ return self();
+ }
+
public ComponentBuilder<T, B> addInstanceProperty(String instanceId, ComponentInstanceProperty prop) {
if (component.getComponentInstancesProperties() == null) {
component.setComponentInstancesProperties(new HashMap<>());
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java
index ffe3d06e2a..f163b51f66 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java
@@ -48,6 +48,7 @@ import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
@@ -61,6 +62,7 @@ public class UiComponentDataConverterTest {
private PolicyDefinition policy1, policy2;
private GroupDefinition group1, group2;
private InputDefinition input1;
+ private OutputDefinition output;
private PropertyDefinition propertyDef;
private InterfaceDefinition interfaceDef;
@@ -149,6 +151,7 @@ public class UiComponentDataConverterTest {
public void getUiDataTransferFromResourceByParams_All() {
Resource resourceWithGroups = buildResourceWithGroups();
Resource resourceWithInputs = buildResourceWithInputs();
+ Resource resourceWithOutputs = buildResourceWithOutputs();
UiComponentDataTransfer componentDTO1 = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resourceWithGroups, Collections.singletonList("PROPERTIES"));
UiComponentDataTransfer componentDTO2 = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resourceWithGroups, Collections.singletonList("properties"));
@@ -160,6 +163,7 @@ public class UiComponentDataConverterTest {
UiComponentDataTransfer componentDTO8 = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resourceWithGroups, Collections.singletonList("inputs"));
UiComponentDataTransfer componentDTO81 = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resourceWithInputs, Collections.singletonList("inputs"));
+ UiComponentDataTransfer componentDTO82 = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resourceWithOutputs, Collections.singletonList("outputs"));
UiComponentDataTransfer componentDTO9 = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resourceWithGroups, Collections.singletonList("users"));
UiComponentDataTransfer componentDTO10 = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resourceWithGroups, Collections.singletonList("componentInstances"));
@@ -202,7 +206,7 @@ public class UiComponentDataConverterTest {
@Test
public void getUiDataTransferFromServiceByParams_METADATA() {
UiServiceDataTransfer componentDTO = (UiServiceDataTransfer) uiComponentDataConverter.getUiDataTransferFromServiceByParams(new Service(), Collections.singletonList("metadata"));
- assertThat(componentDTO.getMetadata().getNamingPolicy()).isEqualTo("");
+ assertThat(componentDTO.getMetadata().getNamingPolicy()).isEmpty();
}
@Test
@@ -348,22 +352,30 @@ public class UiComponentDataConverterTest {
.build();
}
- private Resource buildResourceWithParameter(String field) {
- ResourceBuilder res = new ResourceBuilder();
+ private Resource buildResourceWithOutputs() {
+ return new ResourceBuilder()
+ .addOutput(output)
+ .build();
+ }
+
+ private Resource buildResourceWithParameter(final String field) {
+ final ResourceBuilder res = new ResourceBuilder();
switch(field){
case "inputs":
res.addInput(input1);
break;
+ case "outputs":
+ res.addOutput(output);
+ break;
case "properties":
//res.addProperty(propertyDef);
break;
}
-
-
return new ResourceBuilder()
.addInput(input1)
+ .addOutput(output)
.build();
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentAttributeServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentAttributeServletTest.java
new file mode 100644
index 0000000000..123ef9a5ec
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentAttributeServletTest.java
@@ -0,0 +1,148 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.servlets;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+import fj.data.Either;
+import java.util.Arrays;
+import java.util.List;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.core.Response;
+import org.assertj.core.api.Assertions;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.junit.Assert;
+import org.junit.jupiter.api.AfterEach;
+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.Spy;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.openecomp.sdc.be.components.impl.AttributeBusinessLogic;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.WebAppContextWrapper;
+import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.springframework.web.context.WebApplicationContext;
+
+@ExtendWith(MockitoExtension.class)
+class ComponentAttributeServletTest extends JerseySpringBaseTest {
+
+ @Mock
+ private ServletContext context;
+ @Mock
+ private WebAppContextWrapper wrapper;
+ @Mock
+ private WebApplicationContext webAppContext;
+ @Mock
+ private HttpSession session;
+ @Mock
+ private AttributeBusinessLogic attributeBusinessLogic;
+ @Mock
+ private ComponentsUtils componentsUtils;
+ @InjectMocks
+ @Spy
+ private ComponentAttributeServlet componentAttributeServlet;
+
+ private static final String SERVICE_ID = "service1";
+ private static final String RESOURCE_ID = "resource1";
+ private static final String USER_ID = "jh0003";
+ private static final String VALID_PROPERTY_NAME = "valid_name_123";
+ private static final String INVALID_PROPERTY_NAME = "invalid_name_$.&";
+ private static final String STRING_TYPE = "string";
+
+ @BeforeEach
+ public void initClass() throws Exception {
+ super.setUp();
+ when(request.getSession()).thenReturn(session);
+ }
+
+ @AfterEach
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ @Test
+ void getAttributeListInService_success() {
+ AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName(VALID_PROPERTY_NAME);
+ attributeDefinition.setType(STRING_TYPE);
+
+ List<AttributeDefinition> attributeDefinitionEntryData = Arrays.asList(attributeDefinition);
+ when(attributeBusinessLogic.getAttributesList(any(), any())).thenReturn(Either.left(attributeDefinitionEntryData));
+
+ Response attributeInService = componentAttributeServlet.getAttributeListInService(SERVICE_ID, request, USER_ID);
+
+ Assert.assertEquals(HttpStatus.OK_200.getStatusCode(), attributeInService.getStatus());
+ }
+
+ @Test
+ void getAttributeListInService_fail() {
+ when(attributeBusinessLogic.getAttributesList(any(), any()))
+ .thenReturn(Either.right(new ResponseFormat(Response.Status.NOT_FOUND.getStatusCode())));
+
+ Response attributeInService = componentAttributeServlet.getAttributeListInService(SERVICE_ID, request, USER_ID);
+
+ Assertions.assertThat(attributeInService).isNotNull();
+ Assertions.assertThat(attributeInService.getStatus()).isEqualTo(Response.Status.NOT_FOUND.getStatusCode());
+ }
+
+ @Test
+ void getAttributeListInResource_success() {
+ AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName(VALID_PROPERTY_NAME);
+ attributeDefinition.setType(STRING_TYPE);
+
+ List<AttributeDefinition> attributeDefinitionEntryData = Arrays.asList(attributeDefinition);
+ when(attributeBusinessLogic.getAttributesList(any(), any())).thenReturn(Either.left(attributeDefinitionEntryData));
+ when(attributeBusinessLogic.getAttributesList(any(), any())).thenReturn(Either.left(attributeDefinitionEntryData));
+
+ Response attributeInService =
+ componentAttributeServlet.getAttributeListInResource(RESOURCE_ID, request, USER_ID);
+
+ Assert.assertEquals(HttpStatus.OK_200.getStatusCode(), attributeInService.getStatus());
+ }
+
+ @Test
+ void getAttributeListInResource_fail() {
+ when(session.getServletContext()).thenReturn(context);
+ when(context.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(wrapper);
+ when(wrapper.getWebAppContext(any())).thenReturn(webAppContext);
+ when(webAppContext.getBean(ComponentsUtils.class)).thenReturn(componentsUtils);
+ when(attributeBusinessLogic.getAttributesList(any(), any())).thenThrow(new RuntimeException());
+
+ ResponseFormat responseFormat = new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode());
+
+ when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(responseFormat);
+
+ Response attributeInService = componentAttributeServlet.getAttributeListInResource(SERVICE_ID, request, USER_ID);
+
+ Assertions.assertThat(attributeInService).isNotNull();
+ Assertions.assertThat(attributeInService.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/OutputsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/OutputsServletTest.java
new file mode 100644
index 0000000000..6b0cf70ecb
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/OutputsServletTest.java
@@ -0,0 +1,263 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.servlets;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum.RESOURCE;
+
+import fj.data.Either;
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Response;
+import org.assertj.core.api.Assertions;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.components.impl.OutputsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ResourceImportManager;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.config.SpringConfig;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.ServletUtils;
+import org.openecomp.sdc.be.impl.WebAppContextWrapper;
+import org.openecomp.sdc.be.model.ComponentInstOutputsMap;
+import org.openecomp.sdc.be.model.OutputDefinition;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.be.servlets.exception.ComponentExceptionMapper;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
+
+@TestInstance(Lifecycle.PER_CLASS)
+class OutputsServletTest extends JerseyTest {
+
+ private static final String USER_ID = "jh0003";
+ private static final String COMPONENT_ID = "componentId";
+ private static final String RESOURCES = "resources";
+ private static final String COMPONENT_INST_OUTPUTS_MAP_OBJ = "componentInstOutputsMapObj";
+ private static final String OUTPUT_ID = "outputId";
+ private static final String INSTANCE_ID = "instanceId";
+ private static final String COMPONENT_UID = "originComponentUid";
+
+ private final UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class);
+ private final OutputsBusinessLogic outputsBusinessLogic = mock(OutputsBusinessLogic.class);
+ private final ComponentInstanceBusinessLogic componentInstanceBL = mock(ComponentInstanceBusinessLogic.class);
+ private final HttpSession httpSession = mock(HttpSession.class);
+ private final ServletContext servletContext = mock(ServletContext.class);
+ private final WebApplicationContext webApplicationContext = mock(WebApplicationContext.class);
+ private final ComponentsUtils componentsUtils = mock(ComponentsUtils.class);
+ private final ServletUtils servletUtils = mock(ServletUtils.class);
+ private final ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
+ private final HttpServletRequest request = mock(HttpServletRequest.class);
+ private final WebAppContextWrapper wrapper = mock(WebAppContextWrapper.class);
+
+ @Override
+ @BeforeEach
+ public void setUp() throws Exception {
+ super.setUp();
+ when(request.getSession()).thenReturn(httpSession);
+ when(httpSession.getServletContext()).thenReturn(servletContext);
+ when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(wrapper);
+ when(wrapper.getWebAppContext(any())).thenReturn(webApplicationContext);
+ when(webApplicationContext.getBean(OutputsBusinessLogic.class)).thenReturn(outputsBusinessLogic);
+ when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
+ }
+
+ @Override
+ @AfterEach
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ @Test
+ void test_getComponentInstanceOutputs_success() {
+ final Either<List<OutputDefinition>, ResponseFormat> listResponseFormatEither = Either.left(new ArrayList<>());
+ doReturn(listResponseFormatEither).when(outputsBusinessLogic).getComponentInstanceOutputs(USER_ID, COMPONENT_ID, INSTANCE_ID);
+
+ final ResponseFormat responseFormat = new ResponseFormat(HttpStatus.OK_200.getStatusCode());
+ doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.OK);
+
+ final OutputsServlet outputsServlet = createTestObject();
+ Assertions.assertThat(outputsServlet).isNotNull();
+
+ final Response response = outputsServlet.getComponentInstanceOutputs(RESOURCES, COMPONENT_ID, INSTANCE_ID, COMPONENT_UID, request, USER_ID);
+ Assertions.assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200.getStatusCode());
+ verify(componentsUtils, times(2)).getResponseFormat(ActionStatus.OK);
+ }
+
+ @Test
+ void test_getComponentInstanceOutputs_isRight() {
+ final ResponseFormat responseFormat = new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ final Either<Object, ResponseFormat> right = Either.right(responseFormat);
+ doReturn(right).when(outputsBusinessLogic).getComponentInstanceOutputs(USER_ID, COMPONENT_ID, INSTANCE_ID);
+
+ doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.GENERAL_ERROR);
+
+ final OutputsServlet outputsServlet = createTestObject();
+ Assertions.assertThat(outputsServlet).isNotNull();
+
+ final Response response = outputsServlet.getComponentInstanceOutputs(RESOURCES, COMPONENT_ID, INSTANCE_ID, COMPONENT_UID, request, USER_ID);
+ Assertions.assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ verify(componentsUtils, times(0)).getResponseFormat(ActionStatus.GENERAL_ERROR);
+ }
+
+ @Test
+ void test_getComponentInstanceOutputs_fail() {
+ final ResponseFormat responseFormat = new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ final Either<Object, ResponseFormat> right = Either.right(responseFormat);
+ doReturn(right).when(outputsBusinessLogic).getComponentInstanceOutputs(USER_ID, COMPONENT_ID, INSTANCE_ID);
+
+ doThrow(new RuntimeException()).when(componentsUtils).getResponseFormat(ActionStatus.GENERAL_ERROR);
+
+ final OutputsServlet outputsServlet = createTestObject();
+ Assertions.assertThat(outputsServlet).isNotNull();
+
+ final Response response = outputsServlet.getComponentInstanceOutputs(RESOURCES, COMPONENT_ID, INSTANCE_ID, COMPONENT_UID, request, USER_ID);
+ Assertions.assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ verify(componentsUtils, times(0)).getResponseFormat(ActionStatus.GENERAL_ERROR);
+ }
+
+ @Test
+ void test_createMultipleOutputs_success() {
+ final ComponentInstOutputsMap componentInstOutputsMap = new ComponentInstOutputsMap();
+ final Either<ComponentInstOutputsMap, ResponseFormat> left = Either.left(componentInstOutputsMap);
+
+ doReturn(left).when(componentsUtils)
+ .convertJsonToObjectUsingObjectMapper(any(String.class), any(User.class), eq(ComponentInstOutputsMap.class),
+ eq(AuditingActionEnum.CREATE_RESOURCE), eq(RESOURCE));
+ final Either<List<OutputDefinition>, ResponseFormat> listResponseFormatEither = Either.left(new ArrayList<>());
+ doReturn(listResponseFormatEither).when(outputsBusinessLogic).declareAttributes(USER_ID, COMPONENT_ID, RESOURCE, componentInstOutputsMap);
+
+ final ResponseFormat responseFormat = new ResponseFormat(HttpStatus.OK_200.getStatusCode());
+ doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.OK);
+
+ final OutputsServlet outputsServlet = createTestObject();
+ Assertions.assertThat(outputsServlet).isNotNull();
+
+ final Response response = outputsServlet.createMultipleOutputs(RESOURCES, COMPONENT_ID, request, USER_ID, COMPONENT_INST_OUTPUTS_MAP_OBJ);
+ Assertions.assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200.getStatusCode());
+ verify(componentsUtils, times(3)).getResponseFormat(ActionStatus.OK);
+ }
+
+ @Test
+ void test_createMultipleOutputs_isRight() {
+ final ResponseFormat responseFormat = new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ final Either<Object, ResponseFormat> right = Either.right(responseFormat);
+ doReturn(right).when(outputsBusinessLogic).declareAttributes(USER_ID, COMPONENT_ID, RESOURCE, new ComponentInstOutputsMap());
+
+ doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.GENERAL_ERROR);
+
+ final OutputsServlet outputsServlet = createTestObject();
+ Assertions.assertThat(outputsServlet).isNotNull();
+
+ final Response response = outputsServlet.createMultipleOutputs(RESOURCES, COMPONENT_ID, request, USER_ID, COMPONENT_INST_OUTPUTS_MAP_OBJ);
+ Assertions.assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ verify(componentsUtils, times(3)).getResponseFormat(ActionStatus.GENERAL_ERROR);
+ }
+
+ @Test
+ void test_createMultipleOutputs_fail() {
+ final ResponseFormat responseFormat = new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ doThrow(new RuntimeException()).when(outputsBusinessLogic).declareAttributes(USER_ID, COMPONENT_ID, RESOURCE, new ComponentInstOutputsMap());
+
+ doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.GENERAL_ERROR);
+
+ final OutputsServlet outputsServlet = createTestObject();
+ Assertions.assertThat(outputsServlet).isNotNull();
+
+ final Response response = outputsServlet.createMultipleOutputs(RESOURCES, COMPONENT_ID, request, USER_ID, COMPONENT_INST_OUTPUTS_MAP_OBJ);
+ Assertions.assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ verify(componentsUtils, times(2)).getResponseFormat(ActionStatus.GENERAL_ERROR);
+ }
+
+ @Test
+ void test_deleteOutput_success() {
+ doReturn(new OutputDefinition()).when(outputsBusinessLogic).deleteOutput(COMPONENT_ID, USER_ID, OUTPUT_ID);
+
+ final ResponseFormat responseFormat = new ResponseFormat(HttpStatus.OK_200.getStatusCode());
+ doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.OK);
+
+ final OutputsServlet outputsServlet = createTestObject();
+ Assertions.assertThat(outputsServlet).isNotNull();
+
+ final Response response = outputsServlet.deleteOutput(RESOURCES, COMPONENT_ID, OUTPUT_ID, request, USER_ID, COMPONENT_INST_OUTPUTS_MAP_OBJ);
+ Assertions.assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200.getStatusCode());
+ verify(componentsUtils, times(1)).getResponseFormat(ActionStatus.OK);
+ }
+
+ @Test
+ void test_deleteOutput_fail() {
+ final ResponseFormat responseFormat = new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ doThrow(new ComponentException(responseFormat)).when(outputsBusinessLogic).deleteOutput(COMPONENT_ID, USER_ID, OUTPUT_ID);
+
+ doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.GENERAL_ERROR);
+
+ final OutputsServlet outputsServlet = createTestObject();
+ Assertions.assertThat(outputsServlet).isNotNull();
+
+ final Response response = outputsServlet.deleteOutput(RESOURCES, COMPONENT_ID, OUTPUT_ID, request, USER_ID, COMPONENT_INST_OUTPUTS_MAP_OBJ);
+ Assertions.assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
+ verify(componentsUtils, times(1)).getResponseFormat(ActionStatus.GENERAL_ERROR);
+ }
+
+ private OutputsServlet createTestObject() {
+ return new OutputsServlet(userBusinessLogic, outputsBusinessLogic, componentInstanceBL, componentsUtils, servletUtils, resourceImportManager);
+ }
+
+ @Override
+ protected Application configure() {
+ final OutputsServlet outputsServlet = createTestObject();
+ final ResourceConfig resourceConfig = new ResourceConfig()
+ .register(outputsServlet)
+ .register(new ComponentExceptionMapper(componentsUtils))
+ .register(new AbstractBinder() {
+ @Override
+ protected void configure() {
+ bind(request).to(HttpServletRequest.class);
+ }
+ });
+
+ resourceConfig.property("contextConfig", new AnnotationConfigApplicationContext(SpringConfig.class));
+ return resourceConfig;
+ }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
index 993e68b97e..214d1a7aba 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
@@ -48,7 +48,11 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.impl.CapabilityTypeImportManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.config.SpringConfig;
@@ -69,21 +73,32 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.context.WebApplicationContext;
+@TestInstance(Lifecycle.PER_CLASS)
class TypesUploadServletTest extends JerseyTest {
- public static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
- private static final HttpSession session = Mockito.mock(HttpSession.class);
- public static final ServletContext servletContext = Mockito.mock(ServletContext.class);
- public static final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
- private static final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
- private static final CapabilityTypeImportManager importManager = Mockito.mock(CapabilityTypeImportManager.class);
- private static final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
- private static final UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
- private static final ComponentsUtils componentUtils = Mockito.mock(ComponentsUtils.class);
- private static final ResponseFormat responseFormat = Mockito.mock(ResponseFormat.class);
+ @Mock
+ private HttpServletRequest request;
+ @Mock
+ private HttpSession session;
+ @Mock
+ private ServletContext servletContext;
+ @Mock
+ private WebAppContextWrapper webAppContextWrapper;
+ @Mock
+ private WebApplicationContext webApplicationContext;
+ @Mock
+ private CapabilityTypeImportManager importManager;
+ @Mock
+ private ServletUtils servletUtils;
+ @Mock
+ private UserBusinessLogic userAdmin;
+ @Mock
+ private ComponentsUtils componentUtils;
+ @Mock
+ private ResponseFormat responseFormat;
@BeforeAll
- public static void setup() {
+ public void setup() {
ExternalConfiguration.setAppName("catalog-be");
when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
.thenReturn(webAppContextWrapper);
@@ -92,15 +107,13 @@ class TypesUploadServletTest extends JerseyTest {
when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
when(servletUtils.getComponentsUtils()).thenReturn(componentUtils);
when(servletUtils.getUserAdmin()).thenReturn(userAdmin);
- String userId = "jh0003";
- User user = new User();
- user.setUserId(userId);
+ final String userId = "jh0003";
+ final User user = new User(userId);
user.setRole(Role.ADMIN.name());
when(userAdmin.getUser(userId)).thenReturn(user);
when(request.getHeader(Constants.USER_ID_HEADER)).thenReturn(userId);
when(responseFormat.getStatus()).thenReturn(HttpStatus.CREATED_201);
when(componentUtils.getResponseFormat(ActionStatus.CREATED)).thenReturn(responseFormat);
-
}
@BeforeEach
@@ -115,19 +128,16 @@ class TypesUploadServletTest extends JerseyTest {
@Test
void creatingCapabilityTypeSuccessTest() {
- Either<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, ResponseFormat> either = Either
- .left(emptyList());
+ final Either<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, ResponseFormat> either = Either.left(emptyList());
when(importManager.createCapabilityTypes(Mockito.anyString())).thenReturn(either);
- FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip",
- new File("src/test/resources/types/capabilityTypes.zip"));
+ final FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip", new File("src/test/resources/types/capabilityTypes.zip"));
MultiPart multipartEntity = new FormDataMultiPart();
multipartEntity.bodyPart(filePart);
- Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON)
+ final Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON)
.post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
assertEquals(HttpStatus.CREATED_201, response.getStatus());
-
}
@Override
@@ -137,17 +147,17 @@ class TypesUploadServletTest extends JerseyTest {
@Override
protected ResourceConfig configure() {
+ MockitoAnnotations.openMocks(this);
- TypesUploadServlet typesUploadServlet = new TypesUploadServlet(null, null, componentUtils,
+ forceSet(TestProperties.CONTAINER_PORT, "0");
+ final TypesUploadServlet typesUploadServlet = new TypesUploadServlet(null, null, componentUtils,
servletUtils, null, importManager, null,
null, null,
null, null, null);
- ResourceConfig resourceConfig = new ResourceConfig()
- .register(typesUploadServlet);
+ final ResourceConfig resourceConfig = new ResourceConfig().register(typesUploadServlet);
resourceConfig.register(MultiPartFeature.class);
resourceConfig.register(new AbstractBinder() {
-
@Override
protected void configure() {
// The below code was cut-pasted to here from setup() because
@@ -160,17 +170,15 @@ class TypesUploadServletTest extends JerseyTest {
ConfigurationSource configurationSource = new FSConfigurationSource(
ExternalConfiguration.getChangeListener(), appConfigDir);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
- for (String mandatoryHeader : configurationManager.getConfiguration().getIdentificationHeaderFields()) {
-
+ for (final String mandatoryHeader : configurationManager.getConfiguration().getIdentificationHeaderFields()) {
when(request.getHeader(mandatoryHeader)).thenReturn(mandatoryHeader);
-
}
when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR))
.thenReturn(configurationManager);
}
});
- ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
+ final ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
resourceConfig.property("contextConfig", context);
return resourceConfig;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/AttributeConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/AttributeConverterTest.java
index 8292568d8e..2bd529541b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/AttributeConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/AttributeConverterTest.java
@@ -19,7 +19,6 @@
package org.openecomp.sdc.be.tosca;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -130,7 +129,6 @@ class AttributeConverterTest {
assertAttribute(attributeDefinition, defaultValueMap, actualToscaAttribute);
}
-
@Test
void testInvalidDefaultValueJsonConversion() {
//given
@@ -143,8 +141,7 @@ class AttributeConverterTest {
assertEquals("Failed to parse json value", toscaConversionException.getMessage());
}
- private void assertAttribute(final AttributeDefinition expectedAttributeDefinition,
- final ToscaAttribute actualToscaAttribute) {
+ private void assertAttribute(final AttributeDefinition expectedAttributeDefinition, final ToscaAttribute actualToscaAttribute) {
assertAttribute(expectedAttributeDefinition, expectedAttributeDefinition.get_default(), actualToscaAttribute);
}
@@ -170,4 +167,4 @@ class AttributeConverterTest {
return objectMapper.writeValueAsString(value);
}
-} \ No newline at end of file
+}
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 4b55a730fb..bca8827736 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
@@ -82,6 +82,8 @@ import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribOutput;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.ComponentParametersView;
@@ -90,6 +92,7 @@ import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RelationshipInfo;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
@@ -102,6 +105,7 @@ import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
+import org.openecomp.sdc.be.tosca.exception.ToscaConversionException;
import org.openecomp.sdc.be.tosca.model.SubstitutionMapping;
import org.openecomp.sdc.be.tosca.model.ToscaCapability;
import org.openecomp.sdc.be.tosca.model.ToscaMetadata;
@@ -378,11 +382,11 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
@Test
public void testConvertToscaTemplate() throws Exception {
- Component component = getNewResource();
- ToscaTemplate toscaNode = new ToscaTemplate("");
+ final Component component = getNewResource();
+ final ToscaTemplate toscaNode = new ToscaTemplate("");
Either<ToscaTemplate, ToscaError> result;
- List<ComponentInstance> resourceInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
+ final List<ComponentInstance> resourceInstances = new ArrayList<>();
+ final ComponentInstance instance = new ComponentInstance();
instance.setOriginType(OriginTypeEnum.SERVICE);
instance.setSourceModelUid("targetModelUid");
@@ -391,8 +395,11 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
component.setComponentInstances(resourceInstances);
when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
- when(capabilityRequirementConverter.getOriginComponent(any(Map.class),
- any(ComponentInstance.class))).thenReturn(Either.right(false));
+ when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.right(false));
+
+ final Map<String, ToscaProperty> map = new HashMap<>();
+ map.put("mock", new ToscaProperty());
+ doReturn(map).when(outputConverter).convert(any(), any());
// default test
result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
@@ -400,7 +407,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
}
@Test
- public void testConvertToscaTemplateWhenComponentContainsGroup() {
+ public void testConvertToscaTemplateWhenComponentContainsGroup() throws ToscaConversionException {
Component component = getNewResource();
ToscaTemplate toscaNode = new ToscaTemplate("");
Either<ToscaTemplate, ToscaError> result;
@@ -432,6 +439,10 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(groupExportParser.getGroups(component)).thenReturn(null);
+ final Map<String, ToscaProperty> map = new HashMap<>();
+ map.put("mock", new ToscaProperty());
+ doReturn(map).when(outputConverter).convert(any(), any());
+
// test component contains group
result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
Assert.assertNotNull(result);
@@ -467,6 +478,10 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
when(inputConverter.convertInputs(anyList(), anyMap())).thenReturn(new HashMap<>());
+ final Map<String, ToscaProperty> map = new HashMap<>();
+ map.put("mock", new ToscaProperty());
+ doReturn(map).when(outputConverter).convert(any(), any());
+
// test component contains group
result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
Assert.assertNotNull(result);
@@ -536,6 +551,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
// default test
Deencapsulation.invoke(testSubject, "createDependency", componentCache, imports, dependecies, ci);
+ Assert.assertFalse(componentCache.isEmpty());
}
@Test
@@ -1524,11 +1540,9 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
@Test
public void testIsCvfc() throws Exception {
- Component component = new Resource();
+ Component component = new Service();
boolean result;
- component = new Service();
-
result = Deencapsulation.invoke(testSubject, "isCvfc", component);
Assert.assertFalse(result);
}
@@ -1576,8 +1590,8 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
result = Deencapsulation.invoke(testSubject, "convertToNodeTemplateArtifacts", container);
Assert.assertNotNull(result);
Assert.assertTrue(MapUtils.isNotEmpty(result));
- Assert.assertEquals("test_file",result.get("test_art").getFile());
- Assert.assertEquals("test_type",result.get("test_art").getType());
+ Assert.assertEquals("test_file", result.get("test_art").getFile());
+ Assert.assertEquals("test_type", result.get("test_art").getType());
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OutputConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OutputConverterTest.java
new file mode 100644
index 0000000000..392c524471
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OutputConverterTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.tosca.utils;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.openecomp.sdc.be.model.OutputDefinition;
+import org.openecomp.sdc.be.tosca.AttributeConverter;
+import org.openecomp.sdc.be.tosca.exception.ToscaConversionException;
+import org.openecomp.sdc.be.tosca.model.ToscaProperty;
+import org.springframework.beans.factory.ObjectProvider;
+
+@ExtendWith(MockitoExtension.class)
+class OutputConverterTest {
+
+ @InjectMocks
+ private OutputConverter testSubject;
+
+ @Mock
+ private ObjectProvider<AttributeConverter> attributeConverterProvider;
+
+ @Test
+ void test_convert_success() throws ToscaConversionException {
+ final List<OutputDefinition> outputDefinitionList = new ArrayList<>();
+ final OutputDefinition outputDefinition = new OutputDefinition();
+ outputDefinitionList.add(outputDefinition);
+
+ doReturn(new AttributeConverter(new HashMap<>())).when(attributeConverterProvider).getObject(any());
+ final Map<String, ToscaProperty> result = testSubject.convert(outputDefinitionList, new HashMap<>());
+ assertThat(result).isNotNull();
+ }
+
+ @Test
+ void test_convert_isEmpty() throws ToscaConversionException {
+ final Map<String, ToscaProperty> result = testSubject.convert(new ArrayList<>(), new HashMap<>());
+ assertThat(result).isNotNull().isEmpty();
+ }
+
+}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/AttributeDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/AttributeDefinitionTest.java
new file mode 100644
index 0000000000..a6d87df05e
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/AttributeDefinitionTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.model;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+
+class AttributeDefinitionTest {
+
+ private static final String VALUE = "mock";
+ private final AttributeDefinition testSubject = new AttributeDefinition();
+
+ @Test
+ void testCtor() throws Exception {
+ assertNotNull(new AttributeDefinition());
+ assertNotNull(new AttributeDefinition(new AttributeDefinition()));
+ assertNotNull(new AttributeDefinition(new AttributeDataDefinition()));
+ }
+
+ @Test
+ void test_DefaultValue() {
+ testSubject.setDefaultValue(VALUE);
+ final String result = testSubject.getDefaultValue();
+ assertEquals(VALUE, result);
+ }
+
+ @Test
+ void test_isDefinition() {
+ assertFalse(testSubject.isDefinition());
+ }
+} \ No newline at end of file
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstOutputsMapTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstOutputsMapTest.java
new file mode 100644
index 0000000000..79a69df62f
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstOutputsMapTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.model;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class ComponentInstOutputsMapTest {
+
+ private final ComponentInstOutputsMap testInstance = new ComponentInstOutputsMap();
+
+ @Test
+ void test_resolveAttributesToDeclare_isEmpty() {
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ final Pair<String, List<ComponentInstanceAttribOutput>> result = testInstance.resolveAttributesToDeclare();
+ });
+ }
+
+ @Test
+ void test_resolveAttributesToDeclare_success() {
+ Map<String, List<ComponentInstanceAttribOutput>> map = new HashMap<>();
+ map.put("mock", Arrays.asList(new ComponentInstanceAttribOutput()));
+ testInstance.setComponentInstanceOutputsMap(map);
+ testInstance.setComponentInstanceAttributes(null);
+ Pair<String, List<ComponentInstanceAttribOutput>> result = testInstance.resolveAttributesToDeclare();
+ Assertions.assertNotNull(result);
+
+ testInstance.setComponentInstanceOutputsMap(null);
+ testInstance.setComponentInstanceAttributes(map);
+ result = testInstance.resolveAttributesToDeclare();
+ Assertions.assertNotNull(result);
+ }
+
+ @Test
+ void test_getComponentInstanceOutputsMap() {
+ final Map<String, List<ComponentInstanceAttribOutput>> result = testInstance.getComponentInstanceOutputsMap();
+ Assertions.assertNotNull(result);
+ }
+
+ @Test
+ void test_getComponentInstanceAttributes() {
+ final Map<String, List<ComponentInstanceAttribOutput>> result = testInstance.getComponentInstanceAttributes();
+ Assertions.assertNotNull(result);
+ }
+
+}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceAttribOutputTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceAttribOutputTest.java
new file mode 100644
index 0000000000..27be652b7a
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceAttribOutputTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.model;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class ComponentInstanceAttribOutputTest {
+
+ private final ComponentInstanceAttribOutput testSubject = new ComponentInstanceAttribOutput();
+
+ @Test
+ void testCtor() throws Exception {
+ Assertions.assertThat(testSubject).isNotNull().isInstanceOf(ComponentInstanceAttribOutput.class);
+ Assertions.assertThat(new ComponentInstanceAttribOutput(testSubject)).isNotNull().isInstanceOf(ComponentInstanceAttribOutput.class);
+ }
+
+ @Test
+ void test_getParsedAttribNames() {
+ String[] result;
+
+ testSubject.setAttributesName("");
+ result = testSubject.getParsedAttribNames();
+ assertNull(result);
+
+ testSubject.setAttributesName("ZZZ");
+ result = testSubject.getParsedAttribNames();
+ assertNotNull(result);
+ assertEquals(1, result.length);
+
+ testSubject.setAttributesName("AAA#BBB#CCC");
+ result = testSubject.getParsedAttribNames();
+ assertNotNull(result);
+ assertEquals(3, result.length);
+ }
+}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceOutputTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceOutputTest.java
new file mode 100644
index 0000000000..29b2dc4659
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceOutputTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.model;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.List;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
+
+class ComponentInstanceOutputTest {
+
+ private static final String MOCK = "mock";
+
+ @Test
+ void testCtor() throws Exception {
+ Assertions.assertNotNull(new ComponentInstanceOutput(new AttributeDataDefinition()));
+ Assertions.assertNotNull(new ComponentInstanceOutput(new OutputDefinition(), MOCK, MOCK));
+ Assertions.assertNotNull(new ComponentInstanceOutput(new AttributeDataDefinition(), MOCK, MOCK, MOCK));
+ }
+
+}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationTest.java
index aea07799b2..cf4d6b22bf 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationTest.java
@@ -36,22 +36,28 @@ import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphVertex;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.*;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+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.*;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
@@ -64,27 +70,34 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.any;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
-public class NodeTemplateOperationTest extends ModelTestBase {
-
- private final static String COMPONENT_ID = "componentId";
- private final static String TO_INSTANCE_ID = "toInstanceId";
- private final static String FROM_INSTANCE_ID = "fromInstanceId";
- private final static String RELATION_ID = "relationId";
- private final static String CAPABILITY_OWNER_ID = "capabilityOwnerId";
- private final static String CAPABILITY_UID = "capabilityUid";
- private final static String CAPABILITY_NAME = "capabilityName";
- private final static String REQUIREMENT_OWNER_ID = "requirementOwnerId";
- private final static String REQUIREMENT_UID = "requirementUid";
- private final static String REQUIREMENT_NAME = "requirementName";
- private final static String RELATIONSHIP_TYPE = "relationshipType";
+@ExtendWith(MockitoExtension.class)
+@TestInstance(Lifecycle.PER_CLASS)
+class NodeTemplateOperationTest extends ModelTestBase {
+
+ private static final String COMPONENT_ID = "componentId";
+ private static final String TO_INSTANCE_ID = "toInstanceId";
+ private static final String FROM_INSTANCE_ID = "fromInstanceId";
+ private static final String RELATION_ID = "relationId";
+ private static final String CAPABILITY_OWNER_ID = "capabilityOwnerId";
+ private static final String CAPABILITY_UID = "capabilityUid";
+ private static final String CAPABILITY_NAME = "capabilityName";
+ private static final String REQUIREMENT_OWNER_ID = "requirementOwnerId";
+ private static final String REQUIREMENT_UID = "requirementUid";
+ private static final String REQUIREMENT_NAME = "requirementName";
+ private static final String RELATIONSHIP_TYPE = "relationshipType";
private static Map<String, MapListCapabilityDataDefinition> fulfilledCapability;
private static Map<String, MapListRequirementDataDefinition> fulfilledRequirement;
@@ -92,19 +105,15 @@ public class NodeTemplateOperationTest extends ModelTestBase {
private static RequirementDataDefinition requirement;
private static RequirementCapabilityRelDef relation;
- @InjectMocks
- private static NodeTemplateOperation operation;
-
- @Mock
- private static JanusGraphDao janusGraphDao;
+ private final JanusGraphDao janusGraphDao = Mockito.mock(JanusGraphDao.class);
+ private final TopologyTemplateOperation topologyTemplateOperation = Mockito.mock(TopologyTemplateOperation.class);
- @Mock
- private static TopologyTemplateOperation topologyTemplateOperation;
+ @InjectMocks
+ private NodeTemplateOperation operation;
- @BeforeClass
- public static void setup() {
+ @BeforeAll
+ public void setup() {
init();
- janusGraphDao = Mockito.mock(JanusGraphDao.class);
operation = new NodeTemplateOperation();
operation.setJanusGraphDao(janusGraphDao);
buildDataDefinition();
@@ -117,7 +126,7 @@ public class NodeTemplateOperationTest extends ModelTestBase {
}
@Test
- public void testGetFulfilledCapabilityByRelationSuccess(){
+ void testGetFulfilledCapabilityByRelationSuccess() {
GraphVertex vertex = Mockito.mock(GraphVertex.class);
Either<GraphVertex, JanusGraphOperationStatus> vertexRes = Either.left(vertex);
when(janusGraphDao.getVertexById(eq(COMPONENT_ID), eq(JsonParseFlagEnum.ParseAll))).thenReturn(vertexRes);
@@ -132,7 +141,7 @@ public class NodeTemplateOperationTest extends ModelTestBase {
}
@Test
- public void testGetFulfilledRequirementByRelationSuccess(){
+ void testGetFulfilledRequirementByRelationSuccess() {
GraphVertex vertex = Mockito.mock(GraphVertex.class);
Either<GraphVertex, JanusGraphOperationStatus> vertexRes = Either.left(vertex);
when(janusGraphDao.getVertexById(eq(COMPONENT_ID), eq(JsonParseFlagEnum.ParseAll))).thenReturn(vertexRes);
@@ -147,7 +156,7 @@ public class NodeTemplateOperationTest extends ModelTestBase {
}
@Test
- public void testGetFulfilledCapabilityByRelationNotFoundFailure(){
+ void testGetFulfilledCapabilityByRelationNotFoundFailure() {
GraphVertex vertex = Mockito.mock(GraphVertex.class);
Either<GraphVertex, JanusGraphOperationStatus> vertexRes = Either.left(vertex);
when(janusGraphDao.getVertexById(eq(COMPONENT_ID), eq(JsonParseFlagEnum.ParseAll))).thenReturn(vertexRes);
@@ -157,11 +166,11 @@ public class NodeTemplateOperationTest extends ModelTestBase {
when(janusGraphDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_CAPABILITIES), eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes);
Either<CapabilityDataDefinition, StorageOperationStatus> result = operation.getFulfilledCapabilityByRelation(COMPONENT_ID, TO_INSTANCE_ID, relation, this::isBelongingCapability);
assertTrue(result.isRight());
- assertSame(result.right().value(), StorageOperationStatus.NOT_FOUND);
+ assertSame(StorageOperationStatus.NOT_FOUND, result.right().value());
}
@Test
- public void testGetFulfilledRequirementByRelationNotFoundFailure(){
+ void testGetFulfilledRequirementByRelationNotFoundFailure() {
GraphVertex vertex = Mockito.mock(GraphVertex.class);
Either<GraphVertex, JanusGraphOperationStatus> vertexRes = Either.left(vertex);
when(janusGraphDao.getVertexById(eq(COMPONENT_ID), eq(JsonParseFlagEnum.ParseAll))).thenReturn(vertexRes);
@@ -171,11 +180,11 @@ public class NodeTemplateOperationTest extends ModelTestBase {
when(janusGraphDao.getChildVertex(eq(vertex), eq(EdgeLabelEnum.FULLFILLED_REQUIREMENTS), eq(JsonParseFlagEnum.ParseJson))).thenReturn(childVertexRes);
Either<RequirementDataDefinition, StorageOperationStatus> result = operation.getFulfilledRequirementByRelation(COMPONENT_ID, FROM_INSTANCE_ID, relation, this::isBelongingRequirement);
assertTrue(result.isRight());
- assertSame(result.right().value(), StorageOperationStatus.NOT_FOUND);
+ assertSame(StorageOperationStatus.NOT_FOUND, result.right().value());
}
@Test
- public void testUpdateCIMetadataOfTopologyTemplate() {
+ void testUpdateCIMetadataOfTopologyTemplate() {
Either<ImmutablePair<TopologyTemplate, String>, StorageOperationStatus> result;
String id = "id";
TopologyTemplate container = new TopologyTemplate();
@@ -194,16 +203,16 @@ public class NodeTemplateOperationTest extends ModelTestBase {
assertTrue(result.isLeft());
}
- @Test
- public void testGetDefaultHeatTimeout() {
- Integer result;
+ @Test
+ void testGetDefaultHeatTimeout() {
+ Integer result;
- // default test
- result = NodeTemplateOperation.getDefaultHeatTimeout();
+ // default test
+ result = NodeTemplateOperation.getDefaultHeatTimeout();
}
- @Test
- public void testPrepareInstDeploymentArtifactPerInstance() {
+ @Test
+ void testPrepareInstDeploymentArtifactPerInstance() {
Map<String, Object> deploymentResourceArtifacts = new HashMap<>();
Map<String, ArtifactDataDefinition> deploymentArtifacts = new HashMap<>();
ArtifactDataDefinition artifactDataDefinition = new ArtifactDataDefinition();
@@ -220,22 +229,22 @@ public class NodeTemplateOperationTest extends ModelTestBase {
MapArtifactDataDefinition result;
result = operation.prepareInstDeploymentArtifactPerInstance(deploymentArtifacts, componentInstanceId, user,
- envType);
- Assert.assertEquals(2, result.getMapToscaDataDefinition().size());
+ envType);
+ assertEquals(2, result.getMapToscaDataDefinition().size());
}
- @Test
- public void testCreateCapPropertyKey() throws Exception {
- String key = "";
- String instanceId = "";
- String result;
+ @Test
+ void testCreateCapPropertyKey() throws Exception {
+ String key = "";
+ String instanceId = "";
+ String result;
- // default test
- result = NodeTemplateOperation.createCapPropertyKey(key, instanceId);
- }
+ // default test
+ result = NodeTemplateOperation.createCapPropertyKey(key, instanceId);
+ }
- @Test
- public void testPrepareCalculatedCapabiltyForNodeType() {
+ @Test
+ void testPrepareCalculatedCapabiltyForNodeType() {
Map<String, ListCapabilityDataDefinition> capabilities = new HashMap<>();
ListCapabilityDataDefinition listCapDataDefinition = new ListCapabilityDataDefinition();
List<CapabilityDataDefinition> listToscaDataDefinition = new ArrayList<>();
@@ -248,11 +257,11 @@ public class NodeTemplateOperationTest extends ModelTestBase {
MapListCapabilityDataDefinition result;
result = operation.prepareCalculatedCapabiltyForNodeType(capabilities, componentInstance);
- Assert.assertEquals(1, result.getMapToscaDataDefinition().size());
+ assertEquals(1, result.getMapToscaDataDefinition().size());
}
@Test
- public void testPrepareCalculatedReqForNodeType() {
+ void testPrepareCalculatedReqForNodeType() {
Map<String, ListRequirementDataDefinition> requirements = new HashMap<>();
ListRequirementDataDefinition listReqDataDef = new ListRequirementDataDefinition();
List<RequirementDataDefinition> listToscaDataDefinition = new ArrayList<>();
@@ -265,43 +274,43 @@ public class NodeTemplateOperationTest extends ModelTestBase {
MapListRequirementDataDefinition result;
result = operation.prepareCalculatedRequirementForNodeType(requirements, componentInstance);
- Assert.assertEquals(1, result.getMapToscaDataDefinition().size());
+ assertEquals(1, result.getMapToscaDataDefinition().size());
}
- @Test
- public void testAddGroupInstancesToComponentInstance() throws Exception {
- Component containerComponent = null;
- ComponentInstanceDataDefinition componentInstance = null;
- List<GroupDefinition> groups = null;
- Map<String, List<ArtifactDefinition>> groupInstancesArtifacts = null;
- StorageOperationStatus result;
-
- result = operation.addGroupInstancesToComponentInstance(containerComponent, componentInstance, groups,
- groupInstancesArtifacts);
- Assert.assertEquals(StorageOperationStatus.OK, result);
- }
+ @Test
+ void testAddGroupInstancesToComponentInstance() throws Exception {
+ Component containerComponent = null;
+ ComponentInstanceDataDefinition componentInstance = null;
+ List<GroupDefinition> groups = null;
+ Map<String, List<ArtifactDefinition>> groupInstancesArtifacts = null;
+ StorageOperationStatus result;
+
+ result = operation.addGroupInstancesToComponentInstance(containerComponent, componentInstance, groups,
+ groupInstancesArtifacts);
+ assertEquals(StorageOperationStatus.OK, result);
+ }
- @Test
- public void testGenerateCustomizationUUIDOnInstanceGroup() throws Exception {
- String componentId = "";
- String instanceId = "";
- List<String> groupInstances = null;
- StorageOperationStatus result;
+ @Test
+ void testGenerateCustomizationUUIDOnInstanceGroup() throws Exception {
+ String componentId = "";
+ String instanceId = "";
+ List<String> groupInstances = null;
+ StorageOperationStatus result;
- result = operation.generateCustomizationUUIDOnInstanceGroup(componentId, instanceId, groupInstances);
- Assert.assertEquals(StorageOperationStatus.OK, result);
- }
-
- @Test
- public void testUpdateComponentInstanceRequirement() {
+ result = operation.generateCustomizationUUIDOnInstanceGroup(componentId, instanceId, groupInstances);
+ assertEquals(StorageOperationStatus.OK, result);
+ }
+
+ @Test
+ void testUpdateComponentInstanceRequirement() {
String componentId = "";
String componentInstanceId = "requirementOwnerId";
-
+
GraphVertex graphVertex = new GraphVertex();
graphVertex.setUniqueId("uniqueId");
when(janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(graphVertex));
when(janusGraphDao.updateVertex(graphVertex)).thenReturn(Either.left(graphVertex));
-
+
MapListRequirementDataDefinition mapListRequirementDataDefinition = new MapListRequirementDataDefinition();
mapListRequirementDataDefinition.add(requirement.getCapability(), requirement);
Map<String, MapListRequirementDataDefinition> mapOfRequirements = new HashMap<>();
@@ -326,16 +335,108 @@ public class NodeTemplateOperationTest extends ModelTestBase {
}
};
String outId = (String) janusGraphDao
- .getProperty((JanusGraphVertex) outVertex, GraphPropertyEnum.UNIQUE_ID.getProperty());
+ .getProperty((JanusGraphVertex) outVertex, GraphPropertyEnum.UNIQUE_ID.getProperty());
when(janusGraphDao.getProperty(outVertex, GraphPropertyEnum.UNIQUE_ID.getProperty())).thenReturn("uniqueId");
when(janusGraphDao.updateVertex(childVertex)).thenReturn(Either.left(childVertex));
JanusGraphVertex janusGraphVertex = Mockito.mock(JanusGraphVertex.class);
childVertex.setVertex(janusGraphVertex);
when(janusGraphVertex.edges(Direction.IN, EdgeLabelEnum.CALCULATED_REQUIREMENTS.name())).thenReturn(edgeIterator);
-
- StorageOperationStatus result = operation.updateComponentInstanceRequirement(componentId, componentInstanceId, requirement);
- assertEquals(StorageOperationStatus.OK, result);
- }
+
+ StorageOperationStatus result = operation.updateComponentInstanceRequirement(componentId, componentInstanceId, requirement);
+ assertEquals(StorageOperationStatus.OK, result);
+ }
+
+ @Test
+ void test_addComponentInstanceOutput() {
+ final NodeTemplateOperation testInstance = Mockito.spy(new NodeTemplateOperation());
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+
+ final String componentInstanceId = "requirementOwnerId";
+
+ final ComponentInstanceOutput instanceOutput = new ComponentInstanceOutput();
+
+ doReturn(StorageOperationStatus.OK).when((BaseOperation) testInstance)
+ .addToscaDataDeepElementToToscaElement(eq(COMPONENT_ID), eq(EdgeLabelEnum.INST_OUTPUTS), eq(VertexTypeEnum.INST_OUTPUTS),
+ ArgumentMatchers.any(ComponentInstanceOutput.class), ArgumentMatchers.anyList(), eq(JsonPresentationFields.NAME));
+
+ final StorageOperationStatus result = testInstance.addComponentInstanceOutput(component, componentInstanceId, instanceOutput);
+ assertNotNull(result);
+ assertEquals(StorageOperationStatus.OK, result);
+ verify((BaseOperation) testInstance, times(1))
+ .addToscaDataDeepElementToToscaElement(eq(COMPONENT_ID), eq(EdgeLabelEnum.INST_OUTPUTS), eq(VertexTypeEnum.INST_OUTPUTS),
+ ArgumentMatchers.any(ComponentInstanceOutput.class), ArgumentMatchers.anyList(), eq(JsonPresentationFields.NAME));
+ }
+
+ @Test
+ void test_updateComponentInstanceAttributes() {
+ final NodeTemplateOperation testInstance = Mockito.spy(new NodeTemplateOperation());
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+
+ final String componentInstanceId = "requirementOwnerId";
+
+ final ComponentInstanceAttribute instanceAttribute = new ComponentInstanceAttribute();
+ final List<ComponentInstanceAttribute> attributes = new ArrayList<>();
+ attributes.add(instanceAttribute);
+
+ doReturn(StorageOperationStatus.OK).when((BaseOperation) testInstance)
+ .updateToscaDataDeepElementsOfToscaElement(eq(COMPONENT_ID), eq(EdgeLabelEnum.INST_ATTRIBUTES), eq(VertexTypeEnum.INST_ATTRIBUTES),
+ eq(attributes), ArgumentMatchers.anyList(), eq(JsonPresentationFields.NAME));
+
+ final StorageOperationStatus result = testInstance.updateComponentInstanceAttributes(component, componentInstanceId, attributes);
+ assertNotNull(result);
+ assertEquals(StorageOperationStatus.OK, result);
+ verify((BaseOperation) testInstance, times(1))
+ .updateToscaDataDeepElementsOfToscaElement(eq(COMPONENT_ID), eq(EdgeLabelEnum.INST_ATTRIBUTES), eq(VertexTypeEnum.INST_ATTRIBUTES),
+ eq(attributes), ArgumentMatchers.anyList(), eq(JsonPresentationFields.NAME));
+ }
+
+ @Test
+ void test_updateComponentInstanceAttribute() {
+ final NodeTemplateOperation testInstance = Mockito.spy(new NodeTemplateOperation());
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+
+ final String componentInstanceId = "requirementOwnerId";
+
+ final ComponentInstanceAttribute instanceAttribute = new ComponentInstanceAttribute();
+
+ doReturn(StorageOperationStatus.OK).when((BaseOperation) testInstance)
+ .updateToscaDataDeepElementOfToscaElement(eq(COMPONENT_ID), eq(EdgeLabelEnum.INST_ATTRIBUTES), eq(VertexTypeEnum.INST_ATTRIBUTES),
+ eq(instanceAttribute), ArgumentMatchers.anyList(), eq(JsonPresentationFields.NAME));
+
+ final StorageOperationStatus result = testInstance.updateComponentInstanceAttribute(component, componentInstanceId, instanceAttribute);
+ assertNotNull(result);
+ assertEquals(StorageOperationStatus.OK, result);
+ verify((BaseOperation) testInstance, times(1))
+ .updateToscaDataDeepElementOfToscaElement(eq(COMPONENT_ID), eq(EdgeLabelEnum.INST_ATTRIBUTES), eq(VertexTypeEnum.INST_ATTRIBUTES),
+ eq(instanceAttribute), ArgumentMatchers.anyList(), eq(JsonPresentationFields.NAME));
+ }
+
+ @Test
+ void test_updateComponentInstanceOutputs() {
+ final NodeTemplateOperation testInstance = Mockito.spy(new NodeTemplateOperation());
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+
+ final String componentInstanceId = "requirementOwnerId";
+
+ List<ComponentInstanceOutput> componentInstanceOutputList = new ArrayList<>();
+ ComponentInstanceOutput instanceOutput = new ComponentInstanceOutput();
+ componentInstanceOutputList.add(instanceOutput);
+
+ doReturn(StorageOperationStatus.OK).when((BaseOperation) testInstance)
+ .updateToscaDataDeepElementsOfToscaElement(eq(COMPONENT_ID), eq(EdgeLabelEnum.INST_OUTPUTS), eq(VertexTypeEnum.INST_OUTPUTS),
+ eq(componentInstanceOutputList), ArgumentMatchers.anyList(), eq(JsonPresentationFields.NAME));
+
+ final StorageOperationStatus result = testInstance.updateComponentInstanceOutputs(component, componentInstanceId, componentInstanceOutputList);
+ assertNotNull(result);
+ assertEquals(StorageOperationStatus.OK, result);
+ verify((BaseOperation) testInstance, times(1))
+ .updateToscaDataDeepElementsOfToscaElement(eq(COMPONENT_ID), eq(EdgeLabelEnum.INST_OUTPUTS), eq(VertexTypeEnum.INST_OUTPUTS),
+ eq(componentInstanceOutputList), ArgumentMatchers.anyList(), eq(JsonPresentationFields.NAME));
+ }
private ComponentInstance createCompInstance() {
ComponentInstance componentInstance = new ComponentInstance();
@@ -345,6 +446,7 @@ public class NodeTemplateOperationTest extends ModelTestBase {
componentInstance.setName(id);
return componentInstance;
}
+
private static void buildRequirementDataDefinition() {
buildRequirement();
fulfilledRequirement = new HashMap<>();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationTest.java
index 436af94c1c..dc5e2fd5ea 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperationTest.java
@@ -55,6 +55,9 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@@ -148,6 +151,25 @@ public class TopologyTemplateOperationTest {
}
@Test
+ public void testSetOutputsFromGraph() {
+ final GraphVertex containerVertex = new GraphVertex();
+ final ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreOutputs(false);
+ final String componentName = "componentName";
+ final String componentId = UniqueIdBuilder.buildResourceUniqueId();
+ containerVertex.setVertex(Mockito.mock(JanusGraphVertex.class));
+ containerVertex.setJsonMetadataField(JsonPresentationFields.NAME, componentName);
+ containerVertex.setUniqueId(componentId);
+ containerVertex.setLabel(VertexTypeEnum.TOPOLOGY_TEMPLATE);
+ doReturn(Either.right(JanusGraphOperationStatus.GENERAL_ERROR)).when(janusGraphDao)
+ .getChildVertex(any(GraphVertex.class), any(EdgeLabelEnum.class), any(JsonParseFlagEnum.class));
+ final Either<ToscaElement, StorageOperationStatus> storageOperationStatus
+ = topologyTemplateOperation.getToscaElement(containerVertex, filter);
+ assertThat(storageOperationStatus).isEqualTo(Either.right(StorageOperationStatus.GENERAL_ERROR));
+ verify(janusGraphDao, times(1)).getChildVertex(any(GraphVertex.class), any(EdgeLabelEnum.class), any(JsonParseFlagEnum.class));
+ }
+
+ @Test
public void testUpdateDistributionStatus() {
Either<GraphVertex, StorageOperationStatus> result;
String uniqueId = "uniqueId";
@@ -176,7 +198,7 @@ public class TopologyTemplateOperationTest {
JanusGraphOperationStatus.OK);
when(janusGraphDao.updateVertex(graphVertex)).thenReturn(Either.left(graphVertex));
result = topologyTemplateOperation.updateDistributionStatus(uniqueId, user, DistributionStatusEnum.DISTRIBUTED);
- assertThat(result.isLeft());
+ assertThat(result.isLeft()).isTrue();
}
@SuppressWarnings("unchecked")
@@ -195,7 +217,7 @@ public class TopologyTemplateOperationTest {
int counter = 0;
Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = Either.right(
JanusGraphOperationStatus.NOT_FOUND);
- when(janusGraphDao.getChildVertex(eq(componentV), eq(EdgeLabelEnum.POLICIES), eq(JsonParseFlagEnum.ParseJson))).thenReturn(toscaDataVertexRes);
+ when(janusGraphDao.getChildVertex(componentV, EdgeLabelEnum.POLICIES, JsonParseFlagEnum.ParseJson)).thenReturn(toscaDataVertexRes);
Either<GraphVertex, JanusGraphOperationStatus> createVertex = Either.left(dataV);
when(janusGraphDao.createVertex(any(GraphVertex.class))).thenReturn(createVertex);
when(janusGraphDao.createEdge(any(JanusGraphVertex.class), any(JanusGraphVertex.class), any(EdgeLabelEnum.class), any(HashMap.class))).thenReturn(status);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java
index 971f4f79ab..621b275a67 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java
@@ -48,6 +48,7 @@ import org.openecomp.sdc.be.dao.jsongraph.HealingJanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -56,9 +57,13 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.PromoteVersionEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.ComponentParametersView;
@@ -90,8 +95,12 @@ import java.util.Collections;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -122,7 +131,7 @@ public class ToscaOperationFacadeTest {
private TopologyTemplateOperation topologyTemplateOperationMock;
@Mock
- private NodeTypeOperation nodeTypeOperation;
+ private NodeTypeOperation nodeTypeOperationMock;
@Mock
private NodeTemplateOperation nodeTemplateOperationMock;
@@ -369,7 +378,7 @@ public class ToscaOperationFacadeTest {
when(janusGraphDaoMock.getVertexById(id, JsonParseFlagEnum.NoParse)).thenReturn(Either.left(graphVertex));
when(janusGraphDaoMock.getParentVertex(graphVertex, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse)).thenReturn(Either.left(graphVertex));
when(topologyTemplateOperationMock.deleteToscaElement(graphVertex)).thenReturn(Either.left(toscaElement));
- when(nodeTypeOperation.createToscaElement(any(ToscaElement.class))).thenReturn(Either.left(nodeType));
+ when(nodeTypeOperationMock.createToscaElement(any(ToscaElement.class))).thenReturn(Either.left(nodeType));
when(janusGraphDaoMock.getVertexById(null, JsonParseFlagEnum.NoParse)).thenReturn(Either.left(graphVertex));
when(janusGraphDaoMock.createEdge(graphVertex, graphVertex, EdgeLabelEnum.VERSION, null)).thenReturn(
JanusGraphOperationStatus.OK);
@@ -397,7 +406,7 @@ public class ToscaOperationFacadeTest {
component.setUniqueId(id);
GraphVertex graphVertex = getTopologyTemplateVertex();
when(janusGraphDaoMock.getVertexById(id, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(graphVertex));
- when(nodeTypeOperation.markComponentToDelete(graphVertex)).thenReturn(Either.left(graphVertex));
+ when(nodeTypeOperationMock.markComponentToDelete(graphVertex)).thenReturn(Either.left(graphVertex));
result = testInstance.markComponentToDelete(component);
assertEquals(result, StorageOperationStatus.OK);
}
@@ -484,7 +493,8 @@ public class ToscaOperationFacadeTest {
List<ToscaElement> toscaEleList = new ArrayList<>();
ToscaElement toscaElement = getToscaElementForTest();
toscaEleList.add(toscaElement);
- when(nodeTypeOperation.getFollowedComponent(userId, lifecycleStates, lastStateStates, componentType)).thenReturn(Either.left(toscaEleList));
+ when(nodeTypeOperationMock.getFollowedComponent(userId, lifecycleStates, lastStateStates, componentType))
+ .thenReturn(Either.left(toscaEleList));
result = testInstance.getFollowed(userId, lifecycleStates, lastStateStates, componentType);
assertTrue(result.isLeft());
assertEquals(1, result.left().value().size());
@@ -806,11 +816,226 @@ public class ToscaOperationFacadeTest {
}
@Test
- public void associateRequirementsToServiceSuccessTest(){
+ public void associateRequirementsToServiceSuccessTest() {
StorageOperationStatus result = associateRequirementsToServiceWithStatus(StorageOperationStatus.OK);
assertTrue(result == StorageOperationStatus.OK);
}
+ @Test
+ public void test_addOutputsToComponent() {
+ final GraphVertex graphVertex = getTopologyTemplateVertex();
+ final String componentId = "componentId";
+
+ doReturn(Either.left(graphVertex)).when(janusGraphDaoMock).getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ doReturn(StorageOperationStatus.OK).when(topologyTemplateOperationMock)
+ .addToscaDataToToscaElement(
+ any(GraphVertex.class), eq(EdgeLabelEnum.OUTPUTS), eq(VertexTypeEnum.OUTPUTS), anyMap(), eq(JsonPresentationFields.NAME));
+
+ final Map<String, OutputDefinition> outputs = new HashMap<>();
+ final OutputDefinition outputDefinition = new OutputDefinition();
+ outputs.put("mock", outputDefinition);
+ final Either<List<OutputDefinition>, StorageOperationStatus> result = testInstance.addOutputsToComponent(outputs, componentId);
+ assertNotNull(result);
+ assertTrue(result.isLeft());
+ assertFalse(result.left().value().isEmpty());
+ assertThat(result.left().value().get(0)).isInstanceOf(OutputDefinition.class);
+ verify(janusGraphDaoMock, times(1)).getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ verify(topologyTemplateOperationMock, times(1)).addToscaDataToToscaElement(
+ any(GraphVertex.class), eq(EdgeLabelEnum.OUTPUTS), eq(VertexTypeEnum.OUTPUTS), anyMap(), eq(JsonPresentationFields.NAME));
+ }
+
+ @Test
+ public void test_addComponentInstanceOutputsToComponent_updateComponentInstanceOutput() {
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+ final Map<String, List<ComponentInstanceOutput>> map = new HashMap<>();
+ final List<ComponentInstanceOutput> componentInstanceOutputList = new ArrayList<>();
+ final ComponentInstanceOutput componentInstanceOutput = new ComponentInstanceOutput();
+ componentInstanceOutput.setComponentInstanceId(COMPONENT_ID);
+ componentInstanceOutput.setComponentInstanceName(COMPONENT_ID);
+ componentInstanceOutput.setName(COMPONENT_ID);
+ componentInstanceOutputList.add(componentInstanceOutput);
+ map.put("mock", componentInstanceOutputList);
+ component.setComponentInstancesOutputs(map);
+
+ doReturn(StorageOperationStatus.OK).when(nodeTemplateOperationMock)
+ .updateComponentInstanceOutput(any(Component.class), anyString(), any(ComponentInstanceOutput.class));
+
+ final Either<Map<String, List<ComponentInstanceOutput>>, StorageOperationStatus> result
+ = testInstance.addComponentInstanceOutputsToComponent(component, map);
+ assertNotNull(result);
+ assertTrue(result.isLeft());
+ assertFalse(result.left().value().isEmpty());
+ assertSame(result.left().value(), map);
+ verify(nodeTemplateOperationMock, times(1))
+ .updateComponentInstanceOutput(any(Component.class), anyString(), any(ComponentInstanceOutput.class));
+
+ }
+
+ @Test
+ public void test_addComponentInstanceOutputsToComponent_addComponentInstanceOutput() {
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+ Map<String, List<ComponentInstanceOutput>> map = new HashMap<>();
+ List<ComponentInstanceOutput> componentInstanceOutputList = new ArrayList<>();
+ ComponentInstanceOutput componentInstanceOutput = new ComponentInstanceOutput();
+ componentInstanceOutput.setComponentInstanceId(COMPONENT_ID);
+ componentInstanceOutput.setComponentInstanceName(COMPONENT_ID);
+ componentInstanceOutput.setName(COMPONENT_ID);
+ componentInstanceOutputList.add(componentInstanceOutput);
+ map.put("mock", componentInstanceOutputList);
+ component.setComponentInstancesOutputs(map);
+
+ map = new HashMap<>();
+ componentInstanceOutputList = new ArrayList<>();
+ componentInstanceOutput = new ComponentInstanceOutput();
+ componentInstanceOutput.setComponentInstanceId("mock");
+ componentInstanceOutput.setComponentInstanceName("mock");
+ componentInstanceOutput.setName("mock");
+ componentInstanceOutputList.add(componentInstanceOutput);
+ map.put("mock", componentInstanceOutputList);
+
+ final Either<Map<String, List<ComponentInstanceOutput>>, StorageOperationStatus> result = testInstance
+ .addComponentInstanceOutputsToComponent(component, map);
+ assertNotNull(result);
+ assertTrue(result.isRight());
+ }
+
+ @Test
+ public void test_addComponentInstanceAttributesToComponent() {
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+ Map<String, List<ComponentInstanceAttribute>> map = new HashMap<>();
+ List<ComponentInstanceAttribute> componentInstanceOutputList = new ArrayList<>();
+ ComponentInstanceAttribute componentInstanceAttribute = new ComponentInstanceAttribute();
+ componentInstanceAttribute.setComponentInstanceId(COMPONENT_ID);
+ componentInstanceAttribute.setUniqueId(COMPONENT_ID);
+ componentInstanceOutputList.add(componentInstanceAttribute);
+ map.put("mock", componentInstanceOutputList);
+ component.setComponentInstancesAttributes(map);
+
+ doReturn(StorageOperationStatus.OK).when(nodeTemplateOperationMock)
+ .updateComponentInstanceAttribute(any(Component.class), anyString(), any(ComponentInstanceAttribute.class));
+
+ final Either<Map<String, List<ComponentInstanceAttribute>>, StorageOperationStatus> result
+ = testInstance.addComponentInstanceAttributesToComponent(component, map);
+
+ assertNotNull(result);
+ assertTrue(result.isLeft());
+ assertFalse(result.left().value().isEmpty());
+ assertSame(result.left().value(), map);
+ verify(nodeTemplateOperationMock, times(1))
+ .updateComponentInstanceAttribute(any(Component.class), anyString(), any(ComponentInstanceAttribute.class));
+ }
+
+ @Test
+ public void test_updateAttributeOfComponent_success() {
+ final GraphVertex graphVertex = getTopologyTemplateVertex();
+ final String componentId = "componentId";
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+ doReturn(StorageOperationStatus.OK).when(nodeTypeOperationMock).updateToscaDataOfToscaElement(
+ anyString(), eq(EdgeLabelEnum.ATTRIBUTES), eq(VertexTypeEnum.ATTRIBUTES), any(AttributeDefinition.class),
+ eq(JsonPresentationFields.NAME));
+ doReturn(Either.left(graphVertex)).when(janusGraphDaoMock).getVertexById(eq(componentId), any(JsonParseFlagEnum.class));
+
+ final ToscaElement toscaElement = getToscaElementForTest();
+ final Map<String, AttributeDataDefinition> attributes = new HashMap<>();
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName("mock");
+ attributes.put("mock", attributeDefinition);
+ toscaElement.setAttributes(attributes);
+ doReturn(Either.left(toscaElement)).when(topologyTemplateOperationMock)
+ .getToscaElement(ArgumentMatchers.eq(graphVertex), any(ComponentParametersView.class));
+
+ final Either<AttributeDefinition, StorageOperationStatus> result
+ = testInstance.updateAttributeOfComponent(component, attributeDefinition);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void test_updateAttributeOfComponent_isNotPresent() {
+ final GraphVertex graphVertex = getTopologyTemplateVertex();
+ final String componentId = "componentId";
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+ doReturn(StorageOperationStatus.OK).when(nodeTypeOperationMock).updateToscaDataOfToscaElement(
+ anyString(), eq(EdgeLabelEnum.ATTRIBUTES), eq(VertexTypeEnum.ATTRIBUTES), any(AttributeDefinition.class),
+ eq(JsonPresentationFields.NAME));
+ doReturn(Either.left(graphVertex)).when(janusGraphDaoMock).getVertexById(eq(componentId), any(JsonParseFlagEnum.class));
+
+ final ToscaElement toscaElement = getToscaElementForTest();
+ final Map<String, AttributeDataDefinition> attributes = new HashMap<>();
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName("mock");
+ attributes.put("mock", attributeDefinition);
+ toscaElement.setAttributes(attributes);
+ doReturn(Either.left(toscaElement)).when(topologyTemplateOperationMock)
+ .getToscaElement(ArgumentMatchers.eq(graphVertex), any(ComponentParametersView.class));
+
+ final AttributeDefinition attributeDefinitionOneMore = new AttributeDefinition();
+ attributeDefinitionOneMore.setName("Anothermock");
+
+ final Either<AttributeDefinition, StorageOperationStatus> result
+ = testInstance.updateAttributeOfComponent(component, attributeDefinitionOneMore);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void test_updateComponentInstanceAttributes() {
+ final GraphVertex graphVertex = getTopologyTemplateVertex();
+ final String componentId = "componentId";
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+
+ final List<ComponentInstanceAttribute> attributes = new ArrayList<>();
+ final ComponentInstanceAttribute attributeDefinition = new ComponentInstanceAttribute();
+ attributeDefinition.setName("mock");
+ attributes.add(attributeDefinition);
+
+ doReturn(StorageOperationStatus.OK).when(nodeTemplateOperationMock).updateComponentInstanceAttributes(component, componentId, attributes);
+
+ final StorageOperationStatus result = testInstance.updateComponentInstanceAttributes(component, componentId, attributes);
+ assertNotNull(result);
+ assertEquals(StorageOperationStatus.OK, result);
+ verify(nodeTemplateOperationMock, times(1)).updateComponentInstanceAttributes(component, componentId, attributes);
+ }
+
+ @Test
+ public void test_updateComponentInstanceOutputs() {
+ final GraphVertex graphVertex = getTopologyTemplateVertex();
+ final String componentId = "componentId";
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+
+ final List<ComponentInstanceOutput> list = new ArrayList<>();
+ final ComponentInstanceOutput output = new ComponentInstanceOutput();
+ output.setName("mock");
+ list.add(output);
+
+ doReturn(StorageOperationStatus.OK).when(nodeTemplateOperationMock).updateComponentInstanceOutputs(component, componentId, list);
+
+ final StorageOperationStatus result = testInstance.updateComponentInstanceOutputs(component, componentId, list);
+ assertNotNull(result);
+ assertEquals(StorageOperationStatus.OK, result);
+ verify(nodeTemplateOperationMock, times(1)).updateComponentInstanceOutputs(component, componentId, list);
+ }
+
+ @Test
+ public void test_deleteOutputOfResource() {
+ final Component component = new Resource();
+ component.setUniqueId(COMPONENT_ID);
+
+ doReturn(StorageOperationStatus.OK).when(nodeTypeOperationMock)
+ .deleteToscaDataElement(anyString(), eq(EdgeLabelEnum.OUTPUTS), eq(VertexTypeEnum.OUTPUTS), anyString(), eq(JsonPresentationFields.NAME));
+
+ final StorageOperationStatus result = testInstance.deleteOutputOfResource(component, "mock");
+ assertNotNull(result);
+ assertEquals(StorageOperationStatus.OK, result);
+ verify(nodeTypeOperationMock, times(1))
+ .deleteToscaDataElement(anyString(), eq(EdgeLabelEnum.OUTPUTS), eq(VertexTypeEnum.OUTPUTS), anyString(), eq(JsonPresentationFields.NAME));
+ }
+
private StorageOperationStatus associateRequirementsToServiceWithStatus(StorageOperationStatus status) {
Map<String, ListRequirementDataDefinition> requirementsMap = new HashedMap();
String componentId = "componentid";
@@ -819,7 +1044,7 @@ public class ToscaOperationFacadeTest {
requirementsMap.put("requirements1", listRequirementDataDefinition1);
GraphVertex vertex;
- if(status == StorageOperationStatus.OK){
+ if (status == StorageOperationStatus.OK) {
vertex = getTopologyTemplateVertex();
} else {
vertex = getNodeTypeVertex();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java
index 740d148a79..81635e20e0 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java
@@ -29,14 +29,25 @@
*/
package org.openecomp.sdc.be.model.jsonjanusgraph.utils;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.Component;
@@ -47,6 +58,8 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
@@ -107,8 +120,7 @@ public class ModelConverterTest {
}
@Test
- public void testConvertFromToscaElementResourceType()
- {
+ public void testConvertFromToscaElementResourceType() {
TopologyTemplate topologyTemplate = new TopologyTemplate();
topologyTemplate.setComponentType(ComponentTypeEnum.RESOURCE);
topologyTemplate.setResourceType(ResourceTypeEnum.PNF);
@@ -117,8 +129,44 @@ public class ModelConverterTest {
}
@Test
- public void testIsAtomicComponent()
- {
+ public void testConvertFromToscaElementResourceOutputs() {
+ final TopologyTemplate topologyTemplate = new TopologyTemplate();
+ topologyTemplate.setComponentType(ComponentTypeEnum.RESOURCE);
+ final OutputDefinition outputDefinition = new OutputDefinition();
+ final Map<String, AttributeDataDefinition> map = new HashMap<>();
+ map.put("mock", outputDefinition);
+ topologyTemplate.setOutputs(map);
+ final Resource resource = test.convertFromToscaElement(topologyTemplate);
+ assertNotNull(resource.getOutputs());
+ assertFalse(resource.getOutputs().isEmpty());
+ }
+
+ @Test
+ public void testConvertFromToscaElementResourceComponentInstancesOutputs() {
+ final TopologyTemplate topologyTemplate = new TopologyTemplate();
+ topologyTemplate.setComponentType(ComponentTypeEnum.RESOURCE);
+
+ final Map<String, MapAttributesDataDefinition> instOutputs = new HashMap<>();
+ final MapAttributesDataDefinition mapAttributesDataDefinition = new MapAttributesDataDefinition();
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ final Map<String, AttributeDataDefinition> mapToscaDataDefinition = new HashMap<>();
+ mapToscaDataDefinition.put("mock", attributeDefinition);
+ mapAttributesDataDefinition.setMapToscaDataDefinition(mapToscaDataDefinition);
+ instOutputs.put("mock", mapAttributesDataDefinition);
+ topologyTemplate.setInstOutputs(instOutputs);
+
+ final Map<String, ComponentInstanceDataDefinition> componentInstanceDataDefinitionMap = new HashMap<>();
+ componentInstanceDataDefinitionMap.put("mock", new ComponentInstance());
+ topologyTemplate.setComponentInstances(componentInstanceDataDefinitionMap);
+
+ final Resource resource = test.convertFromToscaElement(topologyTemplate);
+ assertNotNull(resource);
+ assertNotNull(resource.getComponentInstancesOutputs());
+ assertFalse(resource.getComponentInstancesOutputs().isEmpty());
+ }
+
+ @Test
+ public void testIsAtomicComponent() {
Resource component = new Resource();
component.setComponentType(ComponentTypeEnum.RESOURCE);
boolean result = test.isAtomicComponent(component);
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/GetOutputValueDataDefinitionTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/GetOutputValueDataDefinitionTest.java
new file mode 100644
index 0000000000..6c975bd8a2
--- /dev/null
+++ b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/GetOutputValueDataDefinitionTest.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.datatypes.elements;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.HashMap;
+import org.junit.jupiter.api.Test;
+
+class GetOutputValueDataDefinitionTest {
+
+ private final GetOutputValueDataDefinition testInstance = new GetOutputValueDataDefinition();
+
+ @Test
+ void testCtor() throws Exception {
+ assertThat(testInstance, instanceOf(GetOutputValueDataDefinition.class));
+ assertThat(new GetOutputValueDataDefinition(new HashMap<>()), instanceOf(GetOutputValueDataDefinition.class));
+ assertThat(new GetOutputValueDataDefinition(testInstance), instanceOf(GetOutputValueDataDefinition.class));
+ }
+
+}