aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java49
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventFactoryTest.java33
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditGetUsersListEventFactoryTest.java30
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactoryTest.java29
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java23
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java47
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeclaratorTest.java91
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyDeclaratorTest.java132
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyToPolicyDeclaratorTest.java26
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/property/GroupPropertyDeclaratorTest.java62
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeclaratorTest.java56
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeclaratorTestBase.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ConsumptionUtilsTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java38
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java66
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java51
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java56
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java17
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java9
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java24
-rw-r--r--catalog-dao/src/test/resources/fixtures/ListCapabilityDataDefinition2.json17
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatusTest.java10
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/test/java/org/openecomp/types/AsdcElementTest.java66
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypesTest.java64
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestinationTest.java28
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/test/java/org/openecomp/core/validation/types/GlobalValidationContextTest.java43
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertorTest.java9
27 files changed, 768 insertions, 336 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java
index e672ced134..5cfa64ea49 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java
@@ -19,22 +19,23 @@
*/
package org.openecomp.sdc.be.auditing.impl;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
+import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
+import org.openecomp.sdc.common.log.wrappers.LoggerSdcAudit;
import org.openecomp.sdc.test.utils.TestConfigurationProvider;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class AuditingManagerTest {
private static final String MSG = "msg";
@@ -47,21 +48,39 @@ public class AuditingManagerTest {
private AuditCassandraDao cassandraDao;
@Mock
private AuditEventFactory eventFactory;
-
- @Before
- public void setUp() throws Exception {
+ @Mock
+ private ConfigurationProvider config;
+ @Test
+ public void testShouldAuditEvent() {
auditingManager = new AuditingManager(cassandraDao, new TestConfigurationProvider());
Mockito.when(eventFactory.getLogMessage()).thenReturn(msg);
Mockito.when(eventFactory.getDbEvent()).thenReturn(auditEvent);
Mockito.when(cassandraDao.saveRecord(auditEvent)).thenReturn(CassandraOperationStatus.OK);
- }
-
- @Test
- public void testShouldAuditEvent() {
String result = auditingManager.auditEvent(eventFactory);
- assertThat(result, is(msg));
+ assertEquals(msg, result);
Mockito.verify(cassandraDao).saveRecord(auditEvent);
}
+ @Test
+ public void testShouldNotAuditEvent() {
+ Configuration testConfig = new Configuration();
+ testConfig.setDisableAudit(true);
+ Mockito.when(config.getConfiguration()).thenReturn(testConfig);
+
+ AuditingManager auditingManager2 = new AuditingManager(cassandraDao, config);
+ assertNull(auditingManager2.auditEvent(eventFactory));
+ Mockito.verify(config, Mockito.times(1)).getConfiguration();
+ }
+ @Test
+ public void testShouldAuditEventWithLog() {
+ auditingManager = new AuditingManager(cassandraDao, new TestConfigurationProvider());
+ Mockito.when(eventFactory.getLogMessage()).thenReturn(msg);
+ Mockito.when(eventFactory.getDbEvent()).thenReturn(auditEvent);
+ Mockito.when(cassandraDao.saveRecord(auditEvent)).thenReturn(CassandraOperationStatus.OK);
+ LoggerSdcAudit logger = Mockito.mock(LoggerSdcAudit.class);
+ String result = auditingManager.auditEvent(eventFactory, logger);
+ assertEquals(msg, result);
+ Mockito.verify(cassandraDao).saveRecord(auditEvent);
+ }
} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventFactoryTest.java
index 554d8efdc2..1ab5faee15 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventFactoryTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventFactoryTest.java
@@ -20,38 +20,29 @@
package org.openecomp.sdc.be.auditing.impl.category;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder;
-public class AuditGetCategoryHierarchyEventFactoryTest {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
- private AuditGetCategoryHierarchyEventFactory createTestSubject() {
- Builder newBuilder = CommonAuditData.newBuilder();
- CommonAuditData build = newBuilder.build();
- return new AuditGetCategoryHierarchyEventFactory( build,
- new User(), "");
- }
+public class AuditGetCategoryHierarchyEventFactoryTest {
+ private Builder newBuilder = CommonAuditData.newBuilder();
+ private CommonAuditData build = newBuilder.build();
@Test
public void testGetLogMessage() throws Exception {
- AuditGetCategoryHierarchyEventFactory testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLogMessage();
+ AuditGetCategoryHierarchyEventFactory testSubject = new AuditGetCategoryHierarchyEventFactory( build,
+ "user", "", "");
+ assertEquals("ACTION = \"GetCategoryHierarchy\" MODIFIER = \"user\" DETAILS = \"\" STATUS = \"\" DESC = \"\"", testSubject.getLogMessage());
}
@Test
public void testGetDbEvent() throws Exception {
- AuditGetCategoryHierarchyEventFactory testSubject;
- AuditingGenericEvent result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDbEvent();
+ AuditGetCategoryHierarchyEventFactory testSubject = new AuditGetCategoryHierarchyEventFactory( build, new User(), "");
+ assertNotNull(testSubject.getDbEvent());
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditGetUsersListEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditGetUsersListEventFactoryTest.java
index 8e6785a9b1..46b746f5ae 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditGetUsersListEventFactoryTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditGetUsersListEventFactoryTest.java
@@ -20,36 +20,26 @@
package org.openecomp.sdc.be.auditing.impl.usersadmin;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
-public class AuditGetUsersListEventFactoryTest {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
- private AuditGetUsersListEventFactory createTestSubject() {
- org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder();
- CommonAuditData commonAuData = newBuilder.build();
- return new AuditGetUsersListEventFactory(commonAuData, new User(), "");
- }
+public class AuditGetUsersListEventFactoryTest {
+ private org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder();
+ private CommonAuditData commonAuData = newBuilder.build();
@Test
public void testGetLogMessage() throws Exception {
- AuditGetUsersListEventFactory testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLogMessage();
+ AuditGetUsersListEventFactory testSubject = new AuditGetUsersListEventFactory(commonAuData, "user", "", "");
+ assertEquals("ACTION = \"GetUsersList\" MODIFIER = \"user\" DETAILS = \"\" STATUS = \"\" DESC = \"\"", testSubject.getLogMessage());
}
@Test
public void testGetDbEvent() throws Exception {
- AuditGetUsersListEventFactory testSubject;
- AuditingGenericEvent result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDbEvent();
+ AuditGetUsersListEventFactory testSubject = new AuditGetUsersListEventFactory(commonAuData, new User(), "");
+ assertNotNull(testSubject.getDbEvent());
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactoryTest.java
index 13448a9c8f..4fe8fe7733 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactoryTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactoryTest.java
@@ -20,36 +20,27 @@
package org.openecomp.sdc.be.auditing.impl.usersadmin;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
-public class AuditUserAccessEventFactoryTest {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
- private AuditUserAccessEventFactory createTestSubject() {
- org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder();
- CommonAuditData commonAuData = newBuilder.build();
- return new AuditUserAccessEventFactory(commonAuData, new User());
- }
+public class AuditUserAccessEventFactoryTest {
+ private org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder();
+ private CommonAuditData commonAuData = newBuilder.build();
@Test
public void testGetLogMessage() throws Exception {
- AuditUserAccessEventFactory testSubject;
- String result;
+ AuditUserAccessEventFactory testSubject = new AuditUserAccessEventFactory(commonAuData, new User());
+ assertEquals("ACTION = \"Access\" USER = \"\" STATUS = \"\" DESC = \"\"", testSubject.getLogMessage());
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLogMessage();
}
@Test
public void testGetDbEvent() throws Exception {
- AuditUserAccessEventFactory testSubject;
- AuditingGenericEvent result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDbEvent();
+ AuditUserAccessEventFactory testSubject = new AuditUserAccessEventFactory(commonAuData, "user", "");
+ assertNotNull(testSubject.getDbEvent());
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
index f3f0ab5628..fddb79afb6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.be.components.csar;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.config.NonManoArtifactType;
@@ -54,9 +54,10 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class CsarInfoTest {
private CsarInfo csarInfo;
@@ -72,7 +73,7 @@ public class CsarInfoTest {
private static final String NODE_TYPE = "tosca.nodes.Compute";
private static final String DELIVER_FOR = "tosca.nodes.Root";
- @Before
+ @BeforeEach
public void setup() throws ZipException, URISyntaxException {
// given
csarInfo = createCsarInfo(PAYLOAD_NAME, MAIN_TEMPLATE_NAME);
@@ -116,6 +117,16 @@ public class CsarInfoTest {
}
@Test
+ public void setUpdateTest() {
+
+ csarInfo.setUpdate(true);
+ assertTrue(csarInfo.isUpdate());
+
+ csarInfo.setUpdate(false);
+ assertFalse(csarInfo.isUpdate());
+ }
+
+ @Test
public void csarCheckNodeTypesInfoTest() {
// when
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java
index 6b5d41d5ae..d8da908e0d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java
@@ -17,14 +17,13 @@
package org.openecomp.sdc.be.components.property;
import fj.data.Either;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.utils.AnnotationBuilder;
import org.openecomp.sdc.be.components.utils.InputsBuilder;
@@ -51,15 +50,17 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static org.openecomp.sdc.be.MockGenerator.mockComponentUtils;
import static org.openecomp.sdc.be.MockGenerator.mockExceptionUtils;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
@@ -82,7 +83,7 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
private Annotation annotation2;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
testInstance = new ComponentInstanceInputPropertyDeclarator(mockComponentUtils(), propertyOperation,
@@ -110,9 +111,9 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
when(toscaOperationFacade.getToscaElement(eq(ORIGIN_INSTANCE_ID), inputsFilterCaptor.capture())).thenReturn(Either.left(originInstanceNodeType));
Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
List<InputDefinition> inputs = createdInputs.left().value();
- assertThat(inputs).hasSize(1);
+ assertEquals(1, inputs.size());
verifyInputAnnotations(inputs.get(0));
- assertThat(inputsFilterCaptor.getValue().isIgnoreInputs()).isFalse();
+ assertFalse(inputsFilterCaptor.getValue().isIgnoreInputs());
}
@Test
@@ -120,13 +121,15 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
List<PropertyDataDefinition> properties = Collections.singletonList(prop1);
List<ComponentInstancePropInput> propsToDeclare = createInstancePropInputList(properties);
when(toscaOperationFacade.getToscaElement(eq(ORIGIN_INSTANCE_ID), inputsFilterCaptor.capture())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
- assertThatExceptionOfType(StorageException.class).isThrownBy(() -> testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare));
+ assertThrows(StorageException.class, () -> {
+ testInstance.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
+ });
}
@Test
public void testCreateDeclaredProperty() {
ComponentInstanceInput declaredProperty = testInstance.createDeclaredProperty(prop1);
- assertThat(declaredProperty.getUniqueId()).isEqualTo(prop1.getUniqueId());
+ assertEquals(prop1.getUniqueId(), declaredProperty.getUniqueId());
}
@Test
@@ -141,18 +144,18 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> updateEither =
(Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus>) testInstance.updatePropertiesValues(resource, resource.getUniqueId(), expectedProperties);
- assertThat(updateEither.isLeft());
+ assertTrue(updateEither.isLeft());
Map<String, List<ComponentInstanceInput>> actualProperties = updateEither.left().value();
- assertThat(actualProperties.values().size()).isEqualTo(expectedProperties.size());
- assertThat(actualProperties.values().iterator().next()).isEqualTo(expectedProperties);
+ assertEquals(expectedProperties.size(), actualProperties.values().size());
+ assertEquals(expectedProperties, actualProperties.values().iterator().next());
}
@Test
public void testResolvePropertiesOwner() {
Optional<ComponentInstance> componentInstance = testInstance.resolvePropertiesOwner(resource, INSTANCE_ID);
- assertThat(componentInstance.isPresent());
- assertThat(componentInstance.get().getUniqueId()).isEqualTo(INSTANCE_ID);
+ assertTrue(componentInstance.isPresent());
+ assertEquals(INSTANCE_ID, componentInstance.get().getUniqueId());
}
@Test
@@ -189,7 +192,7 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
when(toscaOperationFacade.updateComponentInstanceInputs(eq(component), eq(ciProp.getComponentInstanceId()), eq(ciPropList))).thenReturn(StorageOperationStatus.OK);
StorageOperationStatus storageOperationStatus = testInstance.unDeclarePropertiesAsListInputs(component, inputToDelete);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
}
@Test
@@ -201,13 +204,13 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
List<ComponentInstanceInput> resList = new ArrayList<>();
when(componentInstanceBusinessLogic.getComponentInstanceInputsByInputId(eq(resource), eq(INPUT_ID))).thenReturn(resList);
StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
- Assert.assertEquals(status, StorageOperationStatus.OK);
+ assertEquals(status, StorageOperationStatus.OK);
}
private void verifyInputAnnotations(InputDefinition inputDefinition) {
List<Annotation> annotations = inputDefinition.getAnnotations();
- assertThat(annotations)
- .containsExactlyInAnyOrder(annotation1, annotation2);
+ assertTrue(annotations.contains(annotation1));
+ assertTrue(annotations.contains(annotation2));
}
private Component createComponentWithInputAndAnnotation(String inputName) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeclaratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeclaratorTest.java
index 07deb6a2de..bcbd07db31 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeclaratorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeclaratorTest.java
@@ -17,14 +17,14 @@
package org.openecomp.sdc.be.components.property;
import fj.data.Either;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.utils.InputsBuilder;
import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
@@ -57,7 +57,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verifyZeroInteractions;
@@ -66,7 +66,7 @@ import static org.openecomp.sdc.be.components.property.CapabilityTestUtils.creat
import static org.openecomp.sdc.be.components.property.CapabilityTestUtils.createProperties;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorTestBase {
@InjectMocks
@@ -90,7 +90,7 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
public void declarePropertiesAsInputs_componentInstanceNotExist() {
Component cmpt = new Resource();
Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance.declarePropertiesAsInputs(cmpt, "someCmptInstId", Collections.emptyList());
- assertThat(createdInputs.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND);
+ assertEquals(StorageOperationStatus.NOT_FOUND, createdInputs.right().value());
verifyZeroInteractions(toscaOperationFacade);
}
@@ -128,7 +128,7 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
Either<List<InputDefinition>, StorageOperationStatus> createdInputs = testInstance
.declarePropertiesAsInputs(resource, "inst1", propsToDeclare);
- Assert.assertTrue(createdInputs.isLeft());
+ assertTrue(createdInputs.isLeft());
}
@Test
@@ -161,7 +161,7 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
any(ComponentInstanceProperty.class), any(CapabilityDefinition.class))).thenReturn(StorageOperationStatus.OK);
StorageOperationStatus result = testInstance.unDeclarePropertiesAsInputs(component, input);
- Assert.assertEquals(StorageOperationStatus.OK, result);
+ assertEquals(StorageOperationStatus.OK, result);
}
@Test
@@ -207,8 +207,8 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
PropertyDefinition propertyDefinition = getPropertyForDeclaration();
ComponentInstanceProperty declaredProperty = testInstance.createDeclaredProperty(propertyDefinition);
- assertThat(declaredProperty).isNotNull();
- assertThat(declaredProperty.getUniqueId()).isEqualTo(propertyDefinition.getUniqueId());
+ assertNotNull(declaredProperty);
+ assertEquals(propertyDefinition.getUniqueId(), declaredProperty.getUniqueId());
}
@Test
@@ -237,7 +237,7 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
StorageOperationStatus undeclareStatus =
testInstance.unDeclarePropertiesAsInputs(service, inputToDelete);
- assertThat(undeclareStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, undeclareStatus);
}
private List<GetInputValueDataDefinition> getGetInputListForDeclaration() {
@@ -271,16 +271,16 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
when(toscaOperationFacade.addComponentInstancePropertiesToComponent(eq(resource), instancePropertiesCaptor.capture())).thenReturn(Either.left(Collections.emptyMap()));
Either<InputDefinition, StorageOperationStatus> result = testInstance.declarePropertiesAsListInput(resource, "inst1", propsToDeclare, input);
// validate result
- assertThat(result.isLeft()).isTrue();
+ assertTrue(result.isLeft());
List<ComponentInstanceProperty> capturedInstanceProperties = instancePropertiesCaptor.getValue().get(INSTANCE_ID);
- assertThat(capturedInstanceProperties.size()).isEqualTo(2);
+ assertEquals(2, capturedInstanceProperties.size());
Map<String, PropertyDataDefinition> propertiesMap =
properties.stream().collect(Collectors.toMap(PropertyDataDefinition::getName, e->e));
for(ComponentInstanceProperty instanceProperty: capturedInstanceProperties) {
- assertThat(propertiesMap.containsKey(instanceProperty.getName())).isTrue();
+ assertTrue(propertiesMap.containsKey(instanceProperty.getName()));
PropertyDataDefinition property = propertiesMap.get(instanceProperty.getName());
- assertThat(instanceProperty.getType()).isEqualTo(property.getType());
- assertThat(instanceProperty.isGetInputProperty()).isTrue();
+ assertEquals(property.getType(), instanceProperty.getType());
+ assertTrue(instanceProperty.isGetInputProperty());
}
}
@@ -297,8 +297,8 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
.build());
Either<InputDefinition, StorageOperationStatus> result = testInstance.declarePropertiesAsListInput(resource, "inst2", propsToDeclare, input);
// validate result
- assertThat(result.isRight()).isTrue();
- assertThat(result.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND);
+ assertTrue(result.isRight());
+ assertEquals(StorageOperationStatus.NOT_FOUND, result.right().value());
}
@Test
@@ -335,7 +335,7 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
when(toscaOperationFacade.updateComponentInstanceProperties(eq(component), eq(ciProp.getComponentInstanceId()), eq(ciPropList))).thenReturn(StorageOperationStatus.OK);
StorageOperationStatus storageOperationStatus = testInstance.unDeclarePropertiesAsListInputs(component, inputToDelete);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
}
@Test
@@ -347,29 +347,29 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
List<ComponentInstanceProperty> resList = new ArrayList<>();
when(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(eq(resource), eq(INPUT_ID))).thenReturn(resList);
StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
- Assert.assertEquals(status, StorageOperationStatus.OK);
+ assertEquals(status, StorageOperationStatus.OK);
}
private void verifyUpdatedProperties(List<PropertyDataDefinition> properties, List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
- assertThat(capturedInstanceProperties).hasSize(properties.size());
+ assertEquals(properties.size(), capturedInstanceProperties.size());
Map<String, ComponentInstanceProperty> updatedPropertiesByName = MapUtil.toMap(capturedInstanceProperties, ComponentInstanceProperty::getName);
properties.forEach(prop -> verifyUpdatedInstanceProperty(prop, updatedPropertiesByName.get(prop.getName()), inputs));
}
private void verifyUpdatedComplexProperty(List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
- assertThat(capturedInstanceProperties).hasSize(1);
+ assertEquals(1, capturedInstanceProperties.size());
verifyUpdatedInstanceComplexProperty(capturedInstanceProperties.get(0), inputs);
}
private void verifyCreatedInputs(List<PropertyDataDefinition> originalPropsToDeclare, List<ComponentInstanceProperty> capturedUpdatedProperties, List<InputDefinition> inputs) {
- assertThat(inputs).hasSize(originalPropsToDeclare.size());
+ assertEquals(originalPropsToDeclare.size(), inputs.size());
Map<String, InputDefinition> propertyIdToCreatedInput = MapUtil.toMap(inputs, InputDefinition::getPropertyId);
originalPropsToDeclare.forEach(propToDeclare -> verifyCreatedInput(propToDeclare, propertyIdToCreatedInput.get(propToDeclare.getUniqueId())));
capturedUpdatedProperties.forEach(updatedProperty -> verifyInputPropertiesList(updatedProperty, propertyIdToCreatedInput.get(updatedProperty.getUniqueId())));
}
private void verifyCreatedInputsFromComplexProperty(List<ComponentInstancePropInput> propsToDeclare, List<ComponentInstanceProperty> capturedInstanceProperties, List<InputDefinition> inputs) {
- assertThat(inputs).hasSize(propsToDeclare.size());
+ assertEquals(propsToDeclare.size(), inputs.size());
Map<String, InputDefinition> inputsByName = MapUtil.toMap(inputs, InputDefinition::getName);
propsToDeclare.forEach(propToDeclare -> verifyCreatedInputFromComplexProperty(propToDeclare, inputsByName));
Map<String, List<InputDefinition>> propertyIdToCreatedInput = MapUtil.groupListBy(inputs, InputDefinition::getPropertyId);
@@ -384,18 +384,17 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
PropertyDefinition innerProperty = parentProperty.getInput();
String expectedInputName = generateExpectedInputName(parentProperty, innerProperty);
InputDefinition input = inputsByName.get(expectedInputName);
- assertThat(input.getType()).isEqualTo(innerProperty.getType());
- assertThat(input.getValue()).isEqualTo(innerProperty.getValue());
+ assertEquals(innerProperty.getType(), input.getType());
+ assertEquals(innerProperty.getValue(), input.getValue());
// assertThat(input.getDefaultValue()).isEqualTo(innerProperty.getValue());//bug
- assertThat(input.getUniqueId()).isEqualTo(UniqueIdBuilder.buildPropertyUniqueId(RESOURCE_ID, input.getName()));
- assertThat(input.getPropertyId()).isEqualTo(parentProperty.getUniqueId());
- assertThat(input.getInstanceUniqueId()).isEqualTo(INSTANCE_ID);
+ assertEquals(UniqueIdBuilder.buildPropertyUniqueId(RESOURCE_ID, input.getName()), input.getUniqueId());
+ assertEquals(INSTANCE_ID, input.getInstanceUniqueId());
}
private void verifyInputPropertiesList(ComponentInstanceProperty updatedProperty, InputDefinition input) {
- assertThat(input.getProperties()).hasSize(1);
- assertThat(updatedProperty).isEqualTo(input.getProperties().get(0));
+ assertEquals(1, input.getProperties().size());
+ assertEquals(input.getProperties().get(0), updatedProperty);
}
@@ -411,17 +410,17 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
}
private void verifyUpdatedInstanceProperty(PropertyDataDefinition originalProperty, ComponentInstanceProperty updatedProperty, List<InputDefinition> inputs) {
- assertThat(updatedProperty.getValue()).isEqualTo(generateGetInputValue(generateExpectedInputName(originalProperty)));
- assertThat(updatedProperty.isGetInputProperty()).isTrue();
- assertThat(updatedProperty.getName()).isEqualTo(originalProperty.getName());
+ assertEquals(generateGetInputValue(generateExpectedInputName(originalProperty)), updatedProperty.getValue());
+ assertTrue(updatedProperty.isGetInputProperty());
+ assertEquals(originalProperty.getName(), updatedProperty.getName());
List<GetInputValueDataDefinition> getInputValues = updatedProperty.getGetInputValues();
verifyGetInputValues(getInputValues, inputs);
}
private void verifyUpdatedInstanceComplexProperty(ComponentInstanceProperty updatedComplexProperty, List<InputDefinition> inputs) {
- assertThat(updatedComplexProperty.getValue()).isEqualTo(generateComplexGetInputValue(inputs));
- assertThat(updatedComplexProperty.isGetInputProperty()).isTrue();
- assertThat(updatedComplexProperty.getName()).isEqualTo(complexProperty.getName());
+ assertEquals(generateComplexGetInputValue(inputs), updatedComplexProperty.getValue());
+ assertTrue(updatedComplexProperty.isGetInputProperty());
+ assertEquals(complexProperty.getName(), updatedComplexProperty.getName());
List<GetInputValueDataDefinition> getInputValues = updatedComplexProperty.getGetInputValues();
verifyGetInputValues(getInputValues, inputs);
}
@@ -430,7 +429,7 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
Map<String, InputDefinition> inputsByName = MapUtil.toMap(inputs, InputDefinition::getName);
getInputValues.forEach(getInputVal -> {
InputDefinition input = inputsByName.get(getInputVal.getInputName());
- assertThat(input.getUniqueId()).isEqualTo(getInputVal.getInputId());
+ assertEquals(getInputVal.getInputId(), input.getUniqueId());
});
}
@@ -447,13 +446,13 @@ public class ComponentInstancePropertyDeclaratorTest extends PropertyDeclaratorT
}
private void verifyCreatedInput(PropertyDataDefinition property, InputDefinition input) {
- assertThat(input.getType()).isEqualTo(property.getType());
- assertThat(input.getName()).isEqualTo(generateExpectedInputName(property));
- assertThat(input.getValue()).isEqualTo(property.getValue());
- assertThat(input.getDefaultValue()).isEqualTo(property.getValue());
- assertThat(input.getUniqueId()).isEqualTo(UniqueIdBuilder.buildPropertyUniqueId(RESOURCE_ID, input.getName()));
- assertThat(input.getPropertyId()).isEqualTo(property.getUniqueId());
- assertThat(input.getInstanceUniqueId()).isEqualTo(INSTANCE_ID);
+ assertEquals(property.getType(), input.getType());
+ assertEquals(generateExpectedInputName(property), input.getName());
+ assertEquals(property.getValue(), input.getValue());
+ assertEquals(property.getValue(), input.getDefaultValue());
+ assertEquals(UniqueIdBuilder.buildPropertyUniqueId(RESOURCE_ID, input.getName()), input.getUniqueId());
+ assertEquals(property.getUniqueId(), input.getPropertyId());
+ assertEquals(INSTANCE_ID, input.getInstanceUniqueId());
}
private Component createComponentWithListInput(String inputName, String propName) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyDeclaratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyDeclaratorTest.java
index 057c4fba42..62d1d76c5c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyDeclaratorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyDeclaratorTest.java
@@ -22,12 +22,12 @@ package org.openecomp.sdc.be.components.property;
import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+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.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
import org.openecomp.sdc.be.components.utils.InputsBuilder;
import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
@@ -55,7 +55,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class ComponentPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
@InjectMocks
@@ -71,12 +71,26 @@ public class ComponentPropertyDeclaratorTest extends PropertyDeclaratorTestBase
private static final String SERVICE_UID = "serviceUid";
private Service service;
- @Before
+ @BeforeEach
public void init() {
service = new ServiceBuilder().setUniqueId(SERVICE_UID).build();
}
@Test
+ public void unDeclarePropertiesAsInputsTest_whenPropertyUsedByOperation() {
+ InputDefinition input = new InputDefinition();
+ input.setUniqueId(INPUT_ID);
+ input.setName(INPUT_ID);
+ input.setValue("value");
+
+ PropertyDefinition propertyDefinition = new PropertyDefinition(input);
+
+ when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), eq(propertyDefinition))).thenReturn(true);
+ StorageOperationStatus status = testInstance.unDeclarePropertiesAsInputs(resource, input);
+ Assert.assertEquals(StorageOperationStatus.DECLARED_INPUT_USED_BY_OPERATION, status);
+ }
+
+ @Test
public void unDeclarePropertiesAsListInputsTest_whenPropertyUsedByOperation() {
InputDefinition input = new InputDefinition();
input.setUniqueId(INPUT_ID);
@@ -87,7 +101,22 @@ public class ComponentPropertyDeclaratorTest extends PropertyDeclaratorTestBase
when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), eq(propertyDefinition))).thenReturn(true);
StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
- Assert.assertEquals(status, StorageOperationStatus.DECLARED_INPUT_USED_BY_OPERATION);
+ Assert.assertEquals(StorageOperationStatus.DECLARED_INPUT_USED_BY_OPERATION, status);
+ }
+
+ @Test
+ public void unDeclarePropertiesAsInputsTest_whenNotPresentPropertyToUpdateCandidate() {
+ InputDefinition input = new InputDefinition();
+ input.setUniqueId(INPUT_ID);
+ input.setName(INPUT_ID);
+ input.setValue("value");
+
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ resource.setProperties(Collections.singletonList(propertyDefinition));
+
+ when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), any(PropertyDefinition.class))).thenReturn(false);
+ StorageOperationStatus status = testInstance.unDeclarePropertiesAsInputs(resource, input);
+ Assert.assertEquals(StorageOperationStatus.OK, status);
}
@Test
@@ -102,7 +131,21 @@ public class ComponentPropertyDeclaratorTest extends PropertyDeclaratorTestBase
when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), any(PropertyDefinition.class))).thenReturn(false);
StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
- Assert.assertEquals(status, StorageOperationStatus.OK);
+ Assert.assertEquals(StorageOperationStatus.OK, status);
+ }
+
+ @Test
+ public void unDeclarePropertiesAsInputsTest_whenPropertiesEmpty() {
+ InputDefinition input = new InputDefinition();
+ input.setUniqueId(INPUT_ID);
+ input.setName(INPUT_ID);
+ input.setValue("value");
+
+ resource.setProperties(new ArrayList<>());
+
+ when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), any(PropertyDefinition.class))).thenReturn(false);
+ StorageOperationStatus status = testInstance.unDeclarePropertiesAsInputs(resource, input);
+ Assert.assertEquals(StorageOperationStatus.OK, status);
}
@Test
@@ -116,7 +159,22 @@ public class ComponentPropertyDeclaratorTest extends PropertyDeclaratorTestBase
when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), any(PropertyDefinition.class))).thenReturn(false);
StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
- Assert.assertEquals(status, StorageOperationStatus.OK);
+ Assert.assertEquals(StorageOperationStatus.OK, status);
+ }
+
+ @Test
+ public void unDeclarePropertiesAsInputsTest_whenPropertiesToUpdateIsEmpty() {
+ InputDefinition input = new InputDefinition();
+ input.setUniqueId(INPUT_ID);
+ input.setName(INPUT_ID);
+ input.setValue("value");
+
+ PropertyDefinition propertyDefinition = new PropertyDefinition(input);
+ resource.setProperties(Collections.singletonList(propertyDefinition));
+
+ when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), eq(propertyDefinition))).thenReturn(false);
+ StorageOperationStatus status = testInstance.unDeclarePropertiesAsInputs(resource, input);
+ Assert.assertEquals(StorageOperationStatus.OK, status);
}
@Test
@@ -131,7 +189,32 @@ public class ComponentPropertyDeclaratorTest extends PropertyDeclaratorTestBase
when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), eq(propertyDefinition))).thenReturn(false);
StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
- Assert.assertEquals(status, StorageOperationStatus.OK);
+ Assert.assertEquals(StorageOperationStatus.OK, status);
+ }
+
+ @Test
+ public void unDeclarePropertiesAsInputsTest_singleProperty() {
+ InputDefinition input = new InputDefinition();
+ input.setUniqueId(INPUT_ID);
+ input.setName(INPUT_ID);
+ input.setValue("value");
+ input.setDefaultValue("default value");
+
+ PropertyDefinition propertyDefinition = new PropertyDefinition(input);
+ List<GetInputValueDataDefinition> getInputValueList = new ArrayList<>();
+ getInputValueList.add(buildGetInputValue(INPUT_ID));
+ getInputValueList.add(buildGetInputValue("otherInputId"));
+ propertyDefinition.setGetInputValues(getInputValueList);
+ propertyDefinition.setUniqueId("propertyId");
+ propertyDefinition.setDefaultValue("default value");
+ propertyDefinition.setValue(generateGetInputValueAsListInput(INPUT_ID, "innerPropName"));
+ resource.setProperties(Collections.singletonList(propertyDefinition));
+
+ when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), any())).thenReturn(false);
+ when(propertyOperation.findDefaultValueFromSecondPosition(eq(Collections.emptyList()), eq(propertyDefinition.getUniqueId()), eq(propertyDefinition.getDefaultValue()))).thenReturn(Either.left(propertyDefinition.getDefaultValue()));
+ when(toscaOperationFacade.updatePropertyOfComponent(eq(resource), any())).thenReturn(Either.left(propertyDefinition));
+ StorageOperationStatus status = testInstance.unDeclarePropertiesAsInputs(resource, input);
+ Assert.assertEquals(StorageOperationStatus.OK, status);
}
@Test
@@ -156,7 +239,32 @@ public class ComponentPropertyDeclaratorTest extends PropertyDeclaratorTestBase
when(propertyOperation.findDefaultValueFromSecondPosition(eq(Collections.emptyList()), eq(propertyDefinition.getUniqueId()), eq(propertyDefinition.getDefaultValue()))).thenReturn(Either.left(propertyDefinition.getDefaultValue()));
when(toscaOperationFacade.updatePropertyOfComponent(eq(resource), any())).thenReturn(Either.left(propertyDefinition));
StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
- Assert.assertEquals(status, StorageOperationStatus.OK);
+ Assert.assertEquals(StorageOperationStatus.OK, status);
+ }
+
+ @Test
+ public void unDeclarePropertiesAsInputsTest_UnDeclareInputFail() {
+ InputDefinition input = new InputDefinition();
+ input.setUniqueId(INPUT_ID);
+ input.setName(INPUT_ID);
+ input.setValue("value");
+ input.setDefaultValue("default value");
+
+ PropertyDefinition propertyDefinition = new PropertyDefinition(input);
+ List<GetInputValueDataDefinition> getInputValueList = new ArrayList<>();
+ getInputValueList.add(buildGetInputValue(INPUT_ID));
+ getInputValueList.add(buildGetInputValue("otherInputId"));
+ propertyDefinition.setGetInputValues(getInputValueList);
+ propertyDefinition.setUniqueId("propertyId");
+ propertyDefinition.setDefaultValue("default value");
+ propertyDefinition.setValue(generateGetInputValueAsListInput(INPUT_ID, "innerPropName"));
+ resource.setProperties(Collections.singletonList(propertyDefinition));
+
+ when(propertyBusinessLogic.isPropertyUsedByOperation(eq(resource), any())).thenReturn(false);
+ when(propertyOperation.findDefaultValueFromSecondPosition(eq(Collections.emptyList()), eq(propertyDefinition.getUniqueId()), eq(propertyDefinition.getDefaultValue()))).thenReturn(Either.left(propertyDefinition.getDefaultValue()));
+ when(toscaOperationFacade.updatePropertyOfComponent(eq(resource), any())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ StorageOperationStatus status = testInstance.unDeclarePropertiesAsInputs(resource, input);
+ Assert.assertEquals(StorageOperationStatus.NOT_FOUND, status);
}
@Test
@@ -181,7 +289,7 @@ public class ComponentPropertyDeclaratorTest extends PropertyDeclaratorTestBase
when(propertyOperation.findDefaultValueFromSecondPosition(eq(Collections.emptyList()), eq(propertyDefinition.getUniqueId()), eq(propertyDefinition.getDefaultValue()))).thenReturn(Either.left(propertyDefinition.getDefaultValue()));
when(toscaOperationFacade.updatePropertyOfComponent(eq(resource), any())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
StorageOperationStatus status = testInstance.unDeclarePropertiesAsListInputs(resource, input);
- Assert.assertEquals(status, StorageOperationStatus.NOT_FOUND);
+ Assert.assertEquals(StorageOperationStatus.NOT_FOUND, status);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyToPolicyDeclaratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyToPolicyDeclaratorTest.java
index 96ba42d7b2..02d809d75c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyToPolicyDeclaratorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentPropertyToPolicyDeclaratorTest.java
@@ -22,15 +22,15 @@ package org.openecomp.sdc.be.components.property;
import fj.data.Either;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.property.propertytopolicydeclarators.ComponentPropertyToPolicyDeclarator;
import org.openecomp.sdc.be.datatypes.elements.GetPolicyValueDataDefinition;
import org.openecomp.sdc.be.model.PolicyDefinition;
@@ -43,10 +43,12 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class ComponentPropertyToPolicyDeclaratorTest extends PropertyDeclaratorTestBase {
@InjectMocks
@@ -72,7 +74,7 @@ public class ComponentPropertyToPolicyDeclaratorTest extends PropertyDeclaratorT
Either<List<PolicyDefinition>, StorageOperationStatus> declareEither = declarator.declarePropertiesAsPolicies(
service, OWNER_ID, createInstancePropInputList(Collections.singletonList(prop1)));
- Assert.assertTrue(declareEither.isLeft());
+ assertTrue(declareEither.isLeft());
}
@Test
@@ -92,8 +94,8 @@ public class ComponentPropertyToPolicyDeclaratorTest extends PropertyDeclaratorT
PropertyDefinition actualProperty = propertyCaptor.getValue();
- Assert.assertEquals(storageOperationStatus, storageOperationStatus.OK);
- Assert.assertEquals(expectedProperty, actualProperty);
+ assertEquals(storageOperationStatus.OK, storageOperationStatus);
+ assertEquals(expectedProperty, actualProperty);
}
@@ -111,7 +113,7 @@ public class ComponentPropertyToPolicyDeclaratorTest extends PropertyDeclaratorT
Either<List<PolicyDefinition>, StorageOperationStatus> declareEither = declarator.declarePropertiesAsPolicies(
service, OWNER_ID, createInstancePropInputList(Collections.singletonList(prop1)));
- Assert.assertTrue(declareEither.isLeft());
+ assertTrue(declareEither.isLeft());
PolicyDefinition policyDefinition = createPolicyDefinition(prop1.getUniqueId());
StorageOperationStatus storageOperationStatus =
@@ -119,9 +121,9 @@ public class ComponentPropertyToPolicyDeclaratorTest extends PropertyDeclaratorT
List<PropertyDefinition> actualProperties = propertyCaptor.getAllValues();
- Assert.assertEquals(storageOperationStatus, storageOperationStatus.OK);
- Assert.assertEquals(actualProperties.size(), 2);
- Assert.assertEquals(prop1.getValue(), actualProperties.get(1).getValue());
+ assertEquals(storageOperationStatus.OK, storageOperationStatus);
+ assertEquals(2, actualProperties.size());
+ assertEquals(prop1.getValue(), actualProperties.get(1).getValue());
}
private PropertyDefinition createPropertyWithDeclaredPolicy(String policyId) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/GroupPropertyDeclaratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/GroupPropertyDeclaratorTest.java
index 1619e550d6..616e0babfa 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/GroupPropertyDeclaratorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/GroupPropertyDeclaratorTest.java
@@ -21,14 +21,14 @@
package org.openecomp.sdc.be.components.property;
import fj.data.Either;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.utils.GroupDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
@@ -48,12 +48,14 @@ import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
@@ -70,7 +72,7 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
private InputDefinition input;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
resource = createResourceWithGroup();
@@ -83,7 +85,7 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
@Test
public void testDeclarePropertiesAsInputs_groupNotExist() {
Either<List<InputDefinition>, StorageOperationStatus> declareResult = groupPropertyDeclarator.declarePropertiesAsInputs(resource, "nonExistingGroup", Collections.emptyList());
- assertThat(declareResult.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND);
+ assertEquals(StorageOperationStatus.NOT_FOUND, declareResult.right().value());
verifyZeroInteractions(groupOperation);
}
@@ -91,7 +93,7 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
public void testDeclarePropertiesAsInputs_failedToUpdateProperties() {
when(groupOperation.updateGroupProperties(eq(resource), eq(GROUP_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.GENERAL_ERROR);
Either<List<InputDefinition>, StorageOperationStatus> declareResult = groupPropertyDeclarator.declarePropertiesAsInputs(resource, GROUP_ID, Collections.emptyList());
- assertThat(declareResult.right().value()).isEqualTo(StorageOperationStatus.GENERAL_ERROR);
+ assertEquals(StorageOperationStatus.GENERAL_ERROR, declareResult.right().value());
}
@Test
@@ -101,7 +103,7 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
when(groupOperation.updateGroupProperties(eq(resource), eq(GROUP_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.OK);
Either<List<InputDefinition>, StorageOperationStatus> createdInputs = groupPropertyDeclarator.declarePropertiesAsInputs(resource, GROUP_ID, propsToDeclare);
List<InputDefinition> inputs = createdInputs.left().value();
- assertThat(inputs).hasSize(2);
+ assertEquals(2, inputs.size());
verifyInputPropertiesList(inputs, updatedPropsCapture.getValue());
//creation of inputs values is part of the DefaultPropertyDeclarator and is tested in the ComponentInstancePropertyDeclaratorTest class
}
@@ -110,14 +112,14 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
public void testUnDeclareProperties_whenComponentHasNoGroups_returnOk() {
Resource resource = new Resource();
StorageOperationStatus storageOperationStatus = groupPropertyDeclarator.unDeclarePropertiesAsInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
verifyZeroInteractions(groupOperation);
}
@Test
public void testUnDeclareProperties_whenNoPropertiesFromGroupMatchInputId_returnOk() {
StorageOperationStatus storageOperationStatus = groupPropertyDeclarator.unDeclarePropertiesAsInputs(createResourceWithGroup(), input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
verifyZeroInteractions(groupOperation);
}
@@ -125,13 +127,13 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
public void whenFailingToUpdateDeclaredProperties_returnErrorStatus() {
Resource resource = createResourceWithGroups(GROUP_ID);
Optional<GroupDefinition> groupDefinition = resource.getGroupById(GROUP_ID);
- assertThat(groupDefinition.isPresent()).isTrue();
+ assertTrue(groupDefinition.isPresent());
PropertyDataDefinition getInputPropForInput = buildGetInputProperty(INPUT_ID);
groupDefinition.get().setProperties(Collections.singletonList(getInputPropForInput));
when(propertyOperation.findDefaultValueFromSecondPosition(Collections.emptyList(), getInputPropForInput.getUniqueId(), getInputPropForInput.getDefaultValue())).thenReturn(Either.left(getInputPropForInput.getDefaultValue()));
when(groupOperation.updateGroupProperties(eq(resource), eq(GROUP_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.GENERAL_ERROR);
StorageOperationStatus storageOperationStatus = groupPropertyDeclarator.unDeclarePropertiesAsInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.GENERAL_ERROR);
+ assertEquals(StorageOperationStatus.GENERAL_ERROR, storageOperationStatus);
}
@Test
@@ -146,28 +148,28 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
when(groupOperation.updateGroupProperties(eq(resource), eq(GROUP_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.OK);
StorageOperationStatus storageOperationStatus = groupPropertyDeclarator.unDeclarePropertiesAsInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
List<PropertyDataDefinition> updatedProperties = updatedPropsCapture.getValue();
- assertThat(updatedProperties).hasSize(1);
+ assertEquals(1, updatedProperties.size());
PropertyDataDefinition updatedProperty = updatedProperties.get(0);
- assertThat(updatedProperty.isGetInputProperty()).isFalse();
- assertThat(updatedProperty.getValue()).isEmpty();
- assertThat(updatedProperty.getDefaultValue()).isEqualTo(getInputPropForInput.getDefaultValue());
- assertThat(updatedProperty.getUniqueId()).isEqualTo(getInputPropForInput.getUniqueId());
+ assertFalse(updatedProperty.isGetInputProperty());
+ assertTrue(updatedProperty.getValue().isEmpty());
+ assertEquals(getInputPropForInput.getDefaultValue(), updatedProperty.getDefaultValue());
+ assertEquals(getInputPropForInput.getUniqueId(), updatedProperty.getUniqueId());
}
@Test
public void testUnDeclarePropertiesAsListInputs_whenComponentHasNoGroups_returnOk() {
Resource resource = new Resource();
StorageOperationStatus storageOperationStatus = groupPropertyDeclarator.unDeclarePropertiesAsListInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
verifyZeroInteractions(groupOperation);
}
@Test
public void testUnDeclarePropertiesAsListInputs_whenNoPropertiesFromGroupMatchInputId_returnOk() {
StorageOperationStatus storageOperationStatus = groupPropertyDeclarator.unDeclarePropertiesAsListInputs(createResourceWithGroup(), input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
verifyZeroInteractions(groupOperation);
}
@@ -175,13 +177,13 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
public void whenFailingToUpdateDeclaredPropertiesAsListInputs_returnErrorStatus() {
Resource resource = createResourceWithGroups(GROUP_ID);
Optional<GroupDefinition> groupDefinition = resource.getGroupById(GROUP_ID);
- assertThat(groupDefinition.isPresent()).isTrue();
+ assertTrue(groupDefinition.isPresent());
PropertyDataDefinition getInputPropForInput = buildGetInputProperty(INPUT_ID);
groupDefinition.get().setProperties(Collections.singletonList(getInputPropForInput));
when(propertyOperation.findDefaultValueFromSecondPosition(Collections.emptyList(), getInputPropForInput.getUniqueId(), getInputPropForInput.getDefaultValue())).thenReturn(Either.left(getInputPropForInput.getDefaultValue()));
when(groupOperation.updateGroupProperties(eq(resource), eq(GROUP_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.GENERAL_ERROR);
StorageOperationStatus storageOperationStatus = groupPropertyDeclarator.unDeclarePropertiesAsListInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.GENERAL_ERROR);
+ assertEquals(StorageOperationStatus.GENERAL_ERROR, storageOperationStatus);
}
@Test
@@ -196,14 +198,14 @@ public class GroupPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
when(groupOperation.updateGroupProperties(eq(resource), eq(GROUP_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.OK);
StorageOperationStatus storageOperationStatus = groupPropertyDeclarator.unDeclarePropertiesAsListInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
List<PropertyDataDefinition> updatedProperties = updatedPropsCapture.getValue();
- assertThat(updatedProperties).hasSize(1);
+ assertEquals(1, updatedProperties.size());
PropertyDataDefinition updatedProperty = updatedProperties.get(0);
- assertThat(updatedProperty.isGetInputProperty()).isFalse();
- assertThat(updatedProperty.getValue()).isEmpty();
- assertThat(updatedProperty.getDefaultValue()).isEqualTo(getInputPropForInput.getDefaultValue());
- assertThat(updatedProperty.getUniqueId()).isEqualTo(getInputPropForInput.getUniqueId());
+ assertFalse(updatedProperty.isGetInputProperty());
+ assertTrue(updatedProperty.getValue().isEmpty());
+ assertEquals(getInputPropForInput.getDefaultValue(), updatedProperty.getDefaultValue());
+ assertEquals(getInputPropForInput.getUniqueId(), updatedProperty.getUniqueId());
}
private Resource createResourceWithGroup() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeclaratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeclaratorTest.java
index 0cbc957a14..c0b176a571 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeclaratorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeclaratorTest.java
@@ -21,14 +21,14 @@
package org.openecomp.sdc.be.components.property;
import fj.data.Either;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.utils.PolicyDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
@@ -47,12 +47,12 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
//note that testing for most of the common logic is under the ComponentInstancePropertyDeclaratorTest
public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
@@ -69,7 +69,7 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
private InputDefinition input;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
resource = createResourceWithPolicy();
@@ -82,7 +82,7 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
@Test
public void testDeclarePropertiesAsInputs_policyNotExist() {
Either<List<InputDefinition>, StorageOperationStatus> declareResult = policyPropertyDeclarator.declarePropertiesAsInputs(resource, "nonExistingPolicy", Collections.emptyList());
- assertThat(declareResult.right().value()).isEqualTo(StorageOperationStatus.NOT_FOUND);
+ assertEquals(StorageOperationStatus.NOT_FOUND, declareResult.right().value());
verifyZeroInteractions(policyOperation);
}
@@ -90,7 +90,7 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
public void testDeclarePropertiesAsInputs_failedToUpdateProperties() {
when(policyOperation.updatePolicyProperties(eq(resource), eq(POLICY_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.GENERAL_ERROR);
Either<List<InputDefinition>, StorageOperationStatus> declareResult = policyPropertyDeclarator.declarePropertiesAsInputs(resource, POLICY_ID, Collections.emptyList());
- assertThat(declareResult.right().value()).isEqualTo(StorageOperationStatus.GENERAL_ERROR);
+ assertEquals(StorageOperationStatus.GENERAL_ERROR, declareResult.right().value());
}
@Test
@@ -100,7 +100,7 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
when(policyOperation.updatePolicyProperties(eq(resource), eq(POLICY_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.OK);
Either<List<InputDefinition>, StorageOperationStatus> createdInputs = policyPropertyDeclarator.declarePropertiesAsInputs(resource, POLICY_ID, propsToDeclare);
List<InputDefinition> inputs = createdInputs.left().value();
- assertThat(inputs).hasSize(2);
+ assertEquals(2, inputs.size());
verifyInputPropertiesList(inputs, updatedPropsCapture.getValue());
//creation of inputs values is part of the DefaultPropertyDeclarator and is tested in the ComponentInstancePropertyDeclaratorTest class
}
@@ -109,14 +109,14 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
public void testUnDeclareProperties_whenComponentHasNoPolicies_returnOk() {
Resource resource = new Resource();
StorageOperationStatus storageOperationStatus = policyPropertyDeclarator.unDeclarePropertiesAsInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
verifyZeroInteractions(policyOperation);
}
@Test
public void testUnDeclareProperties_whenNoPropertiesFromPolicyMatchInputId_returnOk() {
StorageOperationStatus storageOperationStatus = policyPropertyDeclarator.unDeclarePropertiesAsInputs(createResourceWithPolicy(), input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
verifyZeroInteractions(policyOperation);
}
@@ -129,7 +129,7 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
when(propertyOperation.findDefaultValueFromSecondPosition(Collections.emptyList(), getInputPropForInput.getUniqueId(), getInputPropForInput.getDefaultValue())).thenReturn(Either.left(getInputPropForInput.getDefaultValue()));
when(policyOperation.updatePolicyProperties(eq(resource), eq(POLICY_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.GENERAL_ERROR);
StorageOperationStatus storageOperationStatus = policyPropertyDeclarator.unDeclarePropertiesAsInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.GENERAL_ERROR);
+ assertEquals(StorageOperationStatus.GENERAL_ERROR, storageOperationStatus);
}
@Test
@@ -144,28 +144,28 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
when(policyOperation.updatePolicyProperties(eq(resource), eq(POLICY_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.OK);
StorageOperationStatus storageOperationStatus = policyPropertyDeclarator.unDeclarePropertiesAsInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
List<PropertyDataDefinition> updatedProperties = updatedPropsCapture.getValue();
- assertThat(updatedProperties).hasSize(1);
+ assertEquals(1, updatedProperties.size());
PropertyDataDefinition updatedProperty = updatedProperties.get(0);
- assertThat(updatedProperty.isGetInputProperty()).isFalse();
- assertThat(updatedProperty.getValue()).isEmpty();
- assertThat(updatedProperty.getDefaultValue()).isEqualTo(getInputPropForInput.getDefaultValue());
- assertThat(updatedProperty.getUniqueId()).isEqualTo(getInputPropForInput.getUniqueId());
+ assertFalse(updatedProperty.isGetInputProperty());
+ assertTrue(updatedProperty.getValue().isEmpty());
+ assertEquals(getInputPropForInput.getDefaultValue(), updatedProperty.getDefaultValue());
+ assertEquals(getInputPropForInput.getUniqueId(), updatedProperty.getUniqueId());
}
@Test
public void testUnDeclarePropertiesAsListInputs_whenComponentHasNoPolicies_returnOk() {
Resource resource = new Resource();
StorageOperationStatus storageOperationStatus = policyPropertyDeclarator.unDeclarePropertiesAsListInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
verifyZeroInteractions(policyOperation);
}
@Test
public void testUnDeclarePropertiesAsListInputs_whenNoPropertiesFromPolicyMatchInputId_returnOk() {
StorageOperationStatus storageOperationStatus = policyPropertyDeclarator.unDeclarePropertiesAsListInputs(createResourceWithPolicy(), input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
verifyZeroInteractions(policyOperation);
}
@@ -178,7 +178,7 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
when(propertyOperation.findDefaultValueFromSecondPosition(Collections.emptyList(), getInputPropForInput.getUniqueId(), getInputPropForInput.getDefaultValue())).thenReturn(Either.left(getInputPropForInput.getDefaultValue()));
when(policyOperation.updatePolicyProperties(eq(resource), eq(POLICY_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.GENERAL_ERROR);
StorageOperationStatus storageOperationStatus = policyPropertyDeclarator.unDeclarePropertiesAsListInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.GENERAL_ERROR);
+ assertEquals(StorageOperationStatus.GENERAL_ERROR, storageOperationStatus);
}
@Test
@@ -193,14 +193,14 @@ public class PolicyPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
when(policyOperation.updatePolicyProperties(eq(resource), eq(POLICY_ID), updatedPropsCapture.capture())).thenReturn(StorageOperationStatus.OK);
StorageOperationStatus storageOperationStatus = policyPropertyDeclarator.unDeclarePropertiesAsListInputs(resource, input);
- assertThat(storageOperationStatus).isEqualTo(StorageOperationStatus.OK);
+ assertEquals(StorageOperationStatus.OK, storageOperationStatus);
List<PropertyDataDefinition> updatedProperties = updatedPropsCapture.getValue();
- assertThat(updatedProperties).hasSize(1);
+ assertEquals(1, updatedProperties.size());
PropertyDataDefinition updatedProperty = updatedProperties.get(0);
- assertThat(updatedProperty.isGetInputProperty()).isFalse();
- assertThat(updatedProperty.getValue()).isEmpty();
- assertThat(updatedProperty.getDefaultValue()).isEqualTo(getInputPropForInput.getDefaultValue());
- assertThat(updatedProperty.getUniqueId()).isEqualTo(getInputPropForInput.getUniqueId());
+ assertFalse(updatedProperty.isGetInputProperty());
+ assertTrue(updatedProperty.getValue().isEmpty());
+ assertEquals(getInputPropForInput.getDefaultValue(), updatedProperty.getDefaultValue());
+ assertEquals(getInputPropForInput.getUniqueId(), updatedProperty.getUniqueId());
}
private Resource createResourceWithPolicy() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeclaratorTestBase.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeclaratorTestBase.java
index 88878438c0..d69e58f5f4 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeclaratorTestBase.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeclaratorTestBase.java
@@ -20,7 +20,7 @@
package org.openecomp.sdc.be.components.property;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
import org.openecomp.sdc.be.components.utils.ComponentInstanceBuilder;
import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
@@ -50,7 +50,7 @@ public class PropertyDeclaratorTestBase {
PropertyDataDefinition prop1, prop2, complexProperty;
Resource resource;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
prop1 = new PropertyDataDefinitionBuilder()
.setUniqueId("prop1")
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ConsumptionUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ConsumptionUtilsTest.java
index b78c013211..c240d0d479 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ConsumptionUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ConsumptionUtilsTest.java
@@ -18,13 +18,15 @@ package org.openecomp.sdc.be.components.utils;
import fj.data.Either;
-import org.junit.Assert;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.types.ServiceConsumptionData;
import org.openecomp.sdc.exception.ResponseFormat;
@@ -34,6 +36,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openecomp.sdc.be.components.property.CapabilityTestUtils.createCapabilityDefinition;
import static org.openecomp.sdc.be.components.property.CapabilityTestUtils.createProperties;
@@ -71,6 +75,20 @@ public class ConsumptionUtilsTest {
.handleConsumptionInputMappedToCapabilityProperty(operation, operationInputDefinition,
serviceConsumptionData, capabilityMap, "componentName");
- Assert.assertTrue(operationResponseFormatEither.isLeft());
+ assertTrue(operationResponseFormatEither.isLeft());
+ }
+
+ @Test
+ public void testIsAssignedValueFromValidType() {
+ assertTrue(ConsumptionUtils.isAssignedValueFromValidType("string", "testString"));
+ assertFalse(ConsumptionUtils.isAssignedValueFromValidType("string", true));
+
+ PropertyDefinition propertyDef = new PropertyDefinition();
+ propertyDef.setType("propertyType");
+ assertTrue(ConsumptionUtils.isAssignedValueFromValidType("PROPERTYTYPE", propertyDef));
+
+ OperationOutputDefinition opOutputDef = new OperationOutputDefinition();
+ opOutputDef.setType("opOutputDef");
+ assertTrue(ConsumptionUtils.isAssignedValueFromValidType("OPOUTPUTDEF", opOutputDef));
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
index b55f7d8514..b8f60fe5b7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
@@ -22,19 +22,17 @@ package org.openecomp.sdc.be.tosca;
import fj.data.Either;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundException;
import org.openecomp.sdc.be.components.utils.GroupDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.tosca.model.ToscaGroupTemplate;
import org.openecomp.sdc.be.tosca.model.ToscaTemplateCapability;
@@ -48,9 +46,11 @@ import java.util.stream.Stream;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class GroupExportParserImplTest {
private static final String GROUP_DEFINITION_NAME = "groupDefinitionName";
@@ -73,7 +73,7 @@ public class GroupExportParserImplTest {
@Mock
private PropertyConvertor propertyConvertor;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
initGroupExportParser();
}
@@ -98,6 +98,22 @@ public class GroupExportParserImplTest {
}
@Test
+ public void testGetToscaGroupTemplate() {
+ GroupInstance groupInstance = new GroupInstance();
+ groupInstance.setName("name");
+ groupInstance.setGroupUUID("groupUUID");
+ groupInstance.setInvariantUUID("invariantUUID");
+ groupInstance.setVersion("version");
+ groupInstance.setType("type");
+ groupInstance.setCustomizationUUID("customizationUUID");
+ ToscaGroupTemplate toscaGroupTemplate = groupExportParser.getToscaGroupTemplate(groupInstance, "invariantName");
+
+ assertEquals("type", toscaGroupTemplate.getType());
+ assertNotNull(toscaGroupTemplate);
+
+ }
+
+ @Test
public void oneGroupInComponent() {
when(component.getGroups()).thenReturn(genOneGroup());
Map<String, ToscaGroupTemplate> groups = groupExportParser.getGroups(component);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java
index 8f1923ec79..36c3fae376 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java
@@ -20,7 +20,9 @@
package org.openecomp.sdc.be.tosca.model;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ToscaMetadataTest {
@@ -29,7 +31,67 @@ public class ToscaMetadataTest {
return new ToscaMetadata();
}
-
+
+ @Test
+ public void testServiceFunction() {
+ ToscaMetadata testSubject = createTestSubject();
+ testSubject.setServiceFunction("testServiceFunction");
+ assertEquals("testServiceFunction", testSubject.getServiceFunction());
+ }
+
+ @Test
+ public void testInstantiationType() {
+ ToscaMetadata testSubject = createTestSubject();
+ testSubject.setInstantiationType("testInstantiationType");
+ assertEquals("testInstantiationType", testSubject.getInstantiationType());
+ }
+
+ @Test
+ public void testEcompGeneratedNaming() {
+ ToscaMetadata testSubject = createTestSubject();
+ testSubject.setEcompGeneratedNaming(null);
+ assertEquals(false, testSubject.isEcompGeneratedNaming());
+ testSubject.setEcompGeneratedNaming(true);
+ assertEquals(true, testSubject.isEcompGeneratedNaming());
+ }
+
+ @Test
+ public void testServiceEcompNaming() {
+ ToscaMetadata testSubject = createTestSubject();
+ testSubject.setServiceEcompNaming(null);
+ assertEquals(false, testSubject.getServiceEcompNaming());
+ testSubject.setServiceEcompNaming(false);
+ assertEquals(false, testSubject.getServiceEcompNaming());
+ }
+
+ @Test
+ public void testSourceModelInvariant() {
+ ToscaMetadata testSubject = createTestSubject();
+ testSubject.setSourceModelInvariant("sourceModelInvariant");
+ assertEquals("sourceModelInvariant", testSubject.getSourceModelInvariant());
+ }
+
+ @Test
+ public void testSourceModelName() {
+ ToscaMetadata testSubject = createTestSubject();
+ testSubject.setSourceModelName("sourceModelName");
+ assertEquals("sourceModelName", testSubject.getSourceModelName());
+ }
+
+ @Test
+ public void testSourceModelUuid() {
+ ToscaMetadata testSubject = createTestSubject();
+ testSubject.setSourceModelUuid("sourceModelUuid");
+ assertEquals("sourceModelUuid", testSubject.getSourceModelUuid());
+ }
+
+ @Test
+ public void testEnvironmentContext() {
+ ToscaMetadata testSubject = createTestSubject();
+ testSubject.setEnvironmentContext("environmentContext");
+ assertEquals("environmentContext", testSubject.getEnvironmentContext());
+ }
+
@Test
public void testGetName() throws Exception {
ToscaMetadata testSubject;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
index 43b52e2a54..949aa83c14 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
@@ -20,6 +20,10 @@
package org.openecomp.sdc.be.resources.data;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -27,6 +31,10 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import java.util.HashMap;
import java.util.Map;
+@Getter
+@Setter
+@EqualsAndHashCode
+@ToString
public class TagData extends GraphNode {
private String name;
@@ -56,49 +64,6 @@ public class TagData extends GraphNode {
return map;
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- return "Tag [Name=" + name + "]";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- TagData other = (TagData) obj;
- if (name == null) {
- if (other.getClass() != null) {
- return false;
- }
- } else if (!name.equals(other.getName())) {
- return false;
- }
- return true;
- }
-
@Override
public String getUniqueIdKey() {
return GraphPropertiesDictionary.NAME.getProperty();
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java
index 0cb045aaad..ea562b1f3e 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java
@@ -21,13 +21,17 @@
package org.openecomp.sdc.be.dao.utils;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.*;
import java.util.function.Function;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.openecomp.sdc.be.dao.utils.MapUtil.mergeMaps;
public class MapUtilTest {
@@ -64,14 +68,54 @@ public class MapUtilTest {
}
@Test
public void testGet() throws Exception {
- Map<String, ? extends Object> map = null;
+ Map<String, ? extends Object> mapWildcard = null;
String path = "";
Object result;
- // default test
- result = MapUtil.get(map, path);
- path = "\\mock\\mock";
- result = MapUtil.get(map, path);
+ result = MapUtil.get(mapWildcard, path);
+ assertNull(result);
+
+ path = "mock1.mock2";
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("mock1", "test");
+ mapWildcard = map;
+ result = MapUtil.get(mapWildcard, path);
+ assertNull(result);
+
+ Map<String, Integer> subMap = new HashMap<>();
+ subMap.put("mock2", 1);
+ Map<String, ? extends Object> subMapWildcard = subMap;
+ map.put("mock1", subMapWildcard);
+ mapWildcard = map;
+ result = MapUtil.get(mapWildcard, path);
+ assertEquals(1, result);
+ }
+
+ @Test
+ public void testFlattenMapValues() throws Exception {
+ assertNotNull(MapUtil.flattenMapValues(null));
+
+ Map<String, List<String>> map = new HashMap<>();
+ List<String> list1 = new LinkedList<>();
+ list1.add("test1");
+ List<String> list2 = new LinkedList<>();
+ list2.add("test2");
+ map.put("key1", list1);
+ map.put("key2", list2);
+ List<String> result = MapUtil.flattenMapValues(map);
+ assertEquals(2, result.size());
+ assertEquals("test1", result.get(0));
+ assertEquals("test2", result.get(1));
+ }
+
+ @Test
+ public void testStreamOfNullable() throws Exception {
+ assertEquals(0, MapUtil.streamOfNullable(null).count());
+
+ Collection collectionTest = new LinkedList<String>();
+ collectionTest.add("test");
+ assertEquals(1, MapUtil.streamOfNullable(collectionTest).count());
}
@Test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java
index 21a728053c..09e751580f 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java
@@ -37,12 +37,16 @@ import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.openecomp.sdc.be.utils.FixtureHelpers.fixture;
import static org.openecomp.sdc.be.utils.JsonTester.testJsonMap;
public class JsonParserUtilsTests {
private static final String FIXTURE_PATH = "fixtures/ListCapabilityDataDefinition.json";
+ private static final String FIXTURE_PATH2 = "fixtures/ListCapabilityDataDefinition2.json";
@Test
public void testToMap() {
@@ -54,6 +58,19 @@ public class JsonParserUtilsTests {
}
@Test
+ public void testToList() {
+ assertNull(JsonParserUtils.toList(null, ListCapabilityDataDefinition.class));
+ String json = fixture(FIXTURE_PATH2);
+ List<ListCapabilityDataDefinition> actual = JsonParserUtils.toList(json,
+ ListCapabilityDataDefinition.class);
+ assertEquals(1, actual.size());
+ CapabilityDataDefinition expectedDef = buildListCapabilityDataDefinition().getListToscaDataDefinition().get(0);
+ CapabilityDataDefinition actualDef = actual.get(0).getListToscaDataDefinition().get(0);
+ assertEquals(1, actual.get(0).getListToscaDataDefinition().size());
+ assertEquals(expectedDef, actualDef);
+ }
+
+ @Test
public void testJacksonFasterXml() {
ObjectMapper mapper = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java
index c1729d0f3d..919b7c7663 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java
@@ -20,13 +20,15 @@
package org.openecomp.sdc.be.resources.data;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import java.util.HashMap;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
public class TagDataTest {
private TagData createTestSubject() {
@@ -90,6 +92,7 @@ public class TagDataTest {
result = testSubject.hashCode();
}
+
@Test
public void testEquals() throws Exception {
TagData testSubject;
@@ -100,7 +103,7 @@ public class TagDataTest {
testSubject = createTestSubject();
obj = null;
result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
+ assertEquals(false, result);
}
@Test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java
index f0557aaee5..7a94b4da27 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java
@@ -20,7 +20,14 @@
package org.openecomp.sdc.be.resources.data.auditing;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class AuditingGenericEventTest {
@@ -29,6 +36,21 @@ public class AuditingGenericEventTest {
}
@Test
+ public void testTimestamp() throws Exception {
+ AuditingGenericEvent testSubject = createTestSubject();
+ testSubject.setTimestamp("timestamp");
+ assertEquals("timestamp", testSubject.getTimestamp());
+ }
+
+ @Test
+ public void testFields() throws Exception {
+ AuditingGenericEvent testSubject = createTestSubject();
+ Map<String, Object> map = new HashMap<>();
+ testSubject.setFields(map);
+ assertNotNull(testSubject.getFields());
+ }
+
+ @Test
public void testGetRequestId() throws Exception {
AuditingGenericEvent testSubject;
String result;
diff --git a/catalog-dao/src/test/resources/fixtures/ListCapabilityDataDefinition2.json b/catalog-dao/src/test/resources/fixtures/ListCapabilityDataDefinition2.json
new file mode 100644
index 0000000000..81485110d0
--- /dev/null
+++ b/catalog-dao/src/test/resources/fixtures/ListCapabilityDataDefinition2.json
@@ -0,0 +1,17 @@
+[[
+ {
+ "name": "forwarder",
+ "type": "org.openecomp.capabilities.Forwarder",
+ "uniqueId": "capability.deb142fd-95eb-48f7-99ae-81ab09466b1e.forwarder",
+ "ownerId": "deb142fd-95eb-48f7-99ae-81ab09466b1e",
+ "capabilitySources": [
+ "org.openecomp.resource.cp.nodes.network.Port",
+ "org.openecomp.resource.cp.v2.extCP",
+ "org.openecomp.resource.cp.v2.extContrailCP"
+ ],
+ "minOccurrences": "1",
+ "leftOccurrences": "UNBOUNDED",
+ "maxOccurrences": "UNBOUNDED",
+ "empty": false
+ }
+]]
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatusTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatusTest.java
index 3e18f65949..d4397985da 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatusTest.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatusTest.java
@@ -20,14 +20,22 @@
package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class MonitoringUploadStatusTest {
@Test
public void shouldHaveValidGettersAndSetters() {
assertThat(MonitoringUploadStatus.class, hasValidGettersAndSetters());
}
+
+ @Test
+ public void constructorTest() {
+ MonitoringUploadStatus status = new MonitoringUploadStatus("test1", "test2");
+ assertEquals("test1", status.getSnmpTrap());
+ assertEquals("test2", status.getSnmpPoll());
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/test/java/org/openecomp/types/AsdcElementTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/test/java/org/openecomp/types/AsdcElementTest.java
index 3197767379..74ec1a6859 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/test/java/org/openecomp/types/AsdcElementTest.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/test/java/org/openecomp/types/AsdcElementTest.java
@@ -19,10 +19,25 @@
*/
package org.openecomp.types;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
-import static org.junit.Assert.assertThat;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.HashMap;
-import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class AsdcElementTest {
@Test
@@ -30,4 +45,49 @@ public class AsdcElementTest {
assertThat(AsdcElement.class,
hasValidGettersAndSettersExcluding("data", "info", "searchableData", "visualization"));
}
+
+ @Test
+ public void getInfoTest() {
+ AsdcElement element = new AsdcElement();
+ element.setName("name");
+ element.setType("type");
+ element.setProperties(new HashMap<>());
+ element.setDescription("desc");
+
+ Info actualInfo = element.getInfo();
+ assertEquals("name", actualInfo.getName());
+ assertEquals(1, actualInfo.getProperties().size());
+ assertEquals("type", actualInfo.getProperty("elementType"));
+ assertEquals("desc", actualInfo.getDescription());
+ }
+
+ @Test
+ public void getSearchableDataTest() {
+ AsdcElement element = new AsdcElement();
+ assertNull(element.getSearchableData());
+ }
+
+ @Test
+ public void getVisualizationTest() {
+ AsdcElement element = new AsdcElement();
+ assertNull(element.getVisualization());
+ }
+
+ @Test
+ public void dataTest() throws IOException {
+ AsdcElement element = new AsdcElement();
+ InputStream inputStream = new ByteArrayInputStream( "testString".getBytes(StandardCharsets.UTF_8) );
+ element.setData(inputStream);
+
+ assertEquals("testString", IOUtils.toString(element.getData(), StandardCharsets.UTF_8));
+ }
+
+ @Test
+ public void addSubElementTest() throws IOException {
+ AsdcElement element = new AsdcElement();
+ assertEquals(0, element.getSubElements().size());
+
+ element.addSubElement(new AsdcElement());
+ assertEquals(1, element.getSubElements().size());
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypesTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypesTest.java
new file mode 100644
index 0000000000..1298681b70
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypesTest.java
@@ -0,0 +1,64 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 AT&T Intellectual Property. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.heat.datatypes.model;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.junit.jupiter.api.Test;
+import java.util.List;
+import java.util.Map;
+
+public class HeatResourcesTypesTest {
+
+ @Test
+ public void findByHeatResourceTest() {
+ assertEquals(HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE,
+ HeatResourcesTypes.findByHeatResource("OS::Nova::ServerGroup"));
+ }
+
+ @Test
+ public void isResourceExpectedToBeExposedTest() {
+ assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Nova::ServerGroup"));
+ assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Contrail::VirtualNetwork"));
+ assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Neutron::Net"));
+ assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Cinder::Volume"));
+ assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Neutron::SecurityGroup"));
+ assertEquals(false, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Nova::Server"));
+ }
+
+ @Test
+ public void isResourceTypeValidTest() {
+ assertEquals(true, HeatResourcesTypes.isResourceTypeValid("OS::Neutron::SecurityGroup"));
+ assertEquals(false, HeatResourcesTypes.isResourceTypeValid("OS::Neutron::test"));
+ }
+
+ @Test
+ public void getListForResourceTypeTest() {
+ Map<HeatResourcesTypes, List<String>> res = HeatResourcesTypes.getListForResourceType(
+ HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE, HeatResourcesTypes.HEAT_CLOUD_CONFIG_TYPE);
+
+ assertNotNull(res.get(HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE));
+ assertNotNull(res.get(HeatResourcesTypes.HEAT_CLOUD_CONFIG_TYPE));
+ assertNull(res.get(HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestinationTest.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestinationTest.java
index b739f32513..78265769e5 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestinationTest.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestinationTest.java
@@ -20,10 +20,10 @@
package org.openecomp.sdc.destinationprovider.impl;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.notification.services.SubscriptionService;
import java.util.Arrays;
@@ -31,7 +31,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
@@ -39,6 +42,7 @@ import static org.mockito.Mockito.doReturn;
* @author avrahamg
* @since July 13, 2017
*/
+@ExtendWith(MockitoExtension.class)
public class MulticastDestinationTest {
@Mock
private SubscriptionService subscriptionServiceMock;
@@ -47,10 +51,6 @@ public class MulticastDestinationTest {
private Set<String> subscribers = new HashSet<>(Arrays.asList("a", "b", excludedSubscriber));
private MulticastDestination multicastDestination;
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
@Test
public void shouldReturnAllSubscribersIfNoExcludedProvided() throws Exception {
@@ -72,13 +72,11 @@ public class MulticastDestinationTest {
assertFalse(actualSubscribers.contains(excludedSubscriber));
}
- @Test(expected = UnsupportedOperationException.class)
- public void shouldThrowUnsupportedOperationExceptionWhenTryingToChangeSubscribersList() throws
- Exception {
- doReturn(subscribers).when(subscriptionServiceMock).getSubscribers(any());
+ @Test
+ public void entityIdTest() {
multicastDestination =
- new MulticastDestination("aa", subscriptionServiceMock, excludedSubscriber);
- List<String> actualSubscribers = multicastDestination.getSubscribers();
- actualSubscribers.add("sss");
+ new MulticastDestination("aa", subscriptionServiceMock, excludedSubscriber);
+ multicastDestination.setEntityId("entityId");
+ assertEquals("entityId", multicastDestination.getEntityId());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/test/java/org/openecomp/core/validation/types/GlobalValidationContextTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/test/java/org/openecomp/core/validation/types/GlobalValidationContextTest.java
index 8f17f0f357..3541465736 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/test/java/org/openecomp/core/validation/types/GlobalValidationContextTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/test/java/org/openecomp/core/validation/types/GlobalValidationContextTest.java
@@ -18,12 +18,13 @@ package org.openecomp.core.validation.types;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.junit.Assert;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -31,6 +32,10 @@ import java.util.List;
import java.util.Map;
import java.util.function.BiPredicate;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class GlobalValidationContextTest {
private static String filename = "testName";
private static String yaml1 = "one.yaml";
@@ -45,7 +50,7 @@ public class GlobalValidationContextTest {
ErrorMessageCode error = new ErrorMessageCode("Error");
globalValidationContext.setMessageCode(error);
- Assert.assertEquals(error, globalValidationContext.getMessageCode());
+ assertEquals(error, globalValidationContext.getMessageCode());
}
@Test
@@ -54,8 +59,8 @@ public class GlobalValidationContextTest {
globalValidationContext.addFileContext(filename, content.getBytes());
Map<String, FileValidationContext> fileContextMap = globalValidationContext.getFileContextMap();
- Assert.assertTrue(MapUtils.isNotEmpty(fileContextMap));
- Assert.assertTrue(fileContextMap.containsKey(filename));
+ assertTrue(MapUtils.isNotEmpty(fileContextMap));
+ assertTrue(fileContextMap.containsKey(filename));
}
@Test
@@ -82,6 +87,18 @@ public class GlobalValidationContextTest {
}
@Test
+ public void testGetFileContent() {
+ GlobalValidationContext globalValidationContext = new GlobalValidationContext();
+
+ assertTrue(globalValidationContext.getFileContent(yaml1).isEmpty());
+
+ byte[] bytes = content.getBytes();
+ globalValidationContext.addFileContext(yaml1, bytes);
+
+ assertTrue(globalValidationContext.getFileContent(yaml1).get() instanceof InputStream);
+ }
+
+ @Test
public void testGetFiles() {
GlobalValidationContext globalValidationContext = new GlobalValidationContext();
byte[] bytes = content.getBytes();
@@ -94,7 +111,7 @@ public class GlobalValidationContextTest {
testGetFilesByFileType((fileName, globalContext) -> fileName.endsWith(".txt"),
1, Collections.singletonList(text1), globalValidationContext);
-
+ assertEquals(3, globalValidationContext.getFiles().size());
}
private void testGetFilesByFileType(BiPredicate<String, GlobalValidationContext> func,
@@ -102,23 +119,23 @@ public class GlobalValidationContextTest {
List<String> expectedFileNames,
GlobalValidationContext globalValidationContext) {
Collection<String> files = globalValidationContext.files(func);
- Assert.assertTrue(CollectionUtils.isNotEmpty(files));
- Assert.assertEquals(files.size(), expectedFilesNumberToFind);
- expectedFileNames.forEach(filename -> Assert.assertTrue(files.contains(filename)));
+ assertTrue(CollectionUtils.isNotEmpty(files));
+ assertEquals(files.size(), expectedFilesNumberToFind);
+ expectedFileNames.forEach(filename -> assertTrue(files.contains(filename)));
}
private void testIfFileHasMessageContainer(Map<String, MessageContainer> messageContainers) {
- Assert.assertNotNull(messageContainers);
- Assert.assertTrue(messageContainers.containsKey(filename));
+ assertNotNull(messageContainers);
+ assertTrue(messageContainers.containsKey(filename));
}
private void testIfFileHasErrorMessage(Map<String, MessageContainer> messageContainers,
int expectedErrorsNumber) {
MessageContainer messageContainer = messageContainers.get(filename);
- Assert.assertEquals(messageContainer.getErrorMessageList().size(), expectedErrorsNumber);
+ assertEquals(messageContainer.getErrorMessageList().size(), expectedErrorsNumber);
ErrorMessage errorMessage =
new ErrorMessage(ErrorLevel.ERROR, ErrorLevel.ERROR.toString() + ": " + message);
- Assert.assertTrue(messageContainer.getErrorMessageList().contains(errorMessage));
+ assertTrue(messageContainer.getErrorMessageList().contains(errorMessage));
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertorTest.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertorTest.java
index 49624a5c55..d1be5ed9a8 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertorTest.java
@@ -17,6 +17,7 @@ package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
@@ -36,7 +37,9 @@ public class ElementToFeatureGroupConvertorTest {
@Test
public void shouldConvertElementToFeatureGroupEntity() {
- ZusammenElement elementToConvert = new ZusammenElement();
+ ZusammenElement elementToConvert = null;
+ assertNull(converter.convert(elementToConvert));
+ elementToConvert = new ZusammenElement();
elementToConvert.setElementId(new Id(ENTITY_ID));
elementToConvert.setInfo(createInfo());
FeatureGroupEntity result = converter.convert(elementToConvert);
@@ -47,7 +50,9 @@ public class ElementToFeatureGroupConvertorTest {
@Test
public void shouldConvertElementInfoToFeatureGroupEntity(){
- ElementInfo elementToConvert = new ElementInfo();
+ ElementInfo elementToConvert = null;
+ assertNull(converter.convert(elementToConvert));
+ elementToConvert = new ElementInfo();
elementToConvert.setId(new Id(ENTITY_ID));
elementToConvert.setInfo(createInfo());
FeatureGroupEntity result = converter.convert(elementToConvert);