diff options
author | 2018-05-13 22:29:24 +0300 | |
---|---|---|
committer | 2018-05-13 20:48:31 +0000 | |
commit | 2924a3dbb7e0f50b239287fb11f6ec8c2235522a (patch) | |
tree | 09d3ff88fce749f2b0665a047afcefd9ab2ce167 /catalog-be/src/test/java/org/openecomp | |
parent | 12368941ba74929ab71a6baab04e1692c256af74 (diff) |
Raise JUnit coverage common-be
Change-Id: If7b31082105378901e9a09e26a8cc1b5737eb425
Issue-ID: SDC-1298
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp')
194 files changed, 4582 insertions, 1475 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java index 2088e8071a..d87f01d1fb 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java @@ -20,7 +20,10 @@ package org.openecomp.sdc; -import fj.data.Either; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; @@ -35,9 +38,7 @@ import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.CategoryData; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import fj.data.Either; public class ElementOperationMock implements IElementOperation { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ErrorConfigurationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/ErrorConfigurationTest.java index 7f5b7f9853..9b8237c8fb 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ErrorConfigurationTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ErrorConfigurationTest.java @@ -20,6 +20,10 @@ package org.openecomp.sdc; +import static org.junit.Assert.assertTrue; + +import java.io.File; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.config.ErrorConfiguration; @@ -33,10 +37,6 @@ import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; - -import static org.junit.Assert.assertTrue; - public class ErrorConfigurationTest { ConfigurationSource configurationSource = null; private static final Logger log = LoggerFactory.getLogger(ErrorConfigurationTest.class); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/TestExternalConfiguration.java b/catalog-be/src/test/java/org/openecomp/sdc/TestExternalConfiguration.java index 4698c0eea9..b6b0069c65 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/TestExternalConfiguration.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/TestExternalConfiguration.java @@ -20,6 +20,8 @@ package org.openecomp.sdc; +import java.io.IOException; + import org.openecomp.sdc.be.config.Configuration; import org.openecomp.sdc.common.api.BasicConfiguration; import org.openecomp.sdc.common.api.ConfigurationListener; @@ -29,8 +31,6 @@ import org.openecomp.sdc.common.impl.ConfigFileChangeListener; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import java.io.IOException; - public class TestExternalConfiguration<T extends Object> { public static void main(String[] args) throws IOException { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java b/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java index 9ee123a840..0b95bae9b5 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java @@ -20,9 +20,6 @@ package org.openecomp.sdc; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.output.ByteArrayOutputStream; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.file.Files; @@ -33,6 +30,9 @@ import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.output.ByteArrayOutputStream; + public class ZipUtil { public static void main(String[] args) { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/DummyConfigurationManager.java b/catalog-be/src/test/java/org/openecomp/sdc/be/DummyConfigurationManager.java index 84c6fc118d..a6c8dc4f0c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/DummyConfigurationManager.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/DummyConfigurationManager.java @@ -1,13 +1,13 @@ package org.openecomp.sdc.be; +import static org.mockito.Mockito.mock; + import org.openecomp.sdc.be.config.Configuration; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.config.DistributionEngineConfiguration; import org.openecomp.sdc.common.api.ConfigurationListener; import org.openecomp.sdc.common.api.ConfigurationSource; -import static org.mockito.Mockito.mock; - public class DummyConfigurationManager { private DistributionEngineConfiguration distributionConfigurationMock = mock(DistributionEngineConfiguration.class); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditAuthRequestEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditAuthRequestEventFactoryTest.java new file mode 100644 index 0000000000..db70cfd7eb --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditAuthRequestEventFactoryTest.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.be.auditing.impl; + +import org.junit.Test; +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 AuditAuthRequestEventFactoryTest { + + private AuditAuthRequestEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditAuthRequestEventFactory(build, "mock", "mock", "mock", "mock"); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditAuthRequestEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditAuthRequestEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactoryTest.java index 9bdf784f1c..e59ae40d80 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactoryTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactoryTest.java @@ -1,9 +1,5 @@ package org.openecomp.sdc.be.auditing.impl; -import org.junit.Test; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.common.api.Constants; - import static org.junit.Assert.assertEquals; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.DESIGNER_USER_ROLE; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_EMAIL; @@ -13,6 +9,10 @@ import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_ID; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_LAST_NAME; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_UID; +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.common.api.Constants; + public class AuditBaseEventFactoryTest { private User user = new User(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFactoryTest.java new file mode 100644 index 0000000000..b550aea646 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFactoryTest.java @@ -0,0 +1,54 @@ +package org.openecomp.sdc.be.auditing.impl; + +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdc.be.model.ConsumerDefinition; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +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; + +import mockit.Deencapsulation; + +public class AuditConsumerEventFactoryTest { + + private AuditConsumerEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditConsumerEventFactory(AuditingActionEnum.ACTIVATE_SERVICE_BY_API, build, new User(), + new ConsumerDefinition()); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditConsumerEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditConsumerEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testBuildConsumerName() throws Exception { + ConsumerDefinition consumer = null; + String result; + + // test 1 + consumer = null; + result = Deencapsulation.invoke(AuditConsumerEventFactory.class, "buildConsumerName", + new Object[] { ConsumerDefinition.class }); + Assert.assertEquals("", result); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java index 0a90ffd915..bf3c7c4e2a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java @@ -1,28 +1,5 @@ package org.openecomp.sdc.be.auditing.impl; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.openecomp.sdc.be.auditing.api.AuditEventFactory; -import org.openecomp.sdc.be.config.Configuration; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; -import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; -import org.openecomp.sdc.be.dao.impl.AuditingDao; -import org.openecomp.sdc.be.model.ConsumerDefinition; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; -import org.openecomp.sdc.be.resources.data.auditing.ConsumerEvent; -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import org.openecomp.sdc.common.util.ThreadLocalsHolder; - -import java.util.EnumMap; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; @@ -44,6 +21,29 @@ import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_ID; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.modifier; +import java.util.EnumMap; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.auditing.api.AuditEventFactory; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; +import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.impl.AuditingDao; +import org.openecomp.sdc.be.model.ConsumerDefinition; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; +import org.openecomp.sdc.be.resources.data.auditing.ConsumerEvent; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; + @RunWith(MockitoJUnitRunner.class) public class AuditConsumerEventFuncTest { private AuditingManager auditingManager; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditEcompOpEnvEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditEcompOpEnvEventFactoryTest.java new file mode 100644 index 0000000000..b181bbf448 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditEcompOpEnvEventFactoryTest.java @@ -0,0 +1,32 @@ +package org.openecomp.sdc.be.auditing.impl; + +import org.junit.Test; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; + +public class AuditEcompOpEnvEventFactoryTest { + + private AuditEcompOpEnvEventFactory createTestSubject() { + return new AuditEcompOpEnvEventFactory(AuditingActionEnum.ACTIVATE_SERVICE_BY_API, "", "", "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditEcompOpEnvEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditEcompOpEnvEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryManangerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryManangerTest.java new file mode 100644 index 0000000000..bad63c7e01 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryManangerTest.java @@ -0,0 +1,42 @@ +package org.openecomp.sdc.be.auditing.impl; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditResourceEventFactoryManangerTest { + + private AuditResourceEventFactoryMananger createTestSubject() { + return new AuditResourceEventFactoryMananger(); + } + + @Test + public void testCreateResourceEventFactory() throws Exception { + AuditingActionEnum action = null; + CommonAuditData commonFields = null; + ResourceAuditData prevParams = null; + ResourceAuditData currParams = null; + String resourceType = ""; + String resourceName = ""; + String invariantUuid = ""; + User modifier = null; + String artifactData = ""; + String comment = ""; + String did = ""; + String toscaNodeType = ""; + AuditBaseEventFactory result; + + for (AuditingActionEnum iterable_element : AuditingActionEnum.values()) { + try { + result = AuditResourceEventFactoryMananger.createResourceEventFactory(iterable_element, commonFields, prevParams, + currParams, resourceType, resourceName, invariantUuid, modifier, artifactData, comment, did, + toscaNodeType); + } catch (Exception UnsupportedOperationException) { + continue; + } + } + // default test + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingLogFormatUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingLogFormatUtilTest.java new file mode 100644 index 0000000000..37f810699b --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingLogFormatUtilTest.java @@ -0,0 +1,96 @@ +package org.openecomp.sdc.be.auditing.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; + +import mockit.Deencapsulation; + +public class AuditingLogFormatUtilTest { + + private AuditingLogFormatUtil createTestSubject() { + return new AuditingLogFormatUtil(); + } + + @Test + public void testGetModifier() throws Exception { + String modifierName = "mock"; + String modifierUid = "mock"; + String result; + + // test 0 + result = Deencapsulation.invoke(AuditingLogFormatUtil.class, "getModifier", + new Object[] { modifierName, modifierUid }); + Assert.assertEquals("mock(mock)", result); + + // test 1 + result = Deencapsulation.invoke(AuditingLogFormatUtil.class, "getModifier", + new Object[] { modifierName, String.class }); + Assert.assertEquals("", result); + + // test 2 + modifierUid = ""; + result = Deencapsulation.invoke(AuditingLogFormatUtil.class, "getModifier", + new Object[] { modifierName, modifierUid }); + Assert.assertEquals("", result); + + // test 3 + result = Deencapsulation.invoke(AuditingLogFormatUtil.class, "getModifier", + new Object[] { String.class, modifierUid }); + Assert.assertEquals("", result); + + // test 4 + modifierName = ""; + result = Deencapsulation.invoke(AuditingLogFormatUtil.class, "getModifier", + new Object[] { modifierName, modifierUid }); + Assert.assertEquals("", result); + } + + @Test + public void testGetUser() throws Exception { + String userData = ""; + String result; + + // default test + result = Deencapsulation.invoke(AuditingLogFormatUtil.class, "getUser", new Object[] { userData }); + } + + @Test + public void testLogAuditEvent() throws Exception { + Map<AuditingFieldsKeysEnum, Object> auditingFields = null; + String result; + + // default test + HashMap<AuditingFieldsKeysEnum, Object> hashMap = new HashMap<AuditingFieldsKeysEnum, Object>(); + result = Deencapsulation.invoke(AuditingLogFormatUtil.class, "logAuditEvent", + new Object[] { hashMap.getClass() }); + } + + @Test + public void testLogAuditEvent_1() throws Exception { + String formattedString = ""; + Map<AuditingFieldsKeysEnum, Object> auditingFields = new HashMap<>(); + + // default test + Deencapsulation.invoke(AuditingLogFormatUtil.class, "logAuditEvent", new Object[] { formattedString }); + + auditingFields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_NAME, "mock"); + Deencapsulation.invoke(AuditingLogFormatUtil.class, "logAuditEvent", auditingFields); + + for ( AuditingFieldsKeysEnum enumValue : AuditingFieldsKeysEnum.values()) { + auditingFields.put(enumValue, "mock"); + } + + Deencapsulation.invoke(AuditingLogFormatUtil.class, "logAuditEvent", auditingFields); + + auditingFields = new HashMap<>(); + for (AuditingActionEnum iterable_element : AuditingActionEnum.values()) { + auditingFields.put(AuditingFieldsKeysEnum.AUDIT_ACTION, iterable_element.getName()); + Deencapsulation.invoke(AuditingLogFormatUtil.class, "logAuditEvent", auditingFields); + } + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java index a774dea352..e41e34bb35 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java @@ -1,5 +1,26 @@ package org.openecomp.sdc.be.auditing.impl.category; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.CATEGORY; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.DESCRIPTION; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_ADD_CATEGORY_LOG_STR; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.GROUPING_NAME; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.MODIFIER_UID; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.REQUEST_ID; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.RESOURCE_TYPE; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.SERVICE_INSTANCE_ID; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.STATUS_OK; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.SUB_CATEGORY; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.modifier; + +import java.util.EnumMap; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,27 +42,6 @@ import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.openecomp.sdc.common.util.ThreadLocalsHolder; -import java.util.EnumMap; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.CATEGORY; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.DESCRIPTION; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_ADD_CATEGORY_LOG_STR; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.GROUPING_NAME; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.MODIFIER_UID; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.REQUEST_ID; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.RESOURCE_TYPE; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.SERVICE_INSTANCE_ID; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.STATUS_OK; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.SUB_CATEGORY; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.modifier; - @RunWith(MockitoJUnitRunner.class) public class AuditCategoryEventFuncTest { private AuditingManager auditingManager; 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 new file mode 100644 index 0000000000..f5f6dde66a --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventFactoryTest.java @@ -0,0 +1,38 @@ +package org.openecomp.sdc.be.auditing.impl.category; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +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 { + + private AuditGetCategoryHierarchyEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditGetCategoryHierarchyEventFactory(AuditingActionEnum.ACTIVATE_SERVICE_BY_API, build, + new User(), ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditGetCategoryHierarchyEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditGetCategoryHierarchyEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditCreateTopicDistribEngineEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditCreateTopicDistribEngineEventFactoryTest.java new file mode 100644 index 0000000000..c50ea24fb4 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditCreateTopicDistribEngineEventFactoryTest.java @@ -0,0 +1,24 @@ +package org.openecomp.sdc.be.auditing.impl.distribution; + +import org.junit.Test; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder; + +public class AuditCreateTopicDistribEngineEventFactoryTest { + + private AuditCreateTopicDistribEngineEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditCreateTopicDistribEngineEventFactory(build, "", "", "", "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditCreateTopicDistribEngineEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistrEngineFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistrEngineFuncTest.java index 199597b82c..29285e7aa0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistrEngineFuncTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistrEngineFuncTest.java @@ -1,28 +1,5 @@ package org.openecomp.sdc.be.auditing.impl.distribution; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.openecomp.sdc.be.auditing.api.AuditEventFactory; -import org.openecomp.sdc.be.auditing.impl.AuditingManager; -import org.openecomp.sdc.be.config.Configuration; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; -import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; -import org.openecomp.sdc.be.dao.impl.AuditingDao; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; -import org.openecomp.sdc.be.resources.data.auditing.DistributionEngineEvent; -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import org.openecomp.sdc.common.util.ThreadLocalsHolder; - -import java.util.EnumMap; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyMap; @@ -44,6 +21,29 @@ import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.SERVICE_INSTANCE import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.STATUS_OK; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; +import java.util.EnumMap; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.auditing.api.AuditEventFactory; +import org.openecomp.sdc.be.auditing.impl.AuditingManager; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; +import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.impl.AuditingDao; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionEngineEvent; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; + @RunWith(MockitoJUnitRunner.class) public class AuditDistrEngineFuncTest { private AuditingManager auditingManager; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistrEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistrEventFuncTest.java index 09a168a132..ceb25e44b7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistrEventFuncTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistrEventFuncTest.java @@ -1,34 +1,5 @@ package org.openecomp.sdc.be.auditing.impl.distribution; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.openecomp.sdc.be.auditing.api.AuditEventFactory; -import org.openecomp.sdc.be.auditing.impl.AuditingManager; -import org.openecomp.sdc.be.config.Configuration; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; -import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; -import org.openecomp.sdc.be.dao.impl.AuditingDao; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; -import org.openecomp.sdc.be.resources.data.auditing.AuditingGetUebClusterEvent; -import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent; -import org.openecomp.sdc.be.resources.data.auditing.DistributionDownloadEvent; -import org.openecomp.sdc.be.resources.data.auditing.DistributionNotificationEvent; -import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent; -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; -import org.openecomp.sdc.be.resources.data.auditing.model.OperationalEnvAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import org.openecomp.sdc.common.util.ThreadLocalsHolder; - -import java.util.EnumMap; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyMap; @@ -63,6 +34,35 @@ import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.VNF_WORKLOAD_CON import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.user; +import java.util.EnumMap; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.auditing.api.AuditEventFactory; +import org.openecomp.sdc.be.auditing.impl.AuditingManager; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; +import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.impl.AuditingDao; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGetUebClusterEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionDownloadEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionNotificationEvent; +import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; +import org.openecomp.sdc.be.resources.data.auditing.model.OperationalEnvAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; + @RunWith(MockitoJUnitRunner.class) public class AuditDistrEventFuncTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribDeployEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribDeployEventFactoryTest.java new file mode 100644 index 0000000000..6a314da699 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribDeployEventFactoryTest.java @@ -0,0 +1,36 @@ +package org.openecomp.sdc.be.auditing.impl.distribution; + +import org.junit.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 AuditDistribDeployEventFactoryTest { + + private AuditDistribDeployEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditDistribDeployEventFactory(build, "", "", new User(), "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditDistribDeployEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditDistribDeployEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribDownloadEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribDownloadEventFactoryTest.java new file mode 100644 index 0000000000..3aaeb6fddd --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribDownloadEventFactoryTest.java @@ -0,0 +1,36 @@ +package org.openecomp.sdc.be.auditing.impl.distribution; + +import org.junit.Test; +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; +import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; + +public class AuditDistribDownloadEventFactoryTest { + + private AuditDistribDownloadEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditDistribDownloadEventFactory(build, new DistributionData("", "")); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditDistribDownloadEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditDistribDownloadEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribNotificationEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribNotificationEventFactoryTest.java new file mode 100644 index 0000000000..06b45a4736 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribNotificationEventFactoryTest.java @@ -0,0 +1,38 @@ +package org.openecomp.sdc.be.auditing.impl.distribution; + +import org.junit.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; +import org.openecomp.sdc.be.resources.data.auditing.model.OperationalEnvAuditData; + +public class AuditDistribNotificationEventFactoryTest { + + private AuditDistribNotificationEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditDistribNotificationEventFactory(build, "", "", "", new User(), "", "", "", + new OperationalEnvAuditData("", "", "")); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditDistribNotificationEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditDistribNotificationEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribStatusEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribStatusEventFactoryTest.java new file mode 100644 index 0000000000..a9b5e68394 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistribStatusEventFactoryTest.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.be.auditing.impl.distribution; + +import org.junit.Test; +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 AuditDistribStatusEventFactoryTest { + + private AuditDistribStatusEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditDistribStatusEventFactory(build, "", "", "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditDistribStatusEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditDistribStatusEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditGetUebClusterEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditGetUebClusterEventFactoryTest.java new file mode 100644 index 0000000000..10608ab651 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditGetUebClusterEventFactoryTest.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.be.auditing.impl.distribution; + +import org.junit.Test; +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 AuditGetUebClusterEventFactoryTest { + + private AuditGetUebClusterEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData build = newBuilder.build(); + return new AuditGetUebClusterEventFactory(build, ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditGetUebClusterEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditGetUebClusterEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java index f859b75607..8dd66800e2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java @@ -1,5 +1,23 @@ package org.openecomp.sdc.be.auditing.impl.ecompopenv; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_CREATE_OP_ENV_LOG_STR; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_UNKNOWN_NOTIFICATION_OP_ENV_LOG_STR; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_UNSUPPORTED_TYPE_OP_ENV_LOG_STR; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.OP_ENV_ACTION; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.OP_ENV_ID; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.OP_ENV_NAME; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.OP_ENV_TYPE; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.TENANT_CONTEXT; +import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; + +import java.util.EnumMap; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,24 +38,6 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; import org.openecomp.sdc.be.resources.data.auditing.EcompOperationalEnvironmentEvent; import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import java.util.EnumMap; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_CREATE_OP_ENV_LOG_STR; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_UNKNOWN_NOTIFICATION_OP_ENV_LOG_STR; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_UNSUPPORTED_TYPE_OP_ENV_LOG_STR; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.OP_ENV_ACTION; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.OP_ENV_ID; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.OP_ENV_NAME; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.OP_ENV_TYPE; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.TENANT_CONTEXT; -import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; - @RunWith(MockitoJUnitRunner.class) public class AuditEcompOpEnvEventTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditActivateServiceExternalApiEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditActivateServiceExternalApiEventFactoryTest.java new file mode 100644 index 0000000000..908399aa50 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditActivateServiceExternalApiEventFactoryTest.java @@ -0,0 +1,29 @@ +package org.openecomp.sdc.be.auditing.impl.externalapi; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditActivateServiceExternalApiEventFactoryTest { + + private AuditActivateServiceExternalApiEventFactory createTestSubject() { + Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditActivateServiceExternalApiEventFactory(commonAuData, "", "", "", "", + resAuData, resAuData, "", new User(), ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditActivateServiceExternalApiEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditChangeLifecycleExternalApiEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditChangeLifecycleExternalApiEventFactoryTest.java new file mode 100644 index 0000000000..d639471c77 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditChangeLifecycleExternalApiEventFactoryTest.java @@ -0,0 +1,28 @@ +package org.openecomp.sdc.be.auditing.impl.externalapi; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditChangeLifecycleExternalApiEventFactoryTest { + + private AuditChangeLifecycleExternalApiEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditChangeLifecycleExternalApiEventFactory(commonAuData, "", "", "", "", + resAuData, resAuData, "", new User(), ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditChangeLifecycleExternalApiEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditCreateResourceExternalApiEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditCreateResourceExternalApiEventFactoryTest.java new file mode 100644 index 0000000000..414920ea4b --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditCreateResourceExternalApiEventFactoryTest.java @@ -0,0 +1,28 @@ +package org.openecomp.sdc.be.auditing.impl.externalapi; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditCreateResourceExternalApiEventFactoryTest { + + private AuditCreateResourceExternalApiEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditCreateResourceExternalApiEventFactory(commonAuData, "", "", "", "", + resAuData, resAuData, "", new User(), ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditCreateResourceExternalApiEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditDownloadArtifactExternalApiEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditDownloadArtifactExternalApiEventFactoryTest.java new file mode 100644 index 0000000000..bf5f03c9ea --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditDownloadArtifactExternalApiEventFactoryTest.java @@ -0,0 +1,28 @@ +package org.openecomp.sdc.be.auditing.impl.externalapi; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditDownloadArtifactExternalApiEventFactoryTest { + + private AuditDownloadArtifactExternalApiEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditDownloadArtifactExternalApiEventFactory(commonAuData, "", "", "", "", + resAuData, resAuData, "", new User(), ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditDownloadArtifactExternalApiEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java index 7ddc9a0606..1ddda9ea5f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java @@ -1,28 +1,5 @@ package org.openecomp.sdc.be.auditing.impl.externalapi; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.openecomp.sdc.be.auditing.api.AuditEventFactory; -import org.openecomp.sdc.be.auditing.impl.AuditingManager; -import org.openecomp.sdc.be.config.Configuration; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; -import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; -import org.openecomp.sdc.be.dao.impl.AuditingDao; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; -import org.openecomp.sdc.be.resources.data.auditing.ExternalApiEvent; -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - -import java.util.EnumMap; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyMap; @@ -54,6 +31,29 @@ import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.STATUS_OK; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.modifier; +import java.util.EnumMap; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.auditing.api.AuditEventFactory; +import org.openecomp.sdc.be.auditing.impl.AuditingManager; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; +import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.impl.AuditingDao; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; +import org.openecomp.sdc.be.resources.data.auditing.ExternalApiEvent; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; + @RunWith(MockitoJUnitRunner.class) public class AuditExternalApiEventFuncTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditArtifactResourceAdminEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditArtifactResourceAdminEventFactoryTest.java new file mode 100644 index 0000000000..51c9553b93 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditArtifactResourceAdminEventFactoryTest.java @@ -0,0 +1,29 @@ +package org.openecomp.sdc.be.auditing.impl.resourceadmin; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditArtifactResourceAdminEventFactoryTest { + + private AuditArtifactResourceAdminEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditArtifactResourceAdminEventFactory(AuditingActionEnum.ACTIVATE_SERVICE_BY_API, commonAuData, + resAuData, resAuData, "", "", "", new User(), "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditArtifactResourceAdminEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditCertificationResourceAdminEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditCertificationResourceAdminEventFactoryTest.java new file mode 100644 index 0000000000..a9de5b01ab --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditCertificationResourceAdminEventFactoryTest.java @@ -0,0 +1,29 @@ +package org.openecomp.sdc.be.auditing.impl.resourceadmin; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditCertificationResourceAdminEventFactoryTest { + + private AuditCertificationResourceAdminEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditCertificationResourceAdminEventFactory(AuditingActionEnum.ACTIVATE_SERVICE_BY_API, commonAuData, + resAuData, resAuData, "", "", "", new User(), "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditCertificationResourceAdminEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditCreateUpdateResourceAdminEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditCreateUpdateResourceAdminEventFactoryTest.java new file mode 100644 index 0000000000..357d2e2694 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditCreateUpdateResourceAdminEventFactoryTest.java @@ -0,0 +1,29 @@ +package org.openecomp.sdc.be.auditing.impl.resourceadmin; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditCreateUpdateResourceAdminEventFactoryTest { + + private AuditCreateUpdateResourceAdminEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditCreateUpdateResourceAdminEventFactory(AuditingActionEnum.ACTIVATE_SERVICE_BY_API, commonAuData, + resAuData, resAuData, "", "", "", new User(), "", "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditCreateUpdateResourceAdminEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditDistStateChangeRequestResourceAdminEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditDistStateChangeRequestResourceAdminEventFactoryTest.java new file mode 100644 index 0000000000..20b65c5b6c --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditDistStateChangeRequestResourceAdminEventFactoryTest.java @@ -0,0 +1,28 @@ +package org.openecomp.sdc.be.auditing.impl.resourceadmin; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditDistStateChangeRequestResourceAdminEventFactoryTest { + + private AuditDistStateChangeRequestResourceAdminEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditDistStateChangeRequestResourceAdminEventFactory(commonAuData, resAuData, + resAuData, "", "", "", new User(), "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditDistStateChangeRequestResourceAdminEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditDistStateChangeResourceAdminEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditDistStateChangeResourceAdminEventFactoryTest.java new file mode 100644 index 0000000000..d3900ee9c9 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditDistStateChangeResourceAdminEventFactoryTest.java @@ -0,0 +1,29 @@ +package org.openecomp.sdc.be.auditing.impl.resourceadmin; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditDistStateChangeResourceAdminEventFactoryTest { + + private AuditDistStateChangeResourceAdminEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + return new AuditDistStateChangeResourceAdminEventFactory(AuditingActionEnum.ACTIVATE_SERVICE_BY_API, commonAuData, + resAuData, resAuData, "", "", "", new User(), "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditDistStateChangeResourceAdminEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditImportResourceAdminEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditImportResourceAdminEventFactoryTest.java new file mode 100644 index 0000000000..ff033dabaf --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditImportResourceAdminEventFactoryTest.java @@ -0,0 +1,29 @@ +package org.openecomp.sdc.be.auditing.impl.resourceadmin; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; + +public class AuditImportResourceAdminEventFactoryTest { + + private AuditImportResourceAdminEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData.Builder newBuilder2 = ResourceAuditData.newBuilder(); + ResourceAuditData resAuData = newBuilder2.build(); + new AuditImportResourceAdminEventFactory(commonAuData, resAuData, resAuData, "", "", "", new User(), ""); + return new AuditImportResourceAdminEventFactory(commonAuData, resAuData, + resAuData, "", "", "", new User(), "", "", "", ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditImportResourceAdminEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java index 18bd41c765..8478803f16 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java @@ -1,33 +1,5 @@ package org.openecomp.sdc.be.auditing.impl.resourceadmin; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.openecomp.sdc.be.auditing.api.AuditEventFactory; -import org.openecomp.sdc.be.auditing.impl.AuditingManager; -import org.openecomp.sdc.be.config.Configuration; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; -import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; -import org.openecomp.sdc.be.dao.impl.AuditingDao; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; -import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent; -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; -import org.openecomp.sdc.common.api.ConfigurationSource; -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import org.openecomp.sdc.common.util.ThreadLocalsHolder; - -import java.util.EnumMap; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyMap; @@ -62,6 +34,34 @@ import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.TOSCA_NODE_TYPE; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.modifier; +import java.util.EnumMap; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.auditing.api.AuditEventFactory; +import org.openecomp.sdc.be.auditing.impl.AuditingManager; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; +import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.impl.AuditingDao; +import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; +import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; +import org.openecomp.sdc.common.api.ConfigurationSource; +import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; + @RunWith(MockitoJUnitRunner.class) public class AuditResourceAdminEventFuncTest { private AuditingManager auditingManager; 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 new file mode 100644 index 0000000000..8b74764b8b --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditGetUsersListEventFactoryTest.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.be.auditing.impl.usersadmin; + +import org.junit.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 { + + 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(), ""); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditGetUsersListEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditGetUsersListEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..df6245d336 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactoryTest.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.be.auditing.impl.usersadmin; + +import org.junit.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 { + + 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()); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditUserAccessEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditUserAccessEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAdminEventFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAdminEventFactoryTest.java new file mode 100644 index 0000000000..6c46902aeb --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAdminEventFactoryTest.java @@ -0,0 +1,37 @@ +package org.openecomp.sdc.be.auditing.impl.usersadmin; + +import org.junit.Test; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; + +public class AuditUserAdminEventFactoryTest { + + private AuditUserAdminEventFactory createTestSubject() { + org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData.Builder newBuilder = CommonAuditData.newBuilder(); + CommonAuditData commonAuData = newBuilder.build(); + return new AuditUserAdminEventFactory(AuditingActionEnum.ACTIVATE_SERVICE_BY_API, commonAuData, new User(), + new User(), new User()); + } + + @Test + public void testGetLogMessage() throws Exception { + AuditUserAdminEventFactory testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLogMessage(); + } + + @Test + public void testGetDbEvent() throws Exception { + AuditUserAdminEventFactory testSubject; + AuditingGenericEvent result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDbEvent(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java index 4a5b1bbd59..f454a4b164 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java @@ -1,32 +1,5 @@ package org.openecomp.sdc.be.auditing.impl.usersadmin; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.openecomp.sdc.be.auditing.api.AuditEventFactory; -import org.openecomp.sdc.be.auditing.impl.AuditAuthRequestEventFactory; -import org.openecomp.sdc.be.auditing.impl.AuditingManager; -import org.openecomp.sdc.be.config.Configuration; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; -import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; -import org.openecomp.sdc.be.dao.impl.AuditingDao; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; -import org.openecomp.sdc.be.resources.data.auditing.AuthEvent; -import org.openecomp.sdc.be.resources.data.auditing.GetUsersListEvent; -import org.openecomp.sdc.be.resources.data.auditing.UserAccessEvent; -import org.openecomp.sdc.be.resources.data.auditing.UserAdminEvent; -import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; - -import java.util.EnumMap; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyMap; @@ -59,6 +32,33 @@ import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.modifier; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.user; +import java.util.EnumMap; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.auditing.api.AuditEventFactory; +import org.openecomp.sdc.be.auditing.impl.AuditAuthRequestEventFactory; +import org.openecomp.sdc.be.auditing.impl.AuditingManager; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; +import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.impl.AuditingDao; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent; +import org.openecomp.sdc.be.resources.data.auditing.AuthEvent; +import org.openecomp.sdc.be.resources.data.auditing.GetUsersListEvent; +import org.openecomp.sdc.be.resources.data.auditing.UserAccessEvent; +import org.openecomp.sdc.be.resources.data.auditing.UserAdminEvent; +import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; + @RunWith(MockitoJUnitRunner.class) public class AuditUserEventFuncTest { @Mock diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java index 06c22bca69..b9f65f5b88 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/AuditingManagerTest.java @@ -20,6 +20,12 @@ package org.openecomp.sdc.be.components; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +import java.util.EnumMap; +import java.util.UUID; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,12 +38,6 @@ import org.openecomp.sdc.be.dao.impl.AuditingDao; import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.openecomp.sdc.common.util.ThreadLocalsHolder; -import java.util.EnumMap; -import java.util.UUID; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; - @RunWith(MockitoJUnitRunner.class) public class AuditingManagerTest extends BeConfDependentTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java index bbd827eb23..a8c014754c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java @@ -1,7 +1,15 @@ package org.openecomp.sdc.be.components; -import com.google.common.collect.Sets; -import fj.data.Either; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletContext; + import org.junit.Before; import org.mockito.Mockito; import org.openecomp.sdc.ElementOperationMock; @@ -47,14 +55,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.google.common.collect.Sets; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; +import fj.data.Either; public class BaseServiceBusinessLogicTest { private static final Logger log = LoggerFactory.getLogger(ServiceBusinessLogicTest.class); private static final String SERVICE_CATEGORY = "Mobility"; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java index d7bfdcd1a4..95a649fbe8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ComponentBusinessLogicTest.java @@ -20,7 +20,13 @@ package org.openecomp.sdc.be.components; -import fj.data.Either; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,12 +48,7 @@ import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class ComponentBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java index c114f340b8..a2dfd907da 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java @@ -20,6 +20,10 @@ package org.openecomp.sdc.be.components; +import static org.mockito.Mockito.when; + +import javax.servlet.ServletContext; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -42,10 +46,6 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import javax.servlet.ServletContext; - -import static org.mockito.Mockito.when; /** * tests GroupBusinessLogic class * @author ns019t diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java index 04c2100ed8..11d2496211 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java @@ -20,17 +20,17 @@ package org.openecomp.sdc.be.components; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + import org.junit.Test; import org.openecomp.sdc.be.components.health.HealthCheckBusinessLogic; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.api.HealthCheckInfo; import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; public class HealthCheckBusinessLogicTest { HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java index 18116a4d56..f38848c1be 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java @@ -16,15 +16,15 @@ package org.openecomp.sdc.be.components; +import java.util.HashMap; +import java.util.Map; + import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.Operation; -import java.util.HashMap; -import java.util.Map; - public interface InterfaceOperationTestUtils { default InterfaceDefinition createInterface(String uniqueID, String description, String type, diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PathTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PathTest.java index f9412c1643..a218b8bb41 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PathTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PathTest.java @@ -1,9 +1,16 @@ package org.openecomp.sdc.be.components; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.junit.Test; import org.mockito.Mockito; import org.openecomp.sdc.be.auditing.impl.AuditingManager; @@ -23,16 +30,11 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class PathTest extends BaseServiceBusinessLogicTest { public static final String fromNode = "fromNode"; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java index 38aaf92335..120077efc9 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java @@ -20,8 +20,19 @@ package org.openecomp.sdc.be.components; -import fj.data.Either; -import junit.framework.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletContext; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -52,17 +63,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; +import junit.framework.Assert; public class PropertyBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index 82389822f3..6488482e06 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -20,7 +20,16 @@ package org.openecomp.sdc.be.components; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.BeforeClass; @@ -55,15 +64,7 @@ import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.PolicyException; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ResourceImportManagerTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceTestUtils.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceTestUtils.java index e750d3ab51..e74a84c809 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceTestUtils.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceTestUtils.java @@ -20,14 +20,14 @@ package org.openecomp.sdc.be.components; +import java.util.ArrayList; +import java.util.List; + import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.category.CategoryDefinition; -import java.util.ArrayList; -import java.util.List; - public class ResourceTestUtils { public static Resource prepareResource(int resourceIndex) { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java index bbb381bad3..f9c75d488e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java @@ -20,7 +20,23 @@ package org.openecomp.sdc.be.components; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.servlet.ServletContext; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.Ignore; @@ -71,21 +87,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ServiceBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java index fe7152608c..86b8b56901 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java @@ -1,6 +1,10 @@ package org.openecomp.sdc.be.components; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -31,10 +35,7 @@ import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.common.util.ThreadLocalsHolder; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.when; +import fj.data.Either; /** * Created by chaya on 10/26/2017. diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/AaiMockRequestHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/AaiMockRequestHandlerTest.java deleted file mode 100644 index 7df88c1cd9..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/AaiMockRequestHandlerTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.openecomp.sdc.be.components.distribution.engine; - -import org.apache.http.HttpStatus; -import org.junit.Ignore; -import org.junit.Test; -import org.openecomp.sdc.be.components.BeConfDependentTest; -import org.openecomp.sdc.be.info.OperationalEnvInfo; -import org.openecomp.sdc.common.http.client.api.HttpResponse; - -import static org.junit.Assert.assertTrue; - -public class AaiMockRequestHandlerTest extends BeConfDependentTest { - - @Ignore - @Test - public void testGetOperationalEnvJson() { - String id = "OEid4"; - AaiRequestHandler aaiRequestHandler = new AaiRequestHandler(); - aaiRequestHandler.init(); - HttpResponse<String> resp = aaiRequestHandler.getOperationalEnvById(id); - - if (resp.getStatusCode() == HttpStatus.SC_OK) { - try { - String response = resp.getResponse(); - System.out.println("The rest response is:"); - System.out.println(response); - - OperationalEnvInfo operationalEnvInfo = OperationalEnvInfo.createFromJson(response); - - System.out.println(String.format("Get \"%s\" operational environment. %s", id, operationalEnvInfo)); - System.out.println(operationalEnvInfo); - } - catch (Exception e) { - System.out.println(String.format("Json convert to OperationalEnvInfo failed with exception %s", e)); - System.out.println(HttpStatus.SC_INTERNAL_SERVER_ERROR); - } - } - else { - System.out.println("The rest response is:"); - String response = resp.getResponse(); - System.out.println(response); - System.out.println(String.format("Get \"%s\" operational environment failed with statusCode: %s, response: %s, description: %s", id, resp.getStatusCode(), resp.getResponse(), resp.getDescription())); - System.out.println(resp.getStatusCode()); - } - - assertTrue(true); - } -} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/AaiRequestHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/AaiRequestHandlerTest.java new file mode 100644 index 0000000000..3a29821504 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/AaiRequestHandlerTest.java @@ -0,0 +1,68 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import java.util.Properties; + +import org.junit.Test; +import org.openecomp.sdc.be.components.BeConfDependentTest; + +import mockit.Deencapsulation; + +public class AaiRequestHandlerTest extends BeConfDependentTest { + + private AaiRequestHandler createTestSubject() { + AaiRequestHandler testSubject = new AaiRequestHandler(); + testSubject.init(); + return testSubject; + } + + @Test + public void testInit() throws Exception { + AaiRequestHandler testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.init(); + } + + @Test + public void testGetOperationalEnvById() throws Exception { + AaiRequestHandler testSubject; + String id = ""; + + // default test + testSubject = createTestSubject(); + testSubject.getOperationalEnvById(id); + } + + @Test + public void testRetryOnException() throws Exception { + AaiRequestHandler testSubject; + Exception e = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "retryOnException", new Object[] { Exception.class }); + } + + @Test + public void testGetCause() throws Exception { + AaiRequestHandler testSubject; + Exception e = null; + Throwable result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "getCause", new Object[] { Exception.class }); + } + + @Test + public void testCreateHeaders() throws Exception { + AaiRequestHandler testSubject; + Properties result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "createHeaders"); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java new file mode 100644 index 0000000000..bbed75dc60 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java @@ -0,0 +1,311 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdc.be.components.BeConfDependentTest; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.common.api.ArtifactTypeEnum; + +import mockit.Deencapsulation; + +public class ArtifactInfoImplTest extends BeConfDependentTest { + + private ArtifactInfoImpl createTestSubject() { + return new ArtifactInfoImpl(); + } + + @Test + public void testConvertToArtifactInfoImpl() throws Exception { + Service service = new Service(); + ComponentInstance resourceInstance = new ComponentInstance(); + Collection<ArtifactDefinition> list = new LinkedList<>(); + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + List<ArtifactInfoImpl> result; + + // test 1 + result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list); + Assert.assertEquals(new LinkedList<>(), result); + + // test 2 + artifactDefinition.setUniqueId("mock"); + list.add(artifactDefinition); + result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list); + Assert.assertFalse(result.isEmpty()); + + // test 3 + artifactDefinition.setGeneratedFromId("mock"); + result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list); + Assert.assertFalse(result.isEmpty()); + } + + @Test + public void testConvertServiceArtifactToArtifactInfoImpl() throws Exception { + Service service = new Service(); + Collection<ArtifactDefinition> list = new LinkedList<>(); + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + List<ArtifactInfoImpl> result = new LinkedList<>(); + + // test 1 + result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list); + Assert.assertEquals(new LinkedList<>(), result); + + // test 2 + artifactDefinition.setUniqueId("mock"); + list.add(artifactDefinition); + + result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list); + Assert.assertFalse(result.isEmpty()); + + // test 3 + artifactDefinition.setGeneratedFromId("mock"); + + result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list); + Assert.assertFalse(result.isEmpty()); + } + + @Test + public void testGetUpdatedRequiredArtifactsFromNamesToUuids() throws Exception { + ArtifactDefinition artifactDefinition = null; + Map<String, ArtifactDefinition> artifacts = new HashMap<String, ArtifactDefinition>(); + List<String> result; + + // test 1 + artifactDefinition = null; + result = Deencapsulation.invoke(ArtifactInfoImpl.class, "getUpdatedRequiredArtifactsFromNamesToUuids", + new Object[] { ArtifactDefinition.class, artifacts.getClass() }); + Assert.assertEquals(null, result); + + // test 2 + artifactDefinition = new ArtifactDefinition(); + result = Deencapsulation.invoke(ArtifactInfoImpl.class, "getUpdatedRequiredArtifactsFromNamesToUuids", + new Object[] { ArtifactDefinition.class, artifacts.getClass() }); + Assert.assertEquals(null, result); + } + + @Test + public void testGetArtifactName() throws Exception { + ArtifactInfoImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactName(); + } + + @Test + public void testSetArtifactName() throws Exception { + ArtifactInfoImpl testSubject; + String artifactName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactName(artifactName); + } + + @Test + public void testGetArtifactType() throws Exception { + ArtifactInfoImpl testSubject; + ArtifactTypeEnum result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactType(); + } + + @Test + public void testSetArtifactType() throws Exception { + ArtifactInfoImpl testSubject; + ArtifactTypeEnum artifactType = null; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL); + } + + @Test + public void testGetArtifactURL() throws Exception { + ArtifactInfoImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactURL(); + } + + @Test + public void testSetArtifactURL() throws Exception { + ArtifactInfoImpl testSubject; + String artifactURL = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactURL(artifactURL); + } + + @Test + public void testGetArtifactChecksum() throws Exception { + ArtifactInfoImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactChecksum(); + } + + @Test + public void testSetArtifactChecksum() throws Exception { + ArtifactInfoImpl testSubject; + String artifactChecksum = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactChecksum(artifactChecksum); + } + + @Test + public void testGetArtifactDescription() throws Exception { + ArtifactInfoImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactDescription(); + } + + @Test + public void testSetArtifactDescription() throws Exception { + ArtifactInfoImpl testSubject; + String artifactDescription = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactDescription(artifactDescription); + } + + @Test + public void testGetArtifactTimeout() throws Exception { + ArtifactInfoImpl testSubject; + Integer result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactTimeout(); + } + + @Test + public void testSetArtifactTimeout() throws Exception { + ArtifactInfoImpl testSubject; + Integer artifactTimeout = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactTimeout(artifactTimeout); + } + + @Test + public void testGetRelatedArtifacts() throws Exception { + ArtifactInfoImpl testSubject; + List<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelatedArtifacts(); + } + + @Test + public void testSetRelatedArtifacts() throws Exception { + ArtifactInfoImpl testSubject; + List<String> relatedArtifacts = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRelatedArtifacts(relatedArtifacts); + } + + @Test + public void testToString() throws Exception { + ArtifactInfoImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } + + @Test + public void testGetArtifactUUID() throws Exception { + ArtifactInfoImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactUUID(); + } + + @Test + public void testSetArtifactUUID() throws Exception { + ArtifactInfoImpl testSubject; + String artifactUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactUUID(artifactUUID); + } + + @Test + public void testGetArtifactVersion() throws Exception { + ArtifactInfoImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactVersion(); + } + + @Test + public void testSetArtifactVersion() throws Exception { + ArtifactInfoImpl testSubject; + String artifactVersion = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactVersion(artifactVersion); + } + + @Test + public void testGetGeneratedFromUUID() throws Exception { + ArtifactInfoImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getGeneratedFromUUID(); + } + + @Test + public void testSetGeneratedFromUUID() throws Exception { + ArtifactInfoImpl testSubject; + String generatedFromUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setGeneratedFromUUID(generatedFromUUID); + } + + @Test + public void testUpdateArtifactTimeout() throws Exception { + ArtifactInfoImpl testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.updateArtifactTimeout(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/CambriaErrorResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/CambriaErrorResponseTest.java new file mode 100644 index 0000000000..e3bdecc440 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/CambriaErrorResponseTest.java @@ -0,0 +1,103 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import java.util.List; + +import org.junit.Test; +import org.openecomp.sdc.be.distribution.api.client.CambriaOperationStatus; + +public class CambriaErrorResponseTest { + + private CambriaErrorResponse createTestSubject() { + return new CambriaErrorResponse(); + } + + @Test + public void testConstructors() throws Exception { + CambriaErrorResponse testSubject; + CambriaOperationStatus result; + + // default test + new CambriaErrorResponse(CambriaOperationStatus.AUTHENTICATION_ERROR); + new CambriaErrorResponse(CambriaOperationStatus.CONNNECTION_ERROR, 500); + } + + @Test + public void testGetOperationStatus() throws Exception { + CambriaErrorResponse testSubject; + CambriaOperationStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperationStatus(); + } + + @Test + public void testSetOperationStatus() throws Exception { + CambriaErrorResponse testSubject; + CambriaOperationStatus operationStatus = null; + + // default test + testSubject = createTestSubject(); + testSubject.setOperationStatus(operationStatus); + } + + @Test + public void testGetHttpCode() throws Exception { + CambriaErrorResponse testSubject; + Integer result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getHttpCode(); + } + + @Test + public void testSetHttpCode() throws Exception { + CambriaErrorResponse testSubject; + Integer httpCode = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setHttpCode(httpCode); + } + + @Test + public void testAddVariable() throws Exception { + CambriaErrorResponse testSubject; + String variable = ""; + + // default test + testSubject = createTestSubject(); + testSubject.addVariable(variable); + } + + @Test + public void testGetVariables() throws Exception { + CambriaErrorResponse testSubject; + List<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVariables(); + } + + @Test + public void testSetVariables() throws Exception { + CambriaErrorResponse testSubject; + List<String> variables = null; + + // default test + testSubject = createTestSubject(); + testSubject.setVariables(variables); + } + + @Test + public void testToString() throws Exception { + CambriaErrorResponse testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandlerTest.java index d425e6d0f5..ae5dec4194 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandlerTest.java @@ -1,10 +1,19 @@ package org.openecomp.sdc.be.components.distribution.engine; -import com.att.nsa.apiClient.credentials.ApiCredential; -import com.att.nsa.apiClient.http.HttpException; -import com.att.nsa.cambria.client.CambriaClient.CambriaApiException; -import com.att.nsa.cambria.client.CambriaIdentityManager; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.security.GeneralSecurityException; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -13,65 +22,315 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.components.BeConfDependentTest; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.distribution.api.client.CambriaOperationStatus; import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import java.io.IOException; -import java.net.MalformedURLException; -import java.security.GeneralSecurityException; -import java.util.Arrays; +import com.att.nsa.apiClient.credentials.ApiCredential; +import com.att.nsa.apiClient.http.HttpException; +import com.att.nsa.cambria.client.CambriaClient; +import com.att.nsa.cambria.client.CambriaClient.CambriaApiException; +import com.att.nsa.cambria.client.CambriaClientBuilders.AbstractAuthenticatedManagerBuilder; +import com.att.nsa.cambria.client.CambriaClientBuilders.TopicManagerBuilder; +import com.att.nsa.cambria.client.CambriaConsumer; +import com.att.nsa.cambria.client.CambriaIdentityManager; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; +import fj.data.Either; +import mockit.Deencapsulation; @RunWith(MockitoJUnitRunner.class) -public class CambriaHandlerTest { - @Spy - private CambriaHandler handler = new CambriaHandler(); +public class CambriaHandlerTest extends BeConfDependentTest { + + private CambriaHandler createTestSubject() { + return new CambriaHandler(); + } + + @Spy + private CambriaHandler handler = new CambriaHandler(); + + @Mock + private CambriaIdentityManager createIdentityManager; + + private ApiCredential apiCredential = new ApiCredential("apiKey", "apiSecret"); + + @BeforeClass + public static void beforeClass() { + String appConfigDir = "src/test/resources/config/catalog-be"; + ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), + appConfigDir); + new ConfigurationManager(configurationSource); + } + + @Before + public void startUp() throws MalformedURLException, GeneralSecurityException { + doReturn(createIdentityManager).when(handler).buildCambriaClient(any()); + } + + @Test + public void testMockCreateUebKeys() throws HttpException, CambriaApiException, IOException { + Mockito.when(createIdentityManager.createApiKey(Mockito.anyString(), Mockito.anyString())) + .thenReturn(apiCredential); + Either<ApiCredential, CambriaErrorResponse> eitherCreateUebKeys = handler + .createUebKeys(Arrays.asList("Myhost:1234")); + + Mockito.verify(createIdentityManager).setApiCredentials(Mockito.anyString(), Mockito.anyString()); + + assertTrue("Unexpected Operational Status", eitherCreateUebKeys.isLeft()); + + } + + @Test + public void testMockCreateUebKeys_FAIL() throws HttpException, CambriaApiException, IOException { + Mockito.when(createIdentityManager.createApiKey(Mockito.anyString(), Mockito.anyString())) + .thenThrow(new CambriaApiException("Error Message")); + Either<ApiCredential, CambriaErrorResponse> eitherCreateUebKeys = handler + .createUebKeys(Arrays.asList("Myhost:1234")); + Mockito.verify(createIdentityManager, Mockito.never()).setApiCredentials(Mockito.anyString(), + Mockito.anyString()); + assertTrue("Unexpected Operational Status", eitherCreateUebKeys.isRight()); + CambriaErrorResponse response = eitherCreateUebKeys.right().value(); + assertEquals("Unexpected Operational Status", CambriaOperationStatus.CONNNECTION_ERROR, + response.getOperationStatus()); + assertEquals("Unexpected HTTP Code", 500, response.getHttpCode().intValue()); + } + + @Test + public void testProcessMessageException() throws Exception { + CambriaHandler testSubject; + String message = ""; + Integer result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "processMessageException", new Object[] { message }); + } + + @Test + public void testCheckPattern() throws Exception { + CambriaHandler testSubject; + String patternStr = ""; + String message = ""; + int groupIndex = 0; + Integer result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "checkPattern", new Object[] { patternStr, message, groupIndex }); + } + + @Test + public void testGetTopics() throws Exception { + CambriaHandler testSubject; + List<String> hostSet = new LinkedList<>(); + hostSet.add("mock"); + Either<Set<String>, CambriaErrorResponse> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getTopics(hostSet); + } + + @Test + public void testProcessError() throws Exception { + CambriaHandler testSubject; + Exception e = null; + CambriaErrorResponse result; + + // default test + testSubject = createTestSubject(); + + e = new Exception("HTTP Status 999"); + result = Deencapsulation.invoke(testSubject, "processError", e); + + e = new Exception("HTTP Status 401"); + result = Deencapsulation.invoke(testSubject, "processError", e); + + e = new Exception("HTTP Status 409"); + result = Deencapsulation.invoke(testSubject, "processError", e); + + e = new Exception("HTTP Status 500"); + result = Deencapsulation.invoke(testSubject, "processError", e); + + e = new Exception("mock", new Throwable(new Throwable("mock"))); + result = Deencapsulation.invoke(testSubject, "processError", e); + } + + @Test + public void testWriteErrorToLog() throws Exception { + CambriaHandler testSubject; + CambriaErrorResponse cambriaErrorResponse = new CambriaErrorResponse(); + cambriaErrorResponse.setOperationStatus(CambriaOperationStatus.AUTHENTICATION_ERROR); + String errorMessage = "mock"; + String methodName = "mock"; + String operationDesc = "mock"; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "writeErrorToLog", cambriaErrorResponse, "mock", "mock", "mock"); + } + + @Test + public void testCreateTopic() throws Exception { + CambriaHandler testSubject; + Collection<String> hostSet = new LinkedList<>(); + hostSet.add("mock"); + String apiKey = "mock"; + String secretKey = "mock"; + String topicName = "mock"; + int partitionCount = 0; + int replicationCount = 0; + CambriaErrorResponse result; + + // default test + testSubject = createTestSubject(); + result = testSubject.createTopic(hostSet, apiKey, secretKey, topicName, partitionCount, replicationCount); + } + + @Test + public void testUnRegisterFromTopic() throws Exception { + CambriaHandler testSubject; + Collection<String> hostSet = new LinkedList<>(); + hostSet.add("mock"); + String managerApiKey = "mock"; + String managerSecretKey = "mock"; + String subscriberApiKey = "mock"; + String topicName = "mock"; + CambriaErrorResponse unRegisterFromTopic = null; + + // default test + testSubject = createTestSubject(); + unRegisterFromTopic = testSubject.unRegisterFromTopic(hostSet, managerApiKey, managerSecretKey, + subscriberApiKey, SubscriberTypeEnum.CONSUMER, topicName); + } + + @Test + public void testRegisterToTopic() throws Exception { + CambriaHandler testSubject; + Collection<String> hostSet = new LinkedList<String>(); + hostSet.add("mock"); + String managerApiKey = "mock"; + String managerSecretKey = "mock"; + String subscriberApiKey = "mock"; + SubscriberTypeEnum subscriberTypeEnum = null; + String topicName = "mock"; + CambriaErrorResponse result; + + // default test + testSubject = createTestSubject(); + result = testSubject.registerToTopic(hostSet, managerApiKey, managerSecretKey, subscriberApiKey, + SubscriberTypeEnum.CONSUMER, topicName); + } + + @Test + public void testCreateConsumer() throws Exception { + CambriaHandler testSubject; + Collection<String> hostSet = new LinkedList<>(); + hostSet.add("mock"); + String topicName = "mock"; + String apiKey = "mock"; + String secretKey = "mock"; + String consumerId = "mock"; + String consumerGroup = "mock"; + int timeoutMS = 0; + CambriaConsumer result; + + // default test + testSubject = createTestSubject(); + result = testSubject.createConsumer(hostSet, topicName, apiKey, secretKey, consumerId, consumerGroup, + timeoutMS); + } + + @Test + public void testCloseConsumer() throws Exception { + CambriaHandler testSubject; + CambriaConsumer consumer = null; + + // test 1 + testSubject = createTestSubject(); + consumer = null; + testSubject.closeConsumer(consumer); + } + + @Test + public void testFetchFromTopic() throws Exception { + CambriaHandler testSubject; + CambriaConsumer topicConsumer = null; + Either<Iterable<String>, CambriaErrorResponse> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.fetchFromTopic(topicConsumer); + } - @Mock - private CambriaIdentityManager createIdentityManager; + @Test + public void testSendNotification() throws Exception { + CambriaHandler testSubject; + String topicName = "mock"; + String uebPublicKey = "mock"; + String uebSecretKey = "mock"; + List<String> uebServers = new LinkedList<>(); + uebServers.add("mock"); + INotificationData data = null; + CambriaErrorResponse result; - private ApiCredential apiCredential = new ApiCredential("apiKey", "apiSecret"); + // default test + testSubject = createTestSubject(); + result = testSubject.sendNotification(topicName, uebPublicKey, uebSecretKey, uebServers, data); + } - @BeforeClass - public static void beforeClass() { - String appConfigDir = "src/test/resources/config/catalog-be"; - ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); - new ConfigurationManager(configurationSource); - } + @Test + public void testSendNotificationAndClose() throws Exception { + CambriaHandler testSubject; + String topicName = "mock"; + String uebPublicKey = "mock"; + String uebSecretKey = "mock"; + List<String> uebServers = new LinkedList<>(); + uebServers.add("mock"); + INotificationData data = null; + long waitBeforeCloseTimeout = 1; + CambriaErrorResponse result; + // default test + testSubject = createTestSubject(); + result = testSubject.sendNotificationAndClose(topicName, uebPublicKey, uebSecretKey, uebServers, data, + waitBeforeCloseTimeout); + } - @Before - public void startUp() throws MalformedURLException, GeneralSecurityException { - doReturn(createIdentityManager).when(handler).buildCambriaClient(any()); - } + @Test + public void testGetApiKey() throws Exception { + CambriaHandler testSubject; + String server = ""; + String apiKey = ""; + CambriaErrorResponse result; - @Test - public void testCreateUebKeys() throws HttpException, CambriaApiException, IOException { - Mockito.when(createIdentityManager.createApiKey(Mockito.anyString(), Mockito.anyString())).thenReturn(apiCredential); - Either<ApiCredential, CambriaErrorResponse> eitherCreateUebKeys = handler.createUebKeys(Arrays.asList("Myhost:1234") ); + // default test + testSubject = createTestSubject(); + result = testSubject.getApiKey(server, apiKey); + } - Mockito.verify(createIdentityManager).setApiCredentials(Mockito.anyString(), Mockito.anyString()); + @Test + public void testCreateUebKeys() throws Exception { + CambriaHandler testSubject; + List<String> hostSet = null; + Either<ApiCredential, CambriaErrorResponse> result; - assertTrue("Unexpected Operational Status", eitherCreateUebKeys.isLeft()); + // default test + testSubject = createTestSubject(); + result = testSubject.createUebKeys(hostSet); + } - } + @Test + public void testBuildCambriaClient() throws Exception { + CambriaHandler testSubject; + AbstractAuthenticatedManagerBuilder<? extends CambriaClient> client = new TopicManagerBuilder() + .usingHosts("mock").authenticatedBy("mock", "mock"); - @Test - public void testCreateUebKeys_FAIL() throws HttpException, CambriaApiException, IOException { - Mockito.when(createIdentityManager.createApiKey(Mockito.anyString(), Mockito.anyString())).thenThrow(new CambriaApiException("Error Message")); - Either<ApiCredential, CambriaErrorResponse> eitherCreateUebKeys = handler.createUebKeys(Arrays.asList("Myhost:1234") ); - Mockito.verify(createIdentityManager, Mockito.never()).setApiCredentials(Mockito.anyString(), Mockito.anyString()); - assertTrue("Unexpected Operational Status", eitherCreateUebKeys.isRight()); - CambriaErrorResponse response = eitherCreateUebKeys.right().value(); - assertEquals("Unexpected Operational Status", CambriaOperationStatus.CONNNECTION_ERROR, response.getOperationStatus()); - assertEquals("Unexpected HTTP Code", 500, response.getHttpCode().intValue()); - } + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "buildCambriaClient", client); + } -} +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/Dev2DevDmaapConsumerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/Dev2DevDmaapConsumerTest.java index 45906c6f30..9903f4c56a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/Dev2DevDmaapConsumerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/Dev2DevDmaapConsumerTest.java @@ -1,7 +1,8 @@ package org.openecomp.sdc.be.components.distribution.engine; -import com.att.nsa.mr.client.MRConsumer; -import com.google.gson.GsonBuilder; +import java.util.concurrent.ExecutorService; +import java.util.stream.IntStream; + import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,8 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.concurrent.ExecutorService; -import java.util.stream.IntStream; +import com.att.nsa.mr.client.MRConsumer; +import com.google.gson.GsonBuilder; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:application-context-test.xml") diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealthTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealthTest.java new file mode 100644 index 0000000000..be25e4af73 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealthTest.java @@ -0,0 +1,157 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.junit.Test; +import org.openecomp.sdc.be.components.BeConfDependentTest; +import org.openecomp.sdc.be.components.distribution.engine.DistributionEngineClusterHealth.HealthCheckScheduledTask; +import org.openecomp.sdc.common.api.HealthCheckInfo; + +import mockit.Deencapsulation; + +public class DistributionEngineClusterHealthTest extends BeConfDependentTest{ + + private DistributionEngineClusterHealth createTestSubject() { + return new DistributionEngineClusterHealth(); + } + + @Test + public void testInit() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "init"); + } + + @Test + public void testDestroy() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "destroy"); + } + + @Test + public void testStartHealthCheckTask() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = null; + boolean startTask = false; + + // default test + testSubject = createTestSubject(); + testSubject.startHealthCheckTask(envNamePerStatus, startTask); + } + + @Test + public void testStartHealthCheckTask_1() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); + + // default test + testSubject = createTestSubject(); + testSubject.init(); + testSubject.startHealthCheckTask(envNamePerStatus); + } + + @Test + public void testHealthCheckScheduledTask() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); + + // default test + testSubject = createTestSubject(); + HealthCheckScheduledTask healthCheckScheduledTask = testSubject. new HealthCheckScheduledTask(new LinkedList<>()); + LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); + UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); + healthCheckCalls.add(hcc); + healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; + + Deencapsulation.invoke(healthCheckScheduledTask, "queryUeb"); + } + + @Test + public void testHealthCheckScheduledTaskRun() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); + envNamePerStatus.put("mock", new AtomicBoolean(true)); + // default test + testSubject = createTestSubject(); + testSubject.startHealthCheckTask(envNamePerStatus, false); + HealthCheckScheduledTask healthCheckScheduledTask = testSubject. new HealthCheckScheduledTask(new LinkedList<>()); + LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); + UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); + healthCheckCalls.add(hcc); + healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; + + Deencapsulation.invoke(healthCheckScheduledTask, "run"); + } + + @Test + public void testHealthCheckScheduledTaskRun_2() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); + envNamePerStatus.put("mock", new AtomicBoolean(false)); + // default test + testSubject = createTestSubject(); + testSubject.startHealthCheckTask(envNamePerStatus, false); + HealthCheckScheduledTask healthCheckScheduledTask = testSubject. new HealthCheckScheduledTask(new LinkedList<>()); + LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); + UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); + healthCheckCalls.add(hcc); + healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; + + Deencapsulation.invoke(healthCheckScheduledTask, "run"); + } + + @Test + public void testLogAlarm() throws Exception { + DistributionEngineClusterHealth testSubject; + boolean lastHealthState = false; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "logAlarm", new Object[] { lastHealthState }); + } + + @Test + public void testGetHealthCheckInfo() throws Exception { + DistributionEngineClusterHealth testSubject; + HealthCheckInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getHealthCheckInfo(); + } + + @Test + public void testSetHealthCheckUebIsDisabled() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.setHealthCheckUebIsDisabled(); + } + + @Test + public void testSetHealthCheckUebConfigurationError() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.setHealthCheckUebConfigurationError(); + } + + @Test + public void testSetHealthCheckOkAndReportInCaseLastStateIsDown() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.setHealthCheckOkAndReportInCaseLastStateIsDown(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java index 04aa242b03..6f167a57b7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineConfigTest.java @@ -20,6 +20,13 @@ package org.openecomp.sdc.be.components.distribution.engine; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.config.ConfigurationManager; @@ -31,13 +38,6 @@ import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class DistributionEngineConfigTest { @Before diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java index 1fa0fc60b7..3d4462e1a3 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java @@ -20,8 +20,12 @@ package org.openecomp.sdc.be.components.distribution.engine; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.List; + import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; @@ -29,11 +33,8 @@ import org.openecomp.sdc.be.components.BeConfDependentTest; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.distribution.api.client.CambriaOperationStatus; -import java.util.List; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; public class DistributionEngineHealthCheckTest extends BeConfDependentTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java index 03a6625cae..c77b86a949 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTaskTest.java @@ -20,7 +20,18 @@ package org.openecomp.sdc.be.components.distribution.engine; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + import org.apache.commons.collections.CollectionUtils; import org.junit.Before; import org.junit.Test; @@ -36,17 +47,7 @@ import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class DistributionEngineInitTaskTest { @@ -90,7 +91,115 @@ public class DistributionEngineInitTaskTest { assertEquals("check next retry interval reach max retry interval", initTask.getCurrentRetryInterval(), maxRetry); } + + @Test + public void checkStartTask() { + + String envName = "PrOD"; + DistributionEngineConfiguration deConfiguration = new DistributionEngineConfiguration(); + int retry = 2; + int maxRetry = 40; + deConfiguration.setInitRetryIntervalSec(retry); + deConfiguration.setInitMaxIntervalSec(maxRetry); + DistributionEngineInitTask initTask = new DistributionEngineInitTask(0l, deConfiguration, envName, new AtomicBoolean(false), componentsUtils, null, readEnvFromConfig(deConfiguration)); + + initTask.startTask(); + } + + @Test + public void checkRestartTask() { + + String envName = "PrOD"; + + DistributionEngineConfiguration deConfiguration = new DistributionEngineConfiguration(); + int retry = 2; + int maxRetry = 40; + deConfiguration.setInitRetryIntervalSec(retry); + deConfiguration.setInitMaxIntervalSec(maxRetry); + DistributionEngineInitTask initTask = new DistributionEngineInitTask(0l, deConfiguration, envName, new AtomicBoolean(false), componentsUtils, null, readEnvFromConfig(deConfiguration)); + + initTask.restartTask(); + } + + @Test + public void checkStopTask() { + + String envName = "PrOD"; + + DistributionEngineConfiguration deConfiguration = new DistributionEngineConfiguration(); + int retry = 2; + int maxRetry = 40; + deConfiguration.setInitRetryIntervalSec(retry); + deConfiguration.setInitMaxIntervalSec(maxRetry); + DistributionEngineInitTask initTask = new DistributionEngineInitTask(0l, deConfiguration, envName, new AtomicBoolean(false), componentsUtils, null, readEnvFromConfig(deConfiguration)); + + initTask.stopTask(); + initTask.startTask(); + initTask.stopTask(); + } + + @Test + public void checkDestroy() { + + String envName = "PrOD"; + + DistributionEngineConfiguration deConfiguration = new DistributionEngineConfiguration(); + int retry = 2; + int maxRetry = 40; + deConfiguration.setInitRetryIntervalSec(retry); + deConfiguration.setInitMaxIntervalSec(maxRetry); + DistributionEngineInitTask initTask = new DistributionEngineInitTask(0l, deConfiguration, envName, new AtomicBoolean(false), componentsUtils, null, readEnvFromConfig(deConfiguration)); + + initTask.destroy(); + } + + @Test + public void checkRun() { + + String notifTopic = "notif"; + String statusTopic = "status"; + + List<String> uebServers = new ArrayList<>(); + uebServers.add("server1"); + CambriaErrorResponse cambriaErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.NOT_FOUND); + Either<Set<String>, CambriaErrorResponse> right = Either.right(cambriaErrorResponse); + when(cambriaHandler.getTopics(Mockito.any(List.class))).thenReturn(right); + + String envName = "PrOD"; + + DistributionEngineConfiguration deConfiguration = new DistributionEngineConfiguration(); + deConfiguration.setUebServers(uebServers); + int retry = 2; + int maxRetry = 40; + deConfiguration.setInitRetryIntervalSec(retry); + deConfiguration.setInitMaxIntervalSec(maxRetry); + deConfiguration.setDistributionNotifTopicName(notifTopic); + deConfiguration.setDistributionStatusTopicName(statusTopic); + CreateTopicConfig createTopic = new CreateTopicConfig(); + createTopic.setPartitionCount(1); + createTopic.setReplicationCount(1); + deConfiguration.setCreateTopic(createTopic); + + cambriaErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.OK); + + String realNotifTopic = notifTopic + "-" + envName.toUpperCase(); + String realStatusTopic = statusTopic + "-" + envName.toUpperCase(); + when(cambriaHandler.createTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.eq(realNotifTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse); + when(cambriaHandler.createTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.eq(realStatusTopic), Mockito.eq(1), Mockito.eq(1))).thenReturn(cambriaErrorResponse); + + cambriaErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.OK); + when(cambriaHandler.registerToTopic(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) + .thenReturn(cambriaErrorResponse); + + DistributionEngineInitTask initTask = new DistributionEngineInitTask(0l, deConfiguration, envName, new AtomicBoolean(false), componentsUtils, null, readEnvFromConfig(deConfiguration)); + initTask.setCambriaHandler(cambriaHandler); + + boolean initFlow = initTask.initFlow(); + + initTask.run(); + } + @SuppressWarnings("unchecked") @Test public void testInitFlowScenarioSuccess() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEnginePollingTaskTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEnginePollingTaskTest.java new file mode 100644 index 0000000000..ecbc1f90f6 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEnginePollingTaskTest.java @@ -0,0 +1,107 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.openecomp.sdc.be.components.BeConfDependentTest; +import org.openecomp.sdc.be.components.distribution.engine.report.DistributionCompleteReporter; +import org.openecomp.sdc.be.config.DistributionEngineConfiguration; +import org.openecomp.sdc.be.impl.ComponentsUtils; +import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; + +import mockit.Deencapsulation; + +public class DistributionEnginePollingTaskTest extends BeConfDependentTest { + + @Mock + private ComponentsUtils componentsUtils; + + private DistributionEnginePollingTask createTestSubject() { + componentsUtils = Mockito.mock(ComponentsUtils.class); + DistributionEngineConfiguration distributionEngineConfiguration = configurationManager + .getDistributionEngineConfiguration(); + + return new DistributionEnginePollingTask(distributionEngineConfiguration, + new DistributionCompleteReporterMock(), componentsUtils, new DistributionEngineClusterHealth(), + new OperationalEnvironmentEntry()); + } + + @Test + public void testStartTask() throws Exception { + DistributionEnginePollingTask testSubject; + String topicName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.startTask(topicName); + } + + @Test + public void testStopTask() throws Exception { + DistributionEnginePollingTask testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.stopTask(); + } + + @Test + public void testDestroy() throws Exception { + DistributionEnginePollingTask testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.destroy(); + } + + @Test + public void testRun() throws Exception { + DistributionEnginePollingTask testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.run(); + } + + @Test + public void testHandleDistributionNotificationMsg() throws Exception { + DistributionEnginePollingTask testSubject; + DistributionStatusNotification notification = new DistributionStatusNotification(); + notification.setDistributionID("mock"); + notification.setConsumerID("mock"); + notification.setArtifactURL("mock"); + notification.setTimestamp(435435); + notification.setStatus(DistributionStatusNotificationEnum.ALREADY_DEPLOYED); + notification.setErrorReason("mock"); + + + + // default test + testSubject = createTestSubject(); + Mockito.doNothing().when(componentsUtils).auditDistributionStatusNotification(Mockito.any(AuditingActionEnum.class), + Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), + Mockito.anyString(), Mockito.anyString(), Mockito.anyString()); + Deencapsulation.invoke(testSubject, "handleDistributionNotificationMsg", + notification); + } + + @Test + public void testShutdownExecutor() throws Exception { + DistributionEnginePollingTask testSubject; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "shutdownExecutor"); + } + + private class DistributionCompleteReporterMock implements DistributionCompleteReporter { + + @Override + public void reportDistributionComplete(DistributionStatusNotification distributionStatusNotification) { + // TODO Auto-generated method stub + + } + + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineTest.java index b1a43eaa57..c1a13f2066 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineTest.java @@ -1,95 +1,358 @@ package org.openecomp.sdc.be.components.distribution.engine; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openecomp.sdc.be.components.utils.OperationalEnvironmentBuilder; +import org.openecomp.sdc.be.config.DistributionEngineConfiguration; +import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionStatusTopicConfig; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; +import mockit.Deencapsulation; -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +public class DistributionEngineTest{ + + public static final String DISTRIBUTION_ID = "distId"; + public static final String ENV_ID = "envId"; + public static final String USER_ID = "userId"; + public static final String MODIFIER = "modifier"; + + @InjectMocks + private DistributionEngine testInstance; + + @Mock + private EnvironmentsEngine environmentsEngine; + + @Mock + private DistributionNotificationSender distributionNotificationSender; + + @Mock + private ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder; + + private DummyDistributionConfigurationManager distributionEngineConfigurationMock; + + private Map<String, OperationalEnvironmentEntry> envs; + + @Before + public void setUpMock() throws Exception { + MockitoAnnotations.initMocks(this); + distributionEngineConfigurationMock = new DummyDistributionConfigurationManager(); + envs = getEnvs(ENV_ID); + } + + @Test + public void notifyService() throws Exception { + NotificationDataImpl notificationData = new NotificationDataImpl(); + Service service = new Service(); + when(environmentsEngine.getEnvironmentById(ENV_ID)).thenReturn(envs.get(ENV_ID)); + when(distributionEngineConfigurationMock.getConfigurationMock().getDistributionNotifTopicName()) + .thenReturn("topic"); + when(distributionNotificationSender.sendNotification(eq("topic-ENVID"), eq(DISTRIBUTION_ID), + any(EnvironmentMessageBusData.class), any(NotificationDataImpl.class), any(Service.class), eq(USER_ID), + eq(MODIFIER))).thenReturn(ActionStatus.OK); + ActionStatus actionStatus = testInstance.notifyService(DISTRIBUTION_ID, service, notificationData, ENV_ID, + USER_ID, MODIFIER); + assertEquals(ActionStatus.OK, actionStatus); + } + + @Test + public void notifyService_couldNotResolveEnvironment() throws Exception { + when(environmentsEngine.getEnvironments()).thenReturn(envs); + ActionStatus actionStatus = testInstance.notifyService(DISTRIBUTION_ID, new Service(), + new NotificationDataImpl(), "someNonExisitngEnv", USER_ID, MODIFIER); + assertEquals(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE, actionStatus); + verifyZeroInteractions(distributionNotificationSender); + } + + @Test + public void notifyService_failedWhileSendingNotification() throws Exception { + NotificationDataImpl notificationData = new NotificationDataImpl(); + Service service = new Service(); + when(environmentsEngine.getEnvironmentById(ENV_ID)).thenReturn(envs.get(ENV_ID)); + when(distributionEngineConfigurationMock.getConfigurationMock().getDistributionNotifTopicName()) + .thenReturn("topic"); + when(distributionNotificationSender.sendNotification(eq("topic-ENVID"), eq(DISTRIBUTION_ID), + any(EnvironmentMessageBusData.class), any(NotificationDataImpl.class), any(Service.class), eq(USER_ID), + eq(MODIFIER))).thenReturn(ActionStatus.GENERAL_ERROR); + ActionStatus actionStatus = testInstance.notifyService(DISTRIBUTION_ID, service, notificationData, ENV_ID, + USER_ID, MODIFIER); + assertEquals(ActionStatus.GENERAL_ERROR, actionStatus); + } + + private Map<String, OperationalEnvironmentEntry> getEnvs(String... environmentIds) { + Set<String> uebAddress = new HashSet<>(); + uebAddress.add("someAddress"); + return Stream.of(environmentIds) + .map(id -> new OperationalEnvironmentBuilder().setEnvId(id).setDmaapUebAddress(uebAddress).build()) + .collect(Collectors.toMap(OperationalEnvironmentEntry::getEnvironmentId, Function.identity())); + } + + private DistributionEngine createTestSubject() { + return new DistributionEngine(); + } + + /*@Test(expected=ExceptionInInitializerError.class) + public void testMain() throws Exception { + String[] args = new String[] { "" }; + + // default test + DistributionEngine.main(args); + }*/ + + @Test + public void testIsActive() throws Exception { + DistributionEngine testSubject; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isActive(); + } + + @Test(expected=NullPointerException.class) + public void testInit() throws Exception { + DistributionEngine testSubject; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "init"); + } + + @Test + public void testShutdown() throws Exception { + DistributionEngine testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.shutdown(); + } + + @Test + public void testValidateConfiguration() throws Exception { + DistributionEngine testSubject; + DistributionEngineConfiguration deConfiguration = new DistributionEngineConfiguration(); + deConfiguration.setDistributionStatusTopic((new DistributionStatusTopicConfig())); + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "validateConfiguration", deConfiguration); + } + + @Test + public void testIsValidServers() throws Exception { + DistributionEngine testSubject; + List<String> uebServers = null; + String methodName = ""; + String paramName = ""; + boolean result; + + // test 1 + testSubject = createTestSubject(); + uebServers = null; + result = Deencapsulation.invoke(testSubject, "isValidServers", + new Object[] { List.class, methodName, paramName }); + Assert.assertEquals(false, result); + } + + @Test + public void testIsValidFqdn() throws Exception { + DistributionEngine testSubject; + String serverFqdn = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "isValidFqdn", new Object[] { serverFqdn }); + } + + @Test + public void testIsValidParam() throws Exception { + DistributionEngine testSubject; + String paramValue = ""; + String methodName = ""; + String paramName = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "isValidParam", + new Object[] { paramValue, methodName, paramName }); + } + + @Test + public void testIsValidParam_1() throws Exception { + DistributionEngine testSubject; + List<String> paramValue = null; + String methodName = ""; + String paramName = ""; + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "isValidParam", + new Object[] { List.class, methodName, paramName }); + } + + @Test + public void testIsValidObject() throws Exception { + DistributionEngine testSubject; + Object paramValue = null; + String methodName = ""; + String paramName = ""; + boolean result; + + // test 1 + testSubject = createTestSubject(); + paramValue = null; + result = Deencapsulation.invoke(testSubject, "isValidObject", + new Object[] { Object.class, methodName, paramName }); + Assert.assertEquals(false, result); + } + + @Test + public void testGetEnvironmentErrorDescription() throws Exception { + DistributionEngine testSubject; + StorageOperationStatus status = null; + String result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "getEnvironmentErrorDescription", + StorageOperationStatus.DISTR_ENVIRONMENT_NOT_AVAILABLE); + result = Deencapsulation.invoke(testSubject, "getEnvironmentErrorDescription", + StorageOperationStatus.DISTR_ENVIRONMENT_NOT_FOUND); + result = Deencapsulation.invoke(testSubject, "getEnvironmentErrorDescription", + StorageOperationStatus.DISTR_ENVIRONMENT_SENT_IS_INVALID); + result = Deencapsulation.invoke(testSubject, "getEnvironmentErrorDescription", + StorageOperationStatus.ARTIFACT_NOT_FOUND); + } + + @Test + public void testIsEnvironmentAvailable() throws Exception { + DistributionEngine testSubject; + String envName = ""; + StorageOperationStatus result; + + // test 1 + testSubject = createTestSubject(); + envName = null; + result = testSubject.isEnvironmentAvailable(envName); + Assert.assertEquals(StorageOperationStatus.DISTR_ENVIRONMENT_SENT_IS_INVALID, result); + + // test 2 + testSubject = createTestSubject(); + envName = "mock"; + result = testSubject.isEnvironmentAvailable(envName); + Assert.assertEquals(StorageOperationStatus.DISTR_ENVIRONMENT_NOT_FOUND, result); + } + + //TODO Create test coverage for this method + /*@Test + public void testIsEnvironmentAvailable_1() throws Exception { + DistributionEngine testSubject; + StorageOperationStatus result; + + // default test + testSubject = createTestSubject(); + result = testInstance.isEnvironmentAvailable(); + }*/ + + @Test(expected=NullPointerException.class) + public void testDisableEnvironment() throws Exception { + DistributionEngine testSubject; + String envName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.disableEnvironment(envName); + } + + @Test + public void testBuildTopicName() throws Exception { + DistributionEngine testSubject; + String envName = ""; + String result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "buildTopicName", new Object[] { envName }); + } + + @Test + public void testIsReadyForDistribution() throws Exception { + DistributionEngine testSubject; + Service service = null; + String envName = ""; + StorageOperationStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isReadyForDistribution(service, envName); + } + + @Test + public void testVerifyServiceHasDeploymentArtifactsTrue() throws Exception { + Service service = new Service(); + StorageOperationStatus result; + + // default test + when(serviceDistributionArtifactsBuilder.verifyServiceContainsDeploymentArtifacts(ArgumentMatchers.any(Service.class))).thenReturn(true); + result = testInstance.verifyServiceHasDeploymentArtifacts(service); + } + + @Test + public void testVerifyServiceHasDeploymentArtifactsFalse() throws Exception { + Service service = new Service(); + StorageOperationStatus result; + + // default test + when(serviceDistributionArtifactsBuilder.verifyServiceContainsDeploymentArtifacts(ArgumentMatchers.any(Service.class))).thenReturn(false); + result = testInstance.verifyServiceHasDeploymentArtifacts(service); + } + + @Test + public void testGetEnvironmentById() throws Exception { + DistributionEngine testSubject; + String opEnvId = ""; + OperationalEnvironmentEntry result; + + // default test + when(environmentsEngine.getEnvironmentById(ArgumentMatchers.anyString())).thenReturn(new OperationalEnvironmentEntry()); + result = testInstance.getEnvironmentById(opEnvId); + } + + @Test + public void testBuildServiceForDistribution() throws Exception { + Service service = new Service(); + String distributionId = ""; + String workloadContext = ""; + INotificationData result; -public class DistributionEngineTest { - - public static final String DISTRIBUTION_ID = "distId"; - public static final String ENV_ID = "envId"; - public static final String USER_ID = "userId"; - public static final String MODIFIER = "modifier"; - - @InjectMocks - private DistributionEngine testInstance; - - @Mock - private EnvironmentsEngine environmentsEngine; - - @Mock - private DistributionNotificationSender distributionNotificationSender; - - private DummyDistributionConfigurationManager distributionEngineConfigurationMock; - - private Map<String, OperationalEnvironmentEntry> envs; - - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - distributionEngineConfigurationMock = new DummyDistributionConfigurationManager(); - envs = getEnvs(ENV_ID); - } - - @Test - public void notifyService() throws Exception { - NotificationDataImpl notificationData = new NotificationDataImpl(); - Service service = new Service(); - when(environmentsEngine.getEnvironmentById(ENV_ID)).thenReturn(envs.get(ENV_ID)); - when(distributionEngineConfigurationMock.getConfigurationMock().getDistributionNotifTopicName()).thenReturn("topic"); - when(distributionNotificationSender.sendNotification(eq("topic-ENVID"), eq(DISTRIBUTION_ID), any(EnvironmentMessageBusData.class), - any(NotificationDataImpl.class), any(Service.class), eq(USER_ID), eq(MODIFIER))) - .thenReturn(ActionStatus.OK); - ActionStatus actionStatus = testInstance.notifyService(DISTRIBUTION_ID, service, notificationData, ENV_ID, USER_ID, MODIFIER); - assertEquals(ActionStatus.OK, actionStatus); - } - - @Test - public void notifyService_couldNotResolveEnvironment() throws Exception { - when(environmentsEngine.getEnvironments()).thenReturn(envs); - ActionStatus actionStatus = testInstance.notifyService(DISTRIBUTION_ID, new Service(), new NotificationDataImpl(), "someNonExisitngEnv", USER_ID, MODIFIER); - assertEquals(ActionStatus.DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE, actionStatus); - verifyZeroInteractions(distributionNotificationSender); - } - - @Test - public void notifyService_failedWhileSendingNotification() throws Exception { - NotificationDataImpl notificationData = new NotificationDataImpl(); - Service service = new Service(); - when(environmentsEngine.getEnvironmentById(ENV_ID)).thenReturn(envs.get(ENV_ID)); - when(distributionEngineConfigurationMock.getConfigurationMock().getDistributionNotifTopicName()).thenReturn("topic"); - when(distributionNotificationSender.sendNotification(eq("topic-ENVID"), eq(DISTRIBUTION_ID), any(EnvironmentMessageBusData.class), - any(NotificationDataImpl.class), any(Service.class), eq(USER_ID), eq(MODIFIER))) - .thenReturn(ActionStatus.GENERAL_ERROR); - ActionStatus actionStatus = testInstance.notifyService(DISTRIBUTION_ID, service, notificationData, ENV_ID, USER_ID, MODIFIER); - assertEquals(ActionStatus.GENERAL_ERROR, actionStatus); - } - - private Map<String, OperationalEnvironmentEntry> getEnvs(String ... environmentIds) { - Set<String> uebAddress = new HashSet<>(); - uebAddress.add("someAddress"); - return Stream.of(environmentIds) - .map(id -> new OperationalEnvironmentBuilder().setEnvId(id).setDmaapUebAddress(uebAddress).build()) - .collect(Collectors.toMap(OperationalEnvironmentEntry::getEnvironmentId, Function.identity())); - } + // default test + //testSubject = createTestSubject(); + when(serviceDistributionArtifactsBuilder.buildResourceInstanceForDistribution(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(new NotificationDataImpl()); + result = testInstance.buildServiceForDistribution(service, distributionId, workloadContext); + } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionStatusNotificationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionStatusNotificationTest.java new file mode 100644 index 0000000000..2dbec7ac03 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionStatusNotificationTest.java @@ -0,0 +1,156 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import org.junit.Test; + +public class DistributionStatusNotificationTest { + + private DistributionStatusNotification createTestSubject() { + return new DistributionStatusNotification(); + } + + @Test + public void testGetDistributionID() throws Exception { + DistributionStatusNotification testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDistributionID(); + } + + @Test + public void testSetDistributionID() throws Exception { + DistributionStatusNotification testSubject; + String distributionId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDistributionID(distributionId); + } + + @Test + public void testGetConsumerID() throws Exception { + DistributionStatusNotification testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getConsumerID(); + } + + @Test + public void testSetConsumerID() throws Exception { + DistributionStatusNotification testSubject; + String consumerId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setConsumerID(consumerId); + } + + @Test + public void testGetTimestamp() throws Exception { + DistributionStatusNotification testSubject; + long result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getTimestamp(); + } + + @Test + public void testSetTimestamp() throws Exception { + DistributionStatusNotification testSubject; + long timestamp = 4354; + + // default test + testSubject = createTestSubject(); + testSubject.setTimestamp(timestamp); + } + + @Test + public void testGetArtifactURL() throws Exception { + DistributionStatusNotification testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactURL(); + } + + @Test + public void testSetArtifactURL() throws Exception { + DistributionStatusNotification testSubject; + String artifactURL = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactURL(artifactURL); + } + + @Test + public void testGetStatus() throws Exception { + DistributionStatusNotification testSubject; + DistributionStatusNotificationEnum result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getStatus(); + } + + @Test + public void testSetStatus() throws Exception { + DistributionStatusNotification testSubject; + DistributionStatusNotificationEnum status = null; + + // default test + testSubject = createTestSubject(); + testSubject.setStatus(status); + } + + @Test + public void testGetErrorReason() throws Exception { + DistributionStatusNotification testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getErrorReason(); + } + + @Test + public void testSetErrorReason() throws Exception { + DistributionStatusNotification testSubject; + String errorReason = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setErrorReason(errorReason); + } + + @Test + public void testIsDistributionCompleteNotification() throws Exception { + DistributionStatusNotification testSubject; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isDistributionCompleteNotification(); + + testSubject.status = DistributionStatusNotificationEnum.DISTRIBUTION_COMPLETE_OK; + result = testSubject.isDistributionCompleteNotification(); + + testSubject.status = DistributionStatusNotificationEnum.DISTRIBUTION_COMPLETE_ERROR; + result = testSubject.isDistributionCompleteNotification(); + } + + @Test + public void testToString() throws Exception { + DistributionStatusNotification testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapClientFactoryTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapClientFactoryTest.java new file mode 100644 index 0000000000..b27c5b07a6 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapClientFactoryTest.java @@ -0,0 +1,133 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import java.io.File; +import java.security.GeneralSecurityException; +import java.util.Properties; + +import org.junit.Test; +import org.openecomp.sdc.be.config.DmaapConsumerConfiguration; +import org.openecomp.sdc.be.config.DmaapConsumerConfiguration.Credential; + +import com.att.nsa.mr.client.MRConsumer; + +import mockit.Deencapsulation; + +public class DmaapClientFactoryTest { + + private DmaapClientFactory createTestSubject() { + return new DmaapClientFactory(); + } + + @Test + public void testCreate() throws Exception { + DmaapClientFactory testSubject; + DmaapConsumerConfiguration parameters = new DmaapConsumerConfiguration(); + MRConsumer result; + String filePath = "src/test/resources/config/mock.txt"; + + Credential credential = new Credential(); + credential.setPassword("hmXYcznAljMSisdy8zgcag=="); + credential.setUsername("mock"); + parameters.setCredential(credential); + parameters.setLatitude(new Double(32452)); + parameters.setLongitude(new Double(543534)); + parameters.setVersion("mock"); + parameters.setServiceName("mock"); + parameters.setServiceName("mock"); + parameters.setEnvironment("mock"); + parameters.setPartner("mock"); + parameters.setRouteOffer("mock"); + parameters.setProtocol("mock"); + parameters.setContenttype("mock"); + parameters.setHosts("mock"); + parameters.setTopic("mock"); + parameters.setConsumerGroup("mock"); + parameters.setConsumerId("mock"); + parameters.setTimeoutMs(42354); + parameters.setLimit(43534); + parameters.setDme2TraceOn(true); + parameters.setAftEnvironment("mock"); + parameters.setAftDme2ConnectionTimeoutMs(234324); + parameters.setAftDme2RoundtripTimeoutMs(435345); + parameters.setAftDme2ReadTimeoutMs(5645); + parameters.setDme2preferredRouterFilePath(filePath); + + // default test + testSubject = createTestSubject(); + result = testSubject.create(parameters); + File file = new File(filePath); + file.delete(); + + } + + @Test + public void testBuildProperties() throws Exception { + DmaapClientFactory testSubject; + DmaapConsumerConfiguration parameters = new DmaapConsumerConfiguration(); + Properties result; + String filePath = "src/test/resources/config/mock.txt"; + + Credential credential = new Credential(); + credential.setPassword("hmXYcznAljMSisdy8zgcag=="); + credential.setUsername("mock"); + parameters.setCredential(credential); + parameters.setLatitude(new Double(32452)); + parameters.setLongitude(new Double(543534)); + parameters.setVersion("mock"); + parameters.setServiceName("mock"); + parameters.setServiceName("mock"); + parameters.setEnvironment("mock"); + parameters.setPartner("mock"); + parameters.setRouteOffer("mock"); + parameters.setProtocol("mock"); + parameters.setContenttype("mock"); + parameters.setHosts("mock"); + parameters.setTopic("mock"); + parameters.setConsumerGroup("mock"); + parameters.setConsumerId("mock"); + parameters.setTimeoutMs(42354); + parameters.setLimit(43534); + parameters.setDme2TraceOn(true); + parameters.setAftEnvironment("mock"); + parameters.setAftDme2ConnectionTimeoutMs(234324); + parameters.setAftDme2RoundtripTimeoutMs(435345); + parameters.setAftDme2ReadTimeoutMs(5645); + parameters.setDme2preferredRouterFilePath(filePath); + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "buildProperties", parameters); + + File file = new File(filePath); + file.delete(); + } + + @Test(expected = GeneralSecurityException.class) + public void testBuildProperties_2() throws Exception { + DmaapClientFactory testSubject; + DmaapConsumerConfiguration parameters = new DmaapConsumerConfiguration(); + Properties result; + String filePath = "src/test/resources/config/mock.txt"; + + Credential credential = new Credential(); + credential.setPassword("mock"); + parameters.setCredential(credential); + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "buildProperties", parameters); + } + + @Test + public void testEnsureFileExists() throws Exception { + DmaapClientFactory testSubject; + String filePath = "src/test/resources/config/mock.txt"; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "ensureFileExists", new Object[] { filePath }); + Deencapsulation.invoke(testSubject, "ensureFileExists", filePath); + File file = new File(filePath); + file.delete(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumerTest.java new file mode 100644 index 0000000000..b35f337ce5 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumerTest.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import java.lang.Thread.UncaughtExceptionHandler; +import java.util.function.Consumer; + +import org.junit.Test; +import org.openecomp.sdc.be.components.BeConfDependentTest; + +public class DmaapConsumerTest extends BeConfDependentTest{ + + private DmaapConsumer createTestSubject() { + return new DmaapConsumer(new ExecutorFactory(), new DmaapClientFactory()); + } + + @Test + public void testConsumeDmaapTopic() throws Exception { + DmaapConsumer testSubject; + Consumer<String> notificationReceived = null; + UncaughtExceptionHandler exceptionHandler = new UncaughtExceptionHandlerMock(); + + // default test + testSubject = createTestSubject(); + testSubject.consumeDmaapTopic(notificationReceived, exceptionHandler); + } + + private class UncaughtExceptionHandlerMock implements UncaughtExceptionHandler{ + + @Override + public void uncaughtException(Thread t, Throwable e) { + // TODO Auto-generated method stub + + } + + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealthTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealthTest.java new file mode 100644 index 0000000000..1c5199e455 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealthTest.java @@ -0,0 +1,104 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import java.net.URISyntaxException; + +import org.junit.Test; +import org.openecomp.sdc.be.components.BeConfDependentTest; +import org.openecomp.sdc.be.config.DmaapConsumerConfiguration; +import org.openecomp.sdc.common.api.HealthCheckInfo; + +import mockit.Deencapsulation; + +public class DmaapHealthTest extends BeConfDependentTest{ + + private DmaapHealth createTestSubject() { + return new DmaapHealth(); + } + + @Test + public void testInit() throws Exception { + DmaapHealth testSubject; + DmaapHealth result; + + // default test + testSubject = createTestSubject(); + result = testSubject.init(); + } + + @Test + public void testDestroy() throws Exception { + DmaapHealth testSubject; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "destroy"); + } + + @Test + public void testStartHealthCheckTask() throws Exception { + DmaapHealth testSubject; + boolean startTask = false; + + // default test + testSubject = createTestSubject(); + testSubject.startHealthCheckTask(startTask); + } + + @Test + public void testReport() throws Exception { + DmaapHealth testSubject; + Boolean isUp = false; + + // default test + testSubject = createTestSubject(); + testSubject.report(isUp); + } + + @Test + public void testLogAlarm() throws Exception { + DmaapHealth testSubject; + boolean lastHealthState = false; + + // default test + testSubject = createTestSubject(); + testSubject.logAlarm(lastHealthState); + } + + @Test + public void testGetConfiguration() throws Exception { + DmaapHealth testSubject; + DmaapConsumerConfiguration result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getConfiguration(); + } + + @Test + public void testGetHealthCheckInfo() throws Exception { + DmaapHealth testSubject; + HealthCheckInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getHealthCheckInfo(); + } + + @Test(expected=URISyntaxException.class) + public void testGetUrlHost() throws Exception { + String qualifiedHost = ""; + String result; + + // default test + result = DmaapHealth.getUrlHost(qualifiedHost); + } + + @Test + public void testGetUrlHost_2() throws Exception { + String qualifiedHost = "www.mock.com"; + String result; + + // default test + result = DmaapHealth.getUrlHost(qualifiedHost); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapNotificationDataImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapNotificationDataImplTest.java new file mode 100644 index 0000000000..16d8298fbb --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapNotificationDataImplTest.java @@ -0,0 +1,40 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import org.junit.Test; + +public class DmaapNotificationDataImplTest { + + private DmaapNotificationDataImpl createTestSubject() { + return new DmaapNotificationDataImpl(); + } + + @Test + public void testGetOperationalEnvironmentId() throws Exception { + DmaapNotificationDataImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperationalEnvironmentId(); + } + + @Test + public void testGetOperationalEnvironmentName() throws Exception { + DmaapNotificationDataImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperationalEnvironmentName(); + } + + @Test + public void testGetTenantContext() throws Exception { + DmaapNotificationDataImpl testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getTenantContext(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentMessageBusDataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentMessageBusDataTest.java new file mode 100644 index 0000000000..a0be84479f --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentMessageBusDataTest.java @@ -0,0 +1,121 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import java.util.HashSet; +import java.util.List; + +import org.junit.Test; +import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; + +public class EnvironmentMessageBusDataTest { + + private EnvironmentMessageBusData createTestSubject() { + return new EnvironmentMessageBusData(); + } + + @Test + public void testConstructor() throws Exception { + OperationalEnvironmentEntry operationalEnvironment = new OperationalEnvironmentEntry(); + operationalEnvironment.setDmaapUebAddress(new HashSet<>()); + new EnvironmentMessageBusData(operationalEnvironment); + } + + @Test + public void testGetTenant() throws Exception { + EnvironmentMessageBusData testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getTenant(); + } + + @Test + public void testSetTenant() throws Exception { + EnvironmentMessageBusData testSubject; + String tenant = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setTenant(tenant); + } + + @Test + public void testGetDmaaPuebEndpoints() throws Exception { + EnvironmentMessageBusData testSubject; + List<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDmaaPuebEndpoints(); + } + + @Test + public void testSetDmaaPuebEndpoints() throws Exception { + EnvironmentMessageBusData testSubject; + List<String> dmaaPuebEndpoints = null; + + // default test + testSubject = createTestSubject(); + testSubject.setDmaaPuebEndpoints(dmaaPuebEndpoints); + } + + @Test + public void testGetUebPublicKey() throws Exception { + EnvironmentMessageBusData testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getUebPublicKey(); + } + + @Test + public void testSetUebPublicKey() throws Exception { + EnvironmentMessageBusData testSubject; + String uebPublicKey = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setUebPublicKey(uebPublicKey); + } + + @Test + public void testGetUebPrivateKey() throws Exception { + EnvironmentMessageBusData testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getUebPrivateKey(); + } + + @Test + public void testSetUebPrivateKey() throws Exception { + EnvironmentMessageBusData testSubject; + String uebPrivateKey = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setUebPrivateKey(uebPrivateKey); + } + + @Test + public void testGetEnvId() throws Exception { + EnvironmentMessageBusData testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getEnvId(); + } + + @Test + public void testSetEnvId() throws Exception { + EnvironmentMessageBusData testSubject; + String envId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setEnvId(envId); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineMockTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineMockTest.java new file mode 100644 index 0000000000..d239679627 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineMockTest.java @@ -0,0 +1,191 @@ +package org.openecomp.sdc.be.components.distribution.engine; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.apache.http.HttpStatus; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.config.ConfigurationManager; +import org.openecomp.sdc.be.config.DistributionEngineConfiguration; +import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; +import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao; +import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum; +import org.openecomp.sdc.be.info.OperationalEnvInfo; +import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; +import org.openecomp.sdc.common.http.client.api.HttpResponse; + +import fj.data.Either; + +@RunWith(value = MockitoJUnitRunner.class) +public class EnvironmentsEngineMockTest { + + @InjectMocks + private EnvironmentsEngine envEngine; + @Mock + private DmaapConsumer dmaapConsumer; + @Mock + private OperationalEnvironmentDao operationalEnvironmentDao; + @Mock + private DME2EndpointIteratorCreator epIterCreator; + @Mock + private ConfigurationManager configurationManager; + @Mock + private DistributionEngineConfiguration distributionEngineConfiguration; + @Mock + private AaiRequestHandler aaiRequestHandler; + + @Before + public void preStart() { + when(configurationManager.getDistributionEngineConfiguration()).thenReturn(distributionEngineConfiguration); + envEngine.setConfigurationManager(configurationManager); + } + + @Test + public void testInit() { + List<OperationalEnvironmentEntry> entryList = Arrays.asList(createOpEnvEntry("Env1"), createOpEnvEntry("Env2")); + Either<List<OperationalEnvironmentEntry>, CassandraOperationStatus> successEither = Either.left(entryList); + when(operationalEnvironmentDao.getByEnvironmentsStatus(EnvironmentStatusEnum.COMPLETED)).thenReturn(successEither); + + when(distributionEngineConfiguration.getEnvironments()).thenReturn(Arrays.asList("Env Loaded From Configuration")); + when(distributionEngineConfiguration.getUebPublicKey()).thenReturn("Dummy Public Key"); + when(distributionEngineConfiguration.getUebSecretKey()).thenReturn("Dummy Private Key"); + when(distributionEngineConfiguration.getUebServers()).thenReturn( + Arrays.asList("uebsb91kcdc.it.att.com:3904", "uebsb92kcdc.it.att.com:3904", "uebsb91kcdc.it.att.com:3904")); + + envEngine.init(); + + Map<String, OperationalEnvironmentEntry> mapEnvs = envEngine.getEnvironments(); + assertEquals("unexpected size of map",3, mapEnvs.size()); + } + + + @Test + public void testGetFullOperationalEnvByIdSuccess() { + String json = getFullOperationalEnvJson(); + + HttpResponse<String> restResponse = new HttpResponse<String>(json, HttpStatus.SC_OK, "Successfully completed"); + when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse); + + Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId"); + assertTrue("The operational environment request ran as not expected", response.isLeft()); + + OperationalEnvInfo operationalEnvInfo = response.left().value(); + + assertEquals("The operational environment json is not as expected", operationalEnvInfo.toString(), json); + } + + @Test + public void testGetPartialOperationalEnvByIdSuccess() { + String json = getPartialOperationalEnvJson(); + + HttpResponse<String> restResponse = new HttpResponse<String>(json, HttpStatus.SC_OK, "Successfully completed"); + when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse); + + Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId"); + assertTrue("The operational environment request ran as not expected", response.isLeft()); + + OperationalEnvInfo operationalEnvInfo = response.left().value(); + + assertEquals("The operational environment json is not as expected", operationalEnvInfo.toString(), json); + } + + + @Test + public void testGetOperationalEnvByIdFailedByJsonConvert() { + String jsonCorrupted = getCorruptedOperationalEnvJson(); + + HttpResponse<String> restResponse = new HttpResponse<String>(jsonCorrupted, HttpStatus.SC_OK, "Successfully Completed"); + when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse); + + Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId"); + assertTrue("The operational environment request ran as not expected", response.isRight()); + assertEquals("The operational environment request status code is not as expected", (Integer)HttpStatus.SC_INTERNAL_SERVER_ERROR, response.right().value()); + } + + @Test + public void testGetOperationalEnvByIdFailed404() { + String json = getFullOperationalEnvJson(); + HttpResponse<String> restResponse = new HttpResponse<String>(json, HttpStatus.SC_NOT_FOUND, "Not Found"); + when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse); + + Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId"); + assertTrue("The operational environment request ran as not expected", response.isRight()); + assertEquals("The operational environment request status code is not as expected", (Integer)HttpStatus.SC_NOT_FOUND, response.right().value()); + } + + + @Test(expected = IOException.class) + public void testCorruptedOperationalEnvJson() throws IOException { + String jsonCorrupted = getCorruptedOperationalEnvJson(); + OperationalEnvInfo.createFromJson(jsonCorrupted); + } + + private String getCorruptedOperationalEnvJson() { + return "{\"OPERATIONAL-environment-name\":\"Op Env Name\"," + + "\"OPERATIONAL-environment-type\":\"VNF\"," + + "\"OPERATIONAL-environment-status\":\"Activate\"," + + "\"tenant-context\":\"Test\"}"; + } + + private String getPartialOperationalEnvJson() { + return "{" + + "\"operational-environment-id\":\"UUID of Operational Environment\"," + + "\"operational-environment-name\":\"Op Env Name\"," + + "\"operational-environment-type\":\"VNF\"," + + "\"operational-environment-status\":\"Activate\"," + + "\"tenant-context\":\"Test\"," + + "\"workload-context\":\"VNF_Development\"," + + "\"resource-version\":\"1505228226913\"," + + "\"relationship-list\":{" + + "\"relationship\":[]" + + "}" + + "}"; + } + + private String getFullOperationalEnvJson() { + return "{" + + "\"operational-environment-id\":\"OEid1\"," + + "\"operational-environment-name\":\"OEname1\"," + + "\"operational-environment-type\":\"OEtype1\"," + + "\"operational-environment-status\":\"OEstatus1\"," + + "\"tenant-context\":\"OEtenantcontext1\"," + + "\"workload-context\":\"OEworkloadcontext1\"," + + "\"resource-version\":\"1511363173278\"," + + "\"relationship-list\":{" + + "\"relationship\":[" + + "{" + + "\"related-to\":\"operational-environment\"," + + "\"relationship-label\":\"managedBy\"," + + "\"related-link\":\"/aai/v12/cloud-infrastructure/operational-environments/operational-environment/OEid3\"," + + "\"relationship-data\":[" + + "{" + + "\"relationship-key\":\"operational-environment.operational-environment-id\"," + + "\"relationship-value\":\"OEid3\"" + + "}" + + "]," + + "\"related-to-property\":[" + + "{" + + "\"property-key\":\"operational-environment.operational-environment-name\"," + + "\"property-value\":\"OEname3\"" + + "}]}]}}"; + } + + private OperationalEnvironmentEntry createOpEnvEntry(String name) { + OperationalEnvironmentEntry entry = new OperationalEnvironmentEntry(); + entry.setEnvironmentId(name); + return entry; + } + +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ServiceDistributionArtifactsBuilderTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ServiceDistributionArtifactsBuilderTest.java index 9b196e55ef..0c1f3a7513 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ServiceDistributionArtifactsBuilderTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ServiceDistributionArtifactsBuilderTest.java @@ -1,11 +1,6 @@ package org.openecomp.sdc.be.components.distribution.engine; -import javax.annotation.Generated; - -import org.junit.Assert; import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/StepsTenantIsolation.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/StepsTenantIsolation.java index 1a2ca4840d..31da6e8698 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/StepsTenantIsolation.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/StepsTenantIsolation.java @@ -1,15 +1,11 @@ package org.openecomp.sdc.be.components.distribution.engine; -import com.att.aft.dme2.api.DME2Exception; -import com.att.aft.dme2.iterator.DME2EndpointIterator; -import com.att.nsa.apiClient.credentials.ApiCredential; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import cucumber.api.java.Before; -import cucumber.api.java.en.Given; -import cucumber.api.java.en.Then; -import cucumber.api.java.en.When; -import fj.data.Either; +import static java.util.Objects.isNull; +import static org.apache.commons.lang3.StringUtils.isEmpty; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import org.apache.commons.lang.NotImplementedException; import org.apache.commons.lang.math.NumberUtils; import org.apache.http.HttpStatus; @@ -28,11 +24,17 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.common.http.client.api.HttpResponse; -import static java.util.Objects.isNull; -import static org.apache.commons.lang3.StringUtils.isEmpty; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import com.att.aft.dme2.api.DME2Exception; +import com.att.aft.dme2.iterator.DME2EndpointIterator; +import com.att.nsa.apiClient.credentials.ApiCredential; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import cucumber.api.java.Before; +import cucumber.api.java.en.Given; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import fj.data.Either; public class StepsTenantIsolation { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/rest/MsoRestClientTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/rest/MsoRestClientTest.java index 9d0e8cd683..fdf2ebf7ab 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/rest/MsoRestClientTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/rest/MsoRestClientTest.java @@ -1,10 +1,16 @@ package org.openecomp.sdc.be.components.distribution.engine.rest; -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.github.tomakehurst.wiremock.matching.AnythingPattern; -import com.github.tomakehurst.wiremock.matching.UrlPattern; -import fj.data.Either; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.patchRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + import org.apache.http.HttpHeaders; import org.junit.Before; import org.junit.ClassRule; @@ -13,13 +19,19 @@ import org.openecomp.sdc.be.components.distribution.engine.DistributionStatusNot import org.openecomp.sdc.be.components.distribution.engine.DummyDistributionConfigurationManager; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.common.http.client.api.HttpResponse; -import org.openecomp.sdc.common.http.config.*; +import org.openecomp.sdc.common.http.config.BasicAuthorization; +import org.openecomp.sdc.common.http.config.ExternalServiceConfig; +import org.openecomp.sdc.common.http.config.HttpClientConfig; +import org.openecomp.sdc.common.http.config.HttpRequestConfig; +import org.openecomp.sdc.common.http.config.Timeouts; import org.openecomp.sdc.security.SecurityUtil; -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; +import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.github.tomakehurst.wiremock.matching.AnythingPattern; +import com.github.tomakehurst.wiremock.matching.UrlPattern; + +import fj.data.Either; public class MsoRestClientTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java index 5c8b90544e..c7b55f2eef 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogicTest.java @@ -1,11 +1,10 @@ package org.openecomp.sdc.be.components.health; -import static org.junit.Assert.*; -import java.util.*; +import java.util.List; + import org.junit.Assert; import org.junit.Test; import org.openecomp.sdc.common.api.HealthCheckInfo; -import org.apache.commons.lang3.tuple.Pair; public class HealthCheckBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java index a7529ed614..ea4df1e4ad 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogicTest.java @@ -1,19 +1,12 @@ package org.openecomp.sdc.be.components.impl; -import java.util.List; - -import javax.servlet.ServletContext; - import org.junit.Test; import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.AdditionalInformationDefinition; -import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.exception.ResponseFormat; import fj.data.Either; -import java.util.*; -import org.junit.Assert; public class AdditionalInformationBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java index 4ce0740887..a9140f5b21 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java @@ -20,14 +20,26 @@ package org.openecomp.sdc.be.components.impl; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -72,25 +84,15 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; +import fj.data.Either; public class ArtifactBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java index dc89156ee9..fa0366fbef 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java @@ -20,6 +20,13 @@ package org.openecomp.sdc.be.components.impl; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; @@ -30,13 +37,6 @@ import org.openecomp.sdc.be.model.Operation; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - public class ArtifactResolverTest { private ArtifactResolverImpl testInstance = new ArtifactResolverImpl(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java index 9b2fb3773b..9f5fdb8d8f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java @@ -20,7 +20,17 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -36,16 +46,7 @@ import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation; import org.openecomp.sdc.common.util.CapabilityTypeNameEnum; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class CapabilityTypeImportManagerTest { @InjectMocks diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java index 8a07e26161..353a6feb86 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CategoriesImportManagerTest.java @@ -20,7 +20,16 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -37,15 +46,7 @@ import org.openecomp.sdc.be.model.category.SubCategoryDefinition; import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class CategoriesImportManagerTest { @InjectMocks diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java index d406244551..011324c6f3 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java @@ -17,7 +17,6 @@ import java.util.function.BiPredicate; import org.assertj.core.util.Lists; import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; @@ -32,7 +31,6 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.impl.ServletUtils; -import org.openecomp.sdc.be.info.CreateAndAssotiateInfo; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; import org.openecomp.sdc.be.model.Component; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentsUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentsUtilsTest.java index a9245d2897..7ecd069448 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentsUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentsUtilsTest.java @@ -1,35 +1,5 @@ package org.openecomp.sdc.be.components.impl; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.openecomp.sdc.be.auditing.api.AuditEventFactory; -import org.openecomp.sdc.be.auditing.impl.AuditBaseEventFactory; -import org.openecomp.sdc.be.auditing.impl.AuditingManager; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.impl.ComponentsUtils; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.resources.data.auditing.DistributionDownloadEvent; -import org.openecomp.sdc.be.resources.data.auditing.EcompOperationalEnvironmentEvent; -import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent; -import org.openecomp.sdc.be.resources.data.auditing.UserAdminEvent; -import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; -import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; -import org.openecomp.sdc.common.util.ThreadLocalsHolder; -import org.openecomp.sdc.exception.ResponseFormat; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -70,6 +40,36 @@ import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_FIRST_NAME; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_ID; import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_LAST_NAME; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.auditing.api.AuditEventFactory; +import org.openecomp.sdc.be.auditing.impl.AuditBaseEventFactory; +import org.openecomp.sdc.be.auditing.impl.AuditingManager; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.be.impl.ComponentsUtils; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; +import org.openecomp.sdc.be.resources.data.auditing.DistributionDownloadEvent; +import org.openecomp.sdc.be.resources.data.auditing.EcompOperationalEnvironmentEvent; +import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent; +import org.openecomp.sdc.be.resources.data.auditing.UserAdminEvent; +import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; +import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.openecomp.sdc.exception.ResponseFormat; + @RunWith(MockitoJUnitRunner.class) public class ComponentsUtilsTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java index 7b37b0e96a..5797516938 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogicTest.java @@ -20,13 +20,7 @@ package org.openecomp.sdc.be.components.impl; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.junit.Test; -import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.unittests.utils.FactoryUtils; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.HashMap; @@ -35,7 +29,13 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import static org.junit.Assert.assertTrue; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.junit.Test; +import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.unittests.utils.FactoryUtils; public class CompositionBusinessLogicTest { CompositionBusinessLogic compBl = new CompositionBusinessLogic(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java index d91fa7995b..3c283ac3e8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CsarValidationUtilsTest.java @@ -20,11 +20,11 @@ package org.openecomp.sdc.be.components.impl; +import java.util.Arrays; + import org.junit.Assert; import org.junit.Test; -import java.util.Arrays; - public class CsarValidationUtilsTest { private String[] invalidExtensions = { null, ".bla", ".yaml", ".yml", ".txt", ".zip" }; private String[] validExtensions = { ".csar", ".cSAr", ".Csar", ".CSAR" }; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java index 46ee852aa0..f81e1444cc 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java @@ -1,6 +1,13 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.Test; @@ -30,13 +37,7 @@ import org.openecomp.sdc.be.resources.data.ServiceMetadataData; import org.openecomp.sdc.be.resources.data.category.CategoryData; import org.openecomp.sdc.common.util.ValidationUtils; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; /** * Created by chaya on 12/7/2017. diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java index b65e77c57f..8597136b3f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java @@ -20,17 +20,10 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; -import org.junit.Test; -import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum; -import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum; -import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum; -import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; -import org.openecomp.sdc.be.model.HeatParameterDefinition; -import org.openecomp.sdc.be.model.PropertyDefinition; -import org.openecomp.sdc.common.api.ArtifactTypeEnum; -import org.yaml.snakeyaml.Yaml; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.nio.file.FileSystems; @@ -42,10 +35,18 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum; +import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum; +import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; +import org.openecomp.sdc.be.model.HeatParameterDefinition; +import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.common.api.ArtifactTypeEnum; +import org.yaml.snakeyaml.Yaml; + +import fj.data.Either; public class ImportUtilsTest { @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java index 068f04aae2..f2c53f47c7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java @@ -20,7 +20,18 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -39,17 +50,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.user.IUserBusinessLogic; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; public class InputsBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java index e726f608f5..97eeef99c4 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java @@ -20,7 +20,15 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -35,14 +43,7 @@ import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class InterfaceLifecycleTypeImportManagerTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java index bde1bbb3a1..5a7d8af394 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java @@ -16,7 +16,25 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyCollection; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.servlet.ServletContext; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -67,23 +85,7 @@ import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.mockito.ArgumentMatchers.anyCollection; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyObject; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; public class InterfaceOperationBusinessLogicTest implements InterfaceOperationTestUtils{ diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java index 9aca92010e..f9c0a2fc3d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java @@ -1,7 +1,21 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.assertj.core.api.Java6Assertions.assertThat; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -44,20 +58,7 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Java6Assertions.assertThat; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class PolicyBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java index ad3e6e8974..dd92a0c495 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyPropertiesBusinessLogicTest.java @@ -1,6 +1,15 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; + +import javax.ws.rs.core.Response; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -28,14 +37,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.exception.ResponseFormat; -import javax.ws.rs.core.Response; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class PolicyPropertiesBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java index 7dc12d96e6..009876ec31 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyTypeBusinessLogicTest.java @@ -1,7 +1,18 @@ package org.openecomp.sdc.be.components.impl; -import com.google.common.collect.ImmutableMap; -import fj.data.Either; +import static com.google.common.collect.Sets.newHashSet; +import static java.util.Collections.emptyList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -21,18 +32,9 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.PolicyTypeOperation; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Arrays; -import java.util.List; -import java.util.Set; +import com.google.common.collect.ImmutableMap; -import static com.google.common.collect.Sets.newHashSet; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class PolicyTypeBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index 75aa10aa64..6d4d7a0889 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -20,7 +20,27 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.servlet.ServletContext; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.Ignore; @@ -40,8 +60,6 @@ import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.jsongraph.TitanDao; import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; -import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; @@ -51,10 +69,8 @@ import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.InputDefinition; -import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.LifeCycleTransitionEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Operation; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; @@ -90,27 +106,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyCollection; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ResourceBusinessLogicTest implements InterfaceOperationTestUtils{ diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java index 3abf711b91..0c88a37f2b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java @@ -20,7 +20,16 @@ package org.openecomp.sdc.be.components.impl; -import fj.data.Either; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -53,15 +62,7 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class ResourceInstanceBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java index 5f4dfdc6f7..309689af45 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java @@ -1,6 +1,12 @@ package org.openecomp.sdc.be.components.impl.generic; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -14,12 +20,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class GenericTypeBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtilsTest.java index 6b1b37e5bc..8fd262d1f2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/PolicyTypeImportUtilsTest.java @@ -1,6 +1,12 @@ package org.openecomp.sdc.be.components.impl.utils; -import com.google.common.collect.ImmutableMap; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.junit.Test; import org.openecomp.sdc.be.components.utils.PolicyTypeBuilder; import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder; @@ -9,12 +15,7 @@ import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint; import org.openecomp.sdc.be.model.tosca.constraints.MinLengthConstraint; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; +import com.google.common.collect.ImmutableMap; public class PolicyTypeImportUtilsTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/GroupMembersUpdateOperationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/GroupMembersUpdateOperationTest.java index fe6071239e..6d7ae39cc2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/GroupMembersUpdateOperationTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/GroupMembersUpdateOperationTest.java @@ -1,6 +1,14 @@ package org.openecomp.sdc.be.components.impl.version; -import fj.data.Either; +import static java.util.Collections.emptyMap; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -22,14 +30,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.GroupsOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import static java.util.Collections.emptyMap; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class GroupMembersUpdateOperationTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/PolicyTargetsUpdateOperationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/PolicyTargetsUpdateOperationTest.java index 0da59d1157..5da782e484 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/PolicyTargetsUpdateOperationTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/PolicyTargetsUpdateOperationTest.java @@ -1,5 +1,15 @@ package org.openecomp.sdc.be.components.impl.version; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.components.impl.utils.TestGenerationUtils.getComponentsUtils; + +import java.util.List; +import java.util.stream.Stream; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,16 +28,6 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import java.util.List; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.components.impl.utils.TestGenerationUtils.getComponentsUtils; - @RunWith(MockitoJUnitRunner.class) public class PolicyTargetsUpdateOperationTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/PostChangeVersionOperationOrchestratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/PostChangeVersionOperationOrchestratorTest.java index ef239f9a2b..c6fea4af6f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/PostChangeVersionOperationOrchestratorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/version/PostChangeVersionOperationOrchestratorTest.java @@ -1,5 +1,10 @@ package org.openecomp.sdc.be.components.impl.version; +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -9,11 +14,6 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - @RunWith(MockitoJUnitRunner.class) public class PostChangeVersionOperationOrchestratorTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java index cfb5bb59e0..80f63e71e9 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTest.java @@ -20,7 +20,9 @@ package org.openecomp.sdc.be.components.lifecycle; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -32,8 +34,7 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class CertificationChangeTransitionTest extends LifecycleTestBase { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java index f9fb9c83c1..495483a857 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java @@ -20,7 +20,13 @@ package org.openecomp.sdc.be.components.lifecycle; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; @@ -48,12 +54,7 @@ import org.openecomp.sdc.be.tosca.ToscaExportHandler; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.Silent.class) public class CertificationRequestTest extends LifecycleTestBase { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java index e60998b177..457a3363a0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java @@ -20,7 +20,9 @@ package org.openecomp.sdc.be.components.lifecycle; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -32,8 +34,7 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class CheckinTest extends LifecycleTestBase { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java index 0826e5d40c..14cbcc80d7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java @@ -20,7 +20,9 @@ package org.openecomp.sdc.be.components.lifecycle; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -34,8 +36,7 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class CheckoutTest extends LifecycleTestBase { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java index 941af0d728..d2903f5f11 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java @@ -20,7 +20,13 @@ package org.openecomp.sdc.be.components.lifecycle; -import fj.data.Either; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.ServletContext; + import org.junit.BeforeClass; import org.mockito.InjectMocks; import org.mockito.Mockito; @@ -61,11 +67,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import java.util.ArrayList; -import java.util.List; - -import static org.mockito.Mockito.when; +import fj.data.Either; public class LifecycleTestBase { private static final Logger log = LoggerFactory.getLogger(LifecycleTestBase.class); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java index d5d665809d..6ef2e8604e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java @@ -20,7 +20,9 @@ package org.openecomp.sdc.be.components.lifecycle; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -31,8 +33,7 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class UndoCheckoutTest extends LifecycleTestBase { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalInputsFilteringBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalInputsFilteringBusinessLogicTest.java index 89b82b91d2..ab2e865ae0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalInputsFilteringBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalInputsFilteringBusinessLogicTest.java @@ -1,7 +1,14 @@ package org.openecomp.sdc.be.components.merge; -import com.google.common.collect.Sets; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -17,14 +24,9 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; +import com.google.common.collect.Sets; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; public class GlobalInputsFilteringBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalTypesMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalTypesMergeBusinessLogicTest.java index ec741b4953..a00b0b8e8a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalTypesMergeBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/GlobalTypesMergeBusinessLogicTest.java @@ -1,6 +1,13 @@ package org.openecomp.sdc.be.components.merge; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.components.utils.ObjectGenerator.buildResourceWithInputs; + +import java.util.Arrays; +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -11,13 +18,7 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.Resource; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.components.utils.ObjectGenerator.buildResourceWithInputs; +import fj.data.Either; public class GlobalTypesMergeBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/RelationsComparatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/RelationsComparatorTest.java index d50f4859db..743d394c62 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/RelationsComparatorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/RelationsComparatorTest.java @@ -1,5 +1,10 @@ package org.openecomp.sdc.be.components.merge; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.components.utils.ComponentInstanceBuilder; @@ -9,11 +14,6 @@ import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; import org.openecomp.sdc.be.model.Resource; -import java.util.Arrays; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class RelationsComparatorTest { public static final String INSTANCE1 = "instance1"; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/TopologyComparatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/TopologyComparatorTest.java index 298a4454b3..3b1ed52550 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/TopologyComparatorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/TopologyComparatorTest.java @@ -1,6 +1,10 @@ package org.openecomp.sdc.be.components.merge; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -16,10 +20,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class TopologyComparatorTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/capability/SimpleCapabilityResolverTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/capability/SimpleCapabilityResolverTest.java index be9f426c2c..8071749fdf 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/capability/SimpleCapabilityResolverTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/capability/SimpleCapabilityResolverTest.java @@ -1,6 +1,12 @@ package org.openecomp.sdc.be.components.merge.capability; -import com.google.common.collect.ImmutableMap; +import static java.util.Arrays.asList; +import static java.util.Collections.emptyMap; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -15,12 +21,7 @@ import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; -import java.util.Map; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyMap; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; +import com.google.common.collect.ImmutableMap; @RunWith(MockitoJUnitRunner.class) public class SimpleCapabilityResolverTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/heat/HeatEnvArtifactsMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/heat/HeatEnvArtifactsMergeBusinessLogicTest.java index c75a6ccd5d..bcdd08e95b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/heat/HeatEnvArtifactsMergeBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/heat/HeatEnvArtifactsMergeBusinessLogicTest.java @@ -1,5 +1,12 @@ package org.openecomp.sdc.be.components.merge.heat; +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Stream; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.components.utils.ArtifactBuilder; @@ -8,13 +15,6 @@ import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.HeatParameterDefinition; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Stream; - -import static org.junit.Assert.assertEquals; - public class HeatEnvArtifactsMergeBusinessLogicTest { private HeatEnvArtifactsMergeBusinessLogic testInstance; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java index 30801b0a4a..26b6782918 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java @@ -1,6 +1,14 @@ package org.openecomp.sdc.be.components.merge.input; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + import org.apache.commons.collections.ListUtils; import org.junit.Before; import org.junit.Test; @@ -14,14 +22,7 @@ import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ComponentInputsMergeBLTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogicTest.java index 98fceab7a8..d593e6ffd0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogicTest.java @@ -1,5 +1,13 @@ package org.openecomp.sdc.be.components.merge.input; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder; @@ -11,14 +19,6 @@ import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.Resource; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - public class InputsValuesMergingBusinessLogicTest { public static final String INPUT_DEFUALT_TYPE = "string"; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java index df3e0ddb68..be16bc3621 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java @@ -1,5 +1,10 @@ package org.openecomp.sdc.be.components.merge.instance; +import static junit.framework.TestCase.assertEquals; + +import java.util.HashMap; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -9,11 +14,6 @@ import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; -import java.util.HashMap; -import java.util.Map; - -import static groovy.util.GroovyTestCase.assertEquals; - public class ComponentInstanceArtifactsMergeTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabiliteisPropertiesMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabiliteisPropertiesMergeTest.java index 4fbb1ab5d7..70d4b87b9f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabiliteisPropertiesMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabiliteisPropertiesMergeTest.java @@ -1,6 +1,11 @@ package org.openecomp.sdc.be.components.merge.instance; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.Collections; +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -16,11 +21,7 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class ComponentInstanceCapabiliteisPropertiesMergeTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabilitiesMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabilitiesMergeBLTest.java index d73459c1b1..adf19011db 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabilitiesMergeBLTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceCapabilitiesMergeBLTest.java @@ -1,7 +1,21 @@ package org.openecomp.sdc.be.components.merge.instance; -import com.google.common.collect.ImmutableMap; -import fj.data.Either; +import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,21 +45,9 @@ import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import com.google.common.collect.ImmutableMap; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class ComponentInstanceCapabilitiesMergeBLTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java index 115825733e..f5cd924957 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java @@ -1,6 +1,13 @@ package org.openecomp.sdc.be.components.merge.instance; -import fj.data.Either; +import static org.mockito.Mockito.when; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -19,13 +26,7 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.mockito.Mockito.when; +import fj.data.Either; public class ComponentInstanceHeatEnvMergeTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogicTest.java index 630a43ef2d..79064bce50 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogicTest.java @@ -1,6 +1,13 @@ package org.openecomp.sdc.be.components.merge.instance; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.Arrays; + import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -22,13 +29,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ComponentInstanceMergeDataBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java index d946206f23..0efbf5fc5b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java @@ -1,6 +1,16 @@ package org.openecomp.sdc.be.components.merge.instance; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyListOf; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -25,16 +35,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ComponentInstancePropsAndInputsMergeTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java index 08c8456064..b341052d9e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java @@ -1,6 +1,18 @@ package org.openecomp.sdc.be.components.merge.instance; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.IntStream; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,18 +38,7 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.stream.IntStream; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class ComponentInstanceRelationMergeTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/path/ComponentInstanceForwardingPathMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/path/ComponentInstanceForwardingPathMergeTest.java index 65ab3ec121..972ea4e620 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/path/ComponentInstanceForwardingPathMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/path/ComponentInstanceForwardingPathMergeTest.java @@ -1,6 +1,15 @@ package org.openecomp.sdc.be.components.merge.path; -import fj.data.Either; +import static groovy.util.GroovyTestCase.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.when; + +import java.util.Set; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -17,14 +26,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.common.api.UserRoleEnum; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Set; - -import static groovy.util.GroovyTestCase.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.TestCase.assertTrue; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ComponentInstanceForwardingPathMergeTest extends BaseForwardingPathVersionChangeTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstanceInputsMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstanceInputsMergeBLTest.java index bbb2dd6895..bb1ea68cbd 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstanceInputsMergeBLTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstanceInputsMergeBLTest.java @@ -1,6 +1,13 @@ package org.openecomp.sdc.be.components.merge.property; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.util.Collections; +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -17,13 +24,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ComponentInstanceInputsMergeBLTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstancePropertiesMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstancePropertiesMergeBLTest.java index 6013009106..e5ca990b7e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstancePropertiesMergeBLTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/ComponentInstancePropertiesMergeBLTest.java @@ -1,6 +1,13 @@ package org.openecomp.sdc.be.components.merge.property; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.util.Collections; +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -15,13 +22,7 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ComponentInstancePropertiesMergeBLTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/DataDefinitionsValuesMergingBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/DataDefinitionsValuesMergingBusinessLogicTest.java index 3b079d30d5..e310cad300 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/DataDefinitionsValuesMergingBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/DataDefinitionsValuesMergingBusinessLogicTest.java @@ -1,5 +1,11 @@ package org.openecomp.sdc.be.components.merge.property; +import static org.mockito.Mockito.verify; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -11,12 +17,6 @@ import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.model.InputDefinition; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.mockito.Mockito.verify; - public class DataDefinitionsValuesMergingBusinessLogicTest { private static final String DEFAULT_PROP_TYPE = "string"; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java index 5c23ec0e8c..6faee487f4 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java @@ -1,6 +1,17 @@ package org.openecomp.sdc.be.components.merge.property; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -14,17 +25,7 @@ import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class PropertyDataValueMergeBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java index 0590c7e500..a43e1e68ca 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/resource/ResourceDataMergeBusinessLogicTest.java @@ -1,5 +1,12 @@ package org.openecomp.sdc.be.components.merge.resource; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.Arrays; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -11,13 +18,6 @@ import org.openecomp.sdc.be.components.utils.ObjectGenerator; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.model.Resource; -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - @RunWith(MockitoJUnitRunner.class) public class ResourceDataMergeBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/utils/MergeInstanceUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/utils/MergeInstanceUtilsTest.java index 3131c4987c..9d07be276b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/utils/MergeInstanceUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/utils/MergeInstanceUtilsTest.java @@ -1,6 +1,13 @@ package org.openecomp.sdc.be.components.merge.utils; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -15,13 +22,7 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) public class MergeInstanceUtilsTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java index 44f87bb352..1182136d6c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java @@ -1,7 +1,12 @@ package org.openecomp.sdc.be.components.path; -import com.google.common.collect.Lists; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + import org.junit.Before; import org.openecomp.sdc.be.components.BeConfDependentTest; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; @@ -35,12 +40,9 @@ import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import com.google.common.collect.Lists; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class BaseForwardingPathTest extends BeConfDependentTest implements ForwardingPathTestUtils { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathVersionChangeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathVersionChangeTest.java index 0e56680728..4b1dc80369 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathVersionChangeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathVersionChangeTest.java @@ -1,6 +1,10 @@ package org.openecomp.sdc.be.components.path; -import com.google.common.collect.Lists; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.openecomp.sdc.be.components.merge.instance.DataForMergeHolder; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; @@ -13,10 +17,7 @@ import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.google.common.collect.Lists; public abstract class BaseForwardingPathVersionChangeTest { protected Service service; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBussinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBussinessLogicTest.java index 03bbc31aef..7e797fe485 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBussinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBussinessLogicTest.java @@ -1,9 +1,14 @@ package org.openecomp.sdc.be.components.path; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import org.junit.Test; import org.junit.runner.RunWith; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; @@ -16,13 +21,10 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import fj.data.Either; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/paths/path-context.xml") diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathChangeVersionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathChangeVersionTest.java index 5af94d7938..4b36a98ae7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathChangeVersionTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathChangeVersionTest.java @@ -1,16 +1,16 @@ package org.openecomp.sdc.be.components.path; -import org.javatuples.Pair; -import org.junit.Test; -import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; -import org.openecomp.sdc.be.impl.ForwardingPathUtils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.util.HashMap; import java.util.Map; import java.util.Set; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.javatuples.Pair; +import org.junit.Test; +import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; +import org.openecomp.sdc.be.impl.ForwardingPathUtils; public class ForwardingPathChangeVersionTest extends BaseForwardingPathVersionChangeTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathDeleteCITest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathDeleteCITest.java index e5de493cb1..f6edc45c9d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathDeleteCITest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathDeleteCITest.java @@ -1,5 +1,14 @@ package org.openecomp.sdc.be.components.path; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; @@ -8,15 +17,6 @@ import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.impl.ForwardingPathUtils; import org.openecomp.sdc.be.model.Service; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - public class ForwardingPathDeleteCITest { private Service service; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathToscaUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathToscaUtilTest.java index e7100a4a7e..e92dd8dbdb 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathToscaUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathToscaUtilTest.java @@ -1,5 +1,19 @@ package org.openecomp.sdc.be.components.path; +import static org.junit.Assert.assertEquals; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.FORWARDER; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.FORWARDS_TO_TOSCA_NAME; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.PORTS_RANGE; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.PROTOCOL; +import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.addForwardingPaths; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -17,20 +31,6 @@ import org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.FORWARDER; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.FORWARDS_TO_TOSCA_NAME; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.PORTS_RANGE; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.PROTOCOL; -import static org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil.addForwardingPaths; - /** * @author KATYR, ORENK * @since November 19, 2017 diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java index fd9e25f475..daa342b2ad 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java @@ -1,8 +1,13 @@ package org.openecomp.sdc.be.components.path; -import com.google.common.collect.Sets; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.util.Collection; +import java.util.Set; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -18,12 +23,9 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Collection; -import java.util.Set; +import com.google.common.collect.Sets; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ForwardingPathValidatorTest implements ForwardingPathTestUtils { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java index 290ba07883..6bbc2bcfcf 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ArtifactCassandraDaoMock.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.path.beans; +import javax.annotation.PostConstruct; + import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; - @Component("artifact-cassandra-dao") public class ArtifactCassandraDaoMock extends ArtifactCassandraDao { @PostConstruct diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java index c4885e1f07..a56346cb00 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/AuditCassandraDaoMock.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.path.beans; +import javax.annotation.PostConstruct; + import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; - @Component("audit-cassandra-dao") public class AuditCassandraDaoMock extends AuditCassandraDao{ diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/CassandraClientMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/CassandraClientMock.java index 0d4b2f1e7e..416f5d814a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/CassandraClientMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/CassandraClientMock.java @@ -1,13 +1,15 @@ package org.openecomp.sdc.be.components.path.beans; -import com.datastax.driver.core.Session; -import com.datastax.driver.mapping.MappingManager; -import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.dao.cassandra.CassandraClient; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; import org.springframework.stereotype.Component; +import com.datastax.driver.core.Session; +import com.datastax.driver.mapping.MappingManager; + +import fj.data.Either; + @Component("cassandra-client") public class CassandraClientMock extends CassandraClient{ public CassandraClientMock() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java index 6a9731e86d..15673e28bf 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ComponentCassandraDaoMock.java @@ -1,6 +1,11 @@ package org.openecomp.sdc.be.components.path.beans; -import fj.data.Either; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.annotation.PostConstruct; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; @@ -9,10 +14,7 @@ import org.openecomp.sdc.be.dao.cassandra.ComponentCassandraDao; import org.openecomp.sdc.be.resources.data.ComponentCacheData; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; -import java.util.List; -import java.util.Map; -import java.util.Set; +import fj.data.Either; @Component("component-cassandra-dao") public class ComponentCassandraDaoMock extends ComponentCassandraDao { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java index 2d7b1ad287..29b8484163 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/EnvironmentCassandraDaoMock.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.path.beans; +import javax.annotation.PostConstruct; + import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; - @Component("operational-environment-dao") public class EnvironmentCassandraDaoMock extends OperationalEnvironmentDao { @PostConstruct diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java index 09e1a72b44..c4cf9fcdd0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java @@ -1,12 +1,13 @@ package org.openecomp.sdc.be.components.path.beans; -import fj.data.Either; import org.openecomp.sdc.be.impl.ForwardingPathUtils; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; +import fj.data.Either; + @org.springframework.stereotype.Component("tosca-operation-facade") public class ForwardingPathToscaOperationFacade extends ToscaOperationFacade { protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service"; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathValidatorMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathValidatorMock.java index 1aa3ab8102..effc35873a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathValidatorMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathValidatorMock.java @@ -1,11 +1,12 @@ package org.openecomp.sdc.be.components.path.beans; -import fj.data.Either; +import java.util.Collection; + import org.openecomp.sdc.be.components.path.ForwardingPathValidator; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Collection; +import fj.data.Either; public class ForwardingPathValidatorMock extends ForwardingPathValidator { @Override diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryTitanGraphClient.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryTitanGraphClient.java index 4e3923d2ea..cb8f3b9cf7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryTitanGraphClient.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryTitanGraphClient.java @@ -1,6 +1,20 @@ package org.openecomp.sdc.be.components.path.beans; +import java.util.ArrayList; +import java.util.HashMap; + +import javax.annotation.PostConstruct; + +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.openecomp.sdc.be.dao.TitanClientStrategy; +import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; +import org.openecomp.sdc.be.dao.titan.TitanGraphClient; +import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + import com.thinkaurelius.titan.core.InvalidElementException; import com.thinkaurelius.titan.core.InvalidIDException; import com.thinkaurelius.titan.core.PropertyKey; @@ -16,19 +30,8 @@ import com.thinkaurelius.titan.core.util.TitanCleanup; import com.thinkaurelius.titan.diskstorage.ResourceUnavailableException; import com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException; import com.thinkaurelius.titan.graphdb.database.idassigner.IDPoolExhaustedException; -import fj.data.Either; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.openecomp.sdc.be.dao.TitanClientStrategy; -import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; -import org.openecomp.sdc.be.dao.titan.TitanGraphClient; -import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; -import java.util.ArrayList; -import java.util.HashMap; +import fj.data.Either; @Component("titan-client") public class InMemoryTitanGraphClient extends TitanGraphClient { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java index 4e0105f067..62d909c1ad 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/SdcSchemaFilesCassandraDaoMock.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.path.beans; +import javax.annotation.PostConstruct; + import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; - @Component("sdc-schema-files-cassandra-dao") public class SdcSchemaFilesCassandraDaoMock extends SdcSchemaFilesCassandraDao { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/TitanGraphTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/TitanGraphTestSetup.java index 7a7eff879a..9c41ff9f8e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/TitanGraphTestSetup.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/TitanGraphTestSetup.java @@ -1,11 +1,9 @@ package org.openecomp.sdc.be.components.path.beans; -import com.thinkaurelius.titan.core.PropertyKey; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanGraphQuery; -import com.thinkaurelius.titan.core.schema.ConsistencyModifier; -import com.thinkaurelius.titan.core.schema.TitanGraphIndex; -import com.thinkaurelius.titan.core.schema.TitanManagement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum; @@ -21,9 +19,12 @@ import org.openecomp.sdc.be.resources.data.UserData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import com.thinkaurelius.titan.core.PropertyKey; +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.TitanGraphQuery; +import com.thinkaurelius.titan.core.schema.ConsistencyModifier; +import com.thinkaurelius.titan.core.schema.TitanGraphIndex; +import com.thinkaurelius.titan.core.schema.TitanManagement; public class TitanGraphTestSetup { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java index 79a1dab517..1ae0898235 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java @@ -20,9 +20,14 @@ package org.openecomp.sdc.be.components.path.utils; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanVertex; -import fj.data.Either; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + import org.apache.tinkerpop.gremlin.structure.io.IoCore; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.jsongraph.TitanDao; @@ -32,13 +37,10 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.TitanVertex; + +import fj.data.Either; public final class GraphTestUtils { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeceleratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeceleratorTest.java index 9bd04d6da3..193f5d9ae0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeceleratorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstancePropertyDeceleratorTest.java @@ -1,6 +1,17 @@ package org.openecomp.sdc.be.components.property; -import fj.data.Either; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,17 +37,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -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.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeceleratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeceleratorTest.java index cd454d5a84..58029953b0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeceleratorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PolicyPropertyDeceleratorTest.java @@ -1,6 +1,16 @@ package org.openecomp.sdc.be.components.property; -import fj.data.Either; +import static org.assertj.core.api.Java6Assertions.assertThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,16 +31,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.PolicyOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; -import java.util.Arrays; -import java.util.Collections; -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.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; @RunWith(MockitoJUnitRunner.class) diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeceleratorTestBase.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeceleratorTestBase.java index 0c761a948d..d6018f2fc7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeceleratorTestBase.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/PropertyDeceleratorTestBase.java @@ -1,5 +1,12 @@ package org.openecomp.sdc.be.components.property; +import static org.assertj.core.api.Assertions.assertThat; +import static org.openecomp.sdc.common.api.Constants.GET_INPUT; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import org.junit.Before; import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder; import org.openecomp.sdc.be.dao.utils.MapUtil; @@ -8,13 +15,6 @@ import org.openecomp.sdc.be.model.ComponentInstancePropInput; import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.InputDefinition; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.openecomp.sdc.common.api.Constants.GET_INPUT; - public class PropertyDeceleratorTestBase { static final String INNER_PROP1 = "ecomp_generated_naming"; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/RecoveryThreadManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/RecoveryThreadManagerTest.java index 56aef5d923..e22bfd9889 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/RecoveryThreadManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/RecoveryThreadManagerTest.java @@ -1,6 +1,18 @@ package org.openecomp.sdc.be.components.scheduledtasks; -import fj.data.Either; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + import org.apache.commons.lang.math.NumberUtils; import org.junit.Before; import org.junit.Test; @@ -16,18 +28,7 @@ import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum; import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; import org.openecomp.sdc.common.datastructure.Wrapper; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import fj.data.Either; public class RecoveryThreadManagerTest extends BeConfDependentTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ArtifactBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ArtifactBuilder.java index 32e3f9c10a..55a119e078 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ArtifactBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ArtifactBuilder.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.utils; +import java.util.ArrayList; + import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.HeatParameterDefinition; -import java.util.ArrayList; - public class ArtifactBuilder { private ArtifactDefinition artifactDefinition; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/CapabilityDefinitionBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/CapabilityDefinitionBuilder.java index 4c137551dc..6a545622e3 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/CapabilityDefinitionBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/CapabilityDefinitionBuilder.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.utils; +import java.util.ArrayList; + import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.ComponentInstanceProperty; -import java.util.ArrayList; - public class CapabilityDefinitionBuilder { private CapabilityDefinition capabilityDefinition; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java index 490140dac0..f3cf208252 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentBuilder.java @@ -1,5 +1,9 @@ package org.openecomp.sdc.be.components.utils; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import org.openecomp.sdc.be.dao.utils.MapUtil; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.model.Component; @@ -12,10 +16,6 @@ import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.PolicyDefinition; import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - public abstract class ComponentBuilder<T extends Component, B extends ComponentBuilder<T, B>> { private T component; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentInstanceBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentInstanceBuilder.java index f461806010..864fb19fa1 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentInstanceBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ComponentInstanceBuilder.java @@ -1,13 +1,13 @@ package org.openecomp.sdc.be.components.utils; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.ComponentInstance; - import java.util.ArrayList; import java.util.HashMap; import java.util.stream.Stream; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.CapabilityDefinition; +import org.openecomp.sdc.be.model.ComponentInstance; + public class ComponentInstanceBuilder { private ComponentInstance componentInstance; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/GroupDefinitionBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/GroupDefinitionBuilder.java index d7deaa423a..08ed89f35c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/GroupDefinitionBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/GroupDefinitionBuilder.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.utils; -import org.openecomp.sdc.be.model.GroupDefinition; - import java.util.HashMap; import java.util.Map; +import org.openecomp.sdc.be.model.GroupDefinition; + public class GroupDefinitionBuilder { private GroupDefinition groupDefinition; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ObjectGenerator.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ObjectGenerator.java index 249cf69112..3a99d54ffa 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ObjectGenerator.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ObjectGenerator.java @@ -1,5 +1,11 @@ package org.openecomp.sdc.be.components.utils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentInstanceInput; import org.openecomp.sdc.be.model.ComponentInstanceProperty; @@ -9,12 +15,6 @@ import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; import org.openecomp.sdc.be.model.Resource; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - public class ObjectGenerator { public static Resource buildResourceWithInputs(String ... inputNames) { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/OperationalEnvironmentBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/OperationalEnvironmentBuilder.java index b6aa96e7d7..0e35964bd3 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/OperationalEnvironmentBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/OperationalEnvironmentBuilder.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.utils; +import java.util.Set; + import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum; import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; -import java.util.Set; - public class OperationalEnvironmentBuilder { private OperationalEnvironmentEntry operationalEnvironmentEntry; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PolicyDefinitionBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PolicyDefinitionBuilder.java index f818c04ccd..2826e2044e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PolicyDefinitionBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PolicyDefinitionBuilder.java @@ -1,15 +1,15 @@ package org.openecomp.sdc.be.components.utils; -import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType; -import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; -import org.openecomp.sdc.be.model.PolicyDefinition; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.model.PolicyDefinition; + public class PolicyDefinitionBuilder { private PolicyDefinition policyDefinition; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PolicyTypeBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PolicyTypeBuilder.java index 8c2b54f27e..d084bc2a0c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PolicyTypeBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PolicyTypeBuilder.java @@ -1,12 +1,12 @@ package org.openecomp.sdc.be.components.utils; -import org.openecomp.sdc.be.model.PolicyTypeDefinition; -import org.openecomp.sdc.be.model.PropertyDefinition; - import java.util.List; import java.util.Map; +import org.openecomp.sdc.be.model.PolicyTypeDefinition; +import org.openecomp.sdc.be.model.PropertyDefinition; + public class PolicyTypeBuilder { private PolicyTypeDefinition policyTypeDataDefinition; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionAbstractBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionAbstractBuilder.java index 9d5d71d67c..94ad42ce7d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionAbstractBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionAbstractBuilder.java @@ -1,11 +1,11 @@ package org.openecomp.sdc.be.components.utils; +import java.util.ArrayList; + import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; -import java.util.ArrayList; - public abstract class PropertyDataDefinitionAbstractBuilder<B extends PropertyDataDefinition, T extends PropertyDataDefinitionAbstractBuilder<B, T>> { B propertyDefinition; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionBuilder.java index 85b2228933..2f4ac9a281 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/PropertyDataDefinitionBuilder.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.utils; +import java.util.List; + import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; -import java.util.List; - public class PropertyDataDefinitionBuilder extends PropertyDataDefinitionAbstractBuilder<PropertyDefinition, PropertyDataDefinitionBuilder> { protected PropertyDataDefinitionBuilder self() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/RelationsBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/RelationsBuilder.java index e0d35c6b6a..6c968f2bdc 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/RelationsBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/RelationsBuilder.java @@ -1,12 +1,12 @@ package org.openecomp.sdc.be.components.utils; +import java.util.Collections; + import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; import org.openecomp.sdc.be.model.RelationshipImpl; import org.openecomp.sdc.be.model.RelationshipInfo; import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import java.util.Collections; - public class RelationsBuilder { private RequirementCapabilityRelDef relation; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ResourceBuilder.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ResourceBuilder.java index 25468af3c9..e5a14852e8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ResourceBuilder.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/ResourceBuilder.java @@ -1,10 +1,10 @@ package org.openecomp.sdc.be.components.utils; +import java.util.ArrayList; + import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; -import java.util.ArrayList; - public class ResourceBuilder extends ComponentBuilder<Resource, ResourceBuilder> { private Resource resource; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/UtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/UtilsTest.java index be19e8b795..4a123727f8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/UtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/utils/UtilsTest.java @@ -1,12 +1,12 @@ package org.openecomp.sdc.be.components.utils; -import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; public class UtilsTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java index 7e8d1b2081..a8686c179a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java @@ -16,8 +16,14 @@ package org.openecomp.sdc.be.components.validation; -import com.google.common.collect.Sets; -import fj.data.Either; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -39,13 +45,9 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import com.google.common.collect.Sets; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; +import fj.data.Either; public class InterfaceOperationValidationTest implements InterfaceOperationTestUtils { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ServiceDistributionValidationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ServiceDistributionValidationTest.java index df48a538a5..8538e090fd 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ServiceDistributionValidationTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ServiceDistributionValidationTest.java @@ -1,6 +1,11 @@ package org.openecomp.sdc.be.components.validation; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -22,11 +27,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ServiceDistributionValidationTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java index 4f90a0a42f..48aff6627a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java @@ -1,5 +1,9 @@ package org.openecomp.sdc.be.datamodel; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Collections; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.components.utils.PolicyDefinitionBuilder; @@ -11,10 +15,6 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer; -import java.util.Collections; - -import static org.assertj.core.api.Assertions.assertThat; - public class UiComponentDataConverterTest { private PolicyDefinition policy1, policy2; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java index a80999a25b..42b730bb92 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/DistributionBusinessLogicTest.java @@ -20,6 +20,14 @@ package org.openecomp.sdc.be.distribution; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.components.distribution.engine.DistributionEngineInitTask.buildTopicName; + +import javax.ws.rs.core.Response; + import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; @@ -38,14 +46,6 @@ import org.openecomp.sdc.be.distribution.api.client.TopicRegistrationResponse; import org.openecomp.sdc.be.distribution.api.client.TopicUnregistrationResponse; import org.openecomp.sdc.common.datastructure.Wrapper; -import javax.ws.rs.core.Response; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.components.distribution.engine.DistributionEngineInitTask.buildTopicName; - public class DistributionBusinessLogicTest extends BeConfDependentTest { @InjectMocks diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java index 4257a88a02..07ca01219c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/ServiceDistributionArtifactsBuilderTest.java @@ -20,6 +20,14 @@ package org.openecomp.sdc.be.distribution; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import org.junit.Test; import org.mockito.InjectMocks; import org.openecomp.sdc.be.components.BeConfDependentTest; @@ -30,14 +38,6 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.junit.Assert.assertTrue; - public class ServiceDistributionArtifactsBuilderTest extends BeConfDependentTest { @InjectMocks diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/TestQueue.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/TestQueue.java index 29b43c1920..64f66ea232 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/TestQueue.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/TestQueue.java @@ -20,11 +20,6 @@ package org.openecomp.sdc.be.distribution; -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import org.openecomp.sdc.be.components.distribution.engine.CambriaHandler; -import org.openecomp.sdc.be.components.distribution.engine.INotificationData; -import org.openecomp.sdc.be.components.distribution.engine.NotificationDataImpl; - import java.util.ArrayList; import java.util.List; import java.util.Timer; @@ -40,6 +35,12 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import org.openecomp.sdc.be.components.distribution.engine.CambriaHandler; +import org.openecomp.sdc.be.components.distribution.engine.INotificationData; +import org.openecomp.sdc.be.components.distribution.engine.NotificationDataImpl; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; + public class TestQueue { public static void main(String[] args) { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java index 253fd31390..7a74a1f983 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/servlet/DistributionServletTest.java @@ -20,8 +20,17 @@ package org.openecomp.sdc.be.distribution.servlet; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Application; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.apache.http.HttpStatus; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; @@ -48,16 +57,8 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; public class DistributionServletTest extends JerseyTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java index 8a40e83506..f0ec613a27 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/GenerateEcompErrorFileTest.java @@ -20,18 +20,18 @@ package org.openecomp.sdc.be.ecomp; -import org.junit.Test; -import org.openecomp.sdc.common.config.EcompClassification; -import org.openecomp.sdc.common.config.EcompErrorCode; -import org.openecomp.sdc.common.config.EcompErrorEnum; -import org.openecomp.sdc.common.config.generation.GenerateEcompErrorsCsv; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.openecomp.sdc.common.config.EcompClassification; +import org.openecomp.sdc.common.config.EcompErrorCode; +import org.openecomp.sdc.common.config.EcompErrorEnum; +import org.openecomp.sdc.common.config.generation.GenerateEcompErrorsCsv; public class GenerateEcompErrorFileTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java index fa43523c79..04dbf0ae75 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java @@ -21,7 +21,19 @@ package org.openecomp.sdc.be.externalapi.servlet; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.Arrays; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Application; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.apache.http.HttpStatus; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; @@ -55,17 +67,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.Arrays; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class AssetsDataServletTest extends JerseyTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java index 52e9230711..7871dd9d2b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java @@ -1,15 +1,9 @@ package org.openecomp.sdc.be.impl; -import java.util.EnumMap; import java.util.List; -import javax.annotation.Generated; -import javax.servlet.http.HttpServletRequest; - import org.apache.tinkerpop.gremlin.structure.T; -import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; import org.openecomp.sdc.be.auditing.impl.AuditingManager; @@ -25,7 +19,6 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.CapabilityTypeDefinition; import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ConsumerDefinition; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.GroupTypeDefinition; import org.openecomp.sdc.be.model.PolicyTypeDefinition; @@ -33,17 +26,14 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData; import org.openecomp.sdc.be.resources.data.auditing.model.ResourceAuditData; import org.openecomp.sdc.be.tosca.ToscaError; import org.openecomp.sdc.common.api.ConfigurationSource; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; import fj.data.Either; -import mockit.Deencapsulation; public class ComponentsUtilsTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java index be43fa7d62..99053aa603 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java @@ -20,17 +20,9 @@ package org.openecomp.sdc.be.servlets; -import fj.data.Either; -import org.apache.commons.codec.binary.Base64; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.sdc.be.model.UploadResourceInfo; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.common.datastructure.Wrapper; -import org.openecomp.sdc.exception.ResponseFormat; -import org.slf4j.Logger; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; -import javax.ws.rs.core.Response; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -40,8 +32,18 @@ import java.nio.file.Paths; import java.util.Map; import java.util.stream.Stream; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; +import javax.ws.rs.core.Response; + +import org.apache.commons.codec.binary.Base64; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdc.be.model.UploadResourceInfo; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.common.datastructure.Wrapper; +import org.openecomp.sdc.exception.ResponseFormat; +import org.slf4j.Logger; + +import fj.data.Either; public class AbstractValidationsServletTest { private static AbstractValidationsServlet servlet = new AbstractValidationsServlet() {}; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java index 6fe303b495..d7d470449c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ApplicationConfig.java @@ -20,17 +20,18 @@ package org.openecomp.sdc.be.servlets; +import java.util.HashSet; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Application; + import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.MultiPart; import org.glassfish.jersey.server.ResourceConfig; import org.mockito.Mockito; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Application; -import java.util.HashSet; -import java.util.Set; - public class ApplicationConfig extends Application { public Set<Class<?>> getClasses() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/BaseTestConfig.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/BaseTestConfig.java index 218505d8ef..8378a71b4c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/BaseTestConfig.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/BaseTestConfig.java @@ -1,11 +1,11 @@ package org.openecomp.sdc.be.servlets; +import static org.mockito.Mockito.mock; + import org.openecomp.sdc.be.auditing.impl.AuditingManager; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.springframework.context.annotation.Bean; -import static org.mockito.Mockito.mock; - public class BaseTestConfig { @Bean diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java index c723e0e664..5d85f52351 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java @@ -1,6 +1,15 @@ package org.openecomp.sdc.be.servlets; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.jetty.http.HttpStatus; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; @@ -23,15 +32,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; +import fj.data.Either; /** * The test suite designed for test functionality of ComponentInstanceServlet class diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java index 2d5494354d..39a541d568 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java @@ -1,9 +1,24 @@ package org.openecomp.sdc.be.servlets; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Sets; -import fj.data.Either; +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; + +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider; import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider; @@ -33,23 +48,11 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.http.HttpStatus; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Stream; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import fj.data.Either; public class GroupTypesEndpointTest extends JerseySpringBaseTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/JerseySpringBaseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/JerseySpringBaseTest.java index 9a074c95c2..c7e759dfea 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/JerseySpringBaseTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/JerseySpringBaseTest.java @@ -1,5 +1,9 @@ package org.openecomp.sdc.be.servlets; +import static org.mockito.Mockito.mock; + +import javax.servlet.http.HttpServletRequest; + import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; @@ -8,10 +12,6 @@ import org.junit.BeforeClass; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import javax.servlet.http.HttpServletRequest; - -import static org.mockito.Mockito.mock; - public class JerseySpringBaseTest extends JerseyTest { protected static HttpServletRequest request; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java index bb949253b2..41e2abe29f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java @@ -1,7 +1,25 @@ package org.openecomp.sdc.be.servlets; -import com.fasterxml.jackson.databind.DeserializationFeature; -import fj.data.Either; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.glassfish.grizzly.http.util.HttpStatus; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider; @@ -25,24 +43,9 @@ import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.exception.ResponseFormat; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import com.fasterxml.jackson.databind.DeserializationFeature; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import fj.data.Either; public class PolicyServletTest extends JerseySpringBaseTest{ diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java index 23f32d169b..b58cae56a2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java @@ -1,7 +1,17 @@ package org.openecomp.sdc.be.servlets; -import com.fasterxml.jackson.databind.DeserializationFeature; -import fj.data.Either; +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; + +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.apache.http.HttpStatus; import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider; import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider; @@ -15,16 +25,9 @@ import org.openecomp.sdc.be.model.PolicyTypeDefinition; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.exception.ResponseFormat; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; +import com.fasterxml.jackson.databind.DeserializationFeature; -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import fj.data.Either; public class PolicyTypesEndpointTest extends JerseySpringBaseTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java index 63e76700df..f64dfb9fec 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.HashMap; + import org.apache.tinkerpop.gremlin.structure.T; import org.junit.Test; import org.openecomp.sdc.be.model.ArtifactDefinition; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java index e8aeb5fc70..5a35793ab9 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java @@ -20,9 +20,19 @@ package org.openecomp.sdc.be.servlets; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.Arrays; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Application; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.tuple.ImmutablePair; import org.glassfish.hk2.utilities.binding.AbstractBinder; @@ -55,17 +65,10 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.http.HttpStatus; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.Arrays; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ResourceServletTest extends JerseyTest { public static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java index 23daab9bf9..8d9b95d414 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java @@ -20,7 +20,22 @@ package org.openecomp.sdc.be.servlets; -import com.google.gson.Gson; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Application; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.media.multipart.FormDataBodyPart; @@ -51,20 +66,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; +import com.google.gson.Gson; public class ResourceUploadServletTest extends JerseyTest { private static final Logger log = LoggerFactory.getLogger(ResourceUploadServletTest.class); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java index 690f7427a8..cfa65f76a5 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java @@ -20,7 +20,20 @@ package org.openecomp.sdc.be.servlets; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.jetty.http.HttpStatus; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.client.ClientConfig; @@ -53,18 +66,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; +import fj.data.Either; public class TypesUploadServletTest extends JerseyTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java index 696214f49d..3e6f934bfc 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java @@ -20,8 +20,17 @@ package org.openecomp.sdc.be.servlets; -import com.google.gson.Gson; -import fj.data.Either; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.core.Application; + import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; @@ -41,16 +50,9 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.http.HttpStatus; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.core.Application; +import com.google.gson.Gson; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; +import fj.data.Either; public class UserAdminServletTest extends JerseyTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertorTest.java index 3c42257446..b00bd0f6b1 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertorTest.java @@ -1,13 +1,9 @@ package org.openecomp.sdc.be.tosca; // -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.Resource; +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.doReturn; import java.util.ArrayList; import java.util.Arrays; @@ -17,9 +13,13 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.doReturn; +import org.junit.Test; +import org.mockito.Mockito; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.model.CapabilityDefinition; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.Resource; public class CapabiltyRequirementConvertorTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java index 8883786d7e..5ac1467a5c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java @@ -20,7 +20,13 @@ package org.openecomp.sdc.be.tosca; -import fj.data.Either; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.config.ConfigurationManager; @@ -29,12 +35,7 @@ import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class CsarUtilsTest { @Before diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java index dbdec12193..139de137d9 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java @@ -1,6 +1,18 @@ package org.openecomp.sdc.be.tosca; -import fj.data.Either; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder; @@ -11,18 +23,7 @@ import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.be.tosca.model.ToscaNodeType; import org.openecomp.sdc.be.tosca.model.ToscaProperty; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import fj.data.Either; public class PropertyConvertorTest { private PropertyDefinition property; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java index 839095f1ca..05f872f44c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/SchemaFiles.java @@ -20,8 +20,8 @@ package org.openecomp.sdc.be.tosca; -import org.junit.Test; -import org.yaml.snakeyaml.Yaml; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.FileInputStream; import java.io.IOException; @@ -31,8 +31,8 @@ import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.yaml.snakeyaml.Yaml; public class SchemaFiles { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java index efc89a9f9d..041973a0b4 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java @@ -1,7 +1,5 @@ package org.openecomp.sdc.be.tosca; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import org.junit.Test; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; import org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation; @@ -9,6 +7,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + public class ToscaExportUtilsTest { private static final Logger log = LoggerFactory.getLogger(ToscaExportUtilsTest.class); @javax.annotation.Resource diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java index ee33d00806..cfc6fa649f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java @@ -18,6 +18,7 @@ package org.openecomp.sdc.be.tosca.utils; import java.util.HashMap; import java.util.Map; + import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java index dc964be430..338143ef23 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java @@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals; import java.io.File; import java.util.HashMap; + import org.junit.BeforeClass; import org.junit.Test; import org.openecomp.sdc.be.DummyConfigurationManager; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java index 8d45e42357..0a65a51890 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java @@ -20,7 +20,12 @@ package org.openecomp.sdc.common.transaction.mngr; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -46,11 +51,7 @@ import org.openecomp.sdc.common.transaction.api.TransactionUtils.TransactionCode import org.openecomp.sdc.common.transaction.api.TransactionUtils.TransactionStatusEnum; import org.slf4j.Logger; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import fj.data.Either; public class SdncTransactionTest { private static ESCatalogDAO esCatalogDao = Mockito.mock(ESCatalogDAO.class); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationTest.java index 95c2ac7bdd..0fbf2c8564 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationTest.java @@ -1,10 +1,11 @@ package org.openecomp.sdc.cucumber.runners; -import cucumber.api.CucumberOptions; -import cucumber.api.junit.Cucumber; import org.junit.runner.RunWith; import org.openecomp.sdc.be.components.BeConfDependentTest; +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; + @RunWith(Cucumber.class) @CucumberOptions(features = "classpath:cucumber/tenantIsolation.feature", glue = "org.openecomp.sdc.be.components.distribution.engine") |