summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-05-16 19:27:27 +0300
committerTal Gitelman <tg851x@intl.att.com>2018-05-16 19:30:04 +0300
commit193fc178482e684c2838b070f7ad8e73c159b071 (patch)
treee3d35e86ac406f18a8d5ea31dd726a7f844c727f /catalog-be/src/test/java
parent28529fa5269ef514443e1b79cdb8fff23fd54901 (diff)
new unit tests for sdc-be
Change-Id: I0e2ee2950898668b9ce1e3ef5acf85c1b68cf5d8 Issue-ID: SDC-1333 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/AsdcComponentsCleanerTaskTest.java73
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java20
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ComponentValidationsTest.java128
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/PolicyUtilsTest.java112
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/UserValidationsTest.java130
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairTest.java136
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairWrapperTest.java73
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java33
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java78
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java35
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/NodeTypeConvertUtilsTest.java18
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java69
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java32
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java50
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java50
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/dto/ExternalRefDTOTest.java45
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/dto/TestSuite.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java452
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java263
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java25
23 files changed, 1865 insertions, 1 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java
new file mode 100644
index 0000000000..278e965837
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/TestSuite.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses(
+
+{ ErrorConfigurationTest.class, org.openecomp.sdc.be.TestSuite.class })
+public class TestSuite { // nothing
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java
new file mode 100644
index 0000000000..d4cc2fb5dd
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/TestSuite.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.be;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses(
+
+{ org.openecomp.sdc.be.ecomp.TestSuite.class })
+public class TestSuite { // nothing
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/AsdcComponentsCleanerTaskTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/AsdcComponentsCleanerTaskTest.java
new file mode 100644
index 0000000000..a7561ff2f2
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/scheduledtasks/AsdcComponentsCleanerTaskTest.java
@@ -0,0 +1,73 @@
+package org.openecomp.sdc.be.components.scheduledtasks;
+
+import java.util.concurrent.ExecutorService;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.BeConfDependentTest;
+
+import mockit.Deencapsulation;
+
+public class AsdcComponentsCleanerTaskTest extends BeConfDependentTest{
+
+ private AsdcComponentsCleanerTask createTestSubject() {
+ return new AsdcComponentsCleanerTask();
+ }
+
+ @Test
+ public void testInit() throws Exception {
+ AsdcComponentsCleanerTask testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.init();
+ }
+
+ @Test
+ public void testDestroy() throws Exception {
+ AsdcComponentsCleanerTask testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.destroy();
+ }
+
+ @Test
+ public void testStartTask() throws Exception {
+ AsdcComponentsCleanerTask testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.startTask();
+ }
+
+ @Test
+ public void testStopTask() throws Exception {
+ AsdcComponentsCleanerTask testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ Deencapsulation.invoke(testSubject, "stopTask");
+ testSubject.init();
+ testSubject.startTask();
+ Deencapsulation.invoke(testSubject, "stopTask");
+ }
+
+ @Test
+ public void testRun() throws Exception {
+ AsdcComponentsCleanerTask testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.run();
+ }
+
+ @Test
+ public void testGetExecutorService() throws Exception {
+ AsdcComponentsCleanerTask testSubject;
+ ExecutorService result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getExecutorService();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java
new file mode 100644
index 0000000000..7cdd048ad0
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.be.components.validation;
+
+import org.junit.Test;
+
+public class ApiResourceEnumTest {
+
+ private ApiResourceEnum createTestSubject() {
+ return ApiResourceEnum.ENVIRONMENT_ID;
+ }
+
+ @Test
+ public void testGetValue() throws Exception {
+ ApiResourceEnum testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getValue();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ComponentValidationsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ComponentValidationsTest.java
new file mode 100644
index 0000000000..a5679bceab
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ComponentValidationsTest.java
@@ -0,0 +1,128 @@
+package org.openecomp.sdc.be.components.validation;
+
+import javax.annotation.Generated;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+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.GraphLockOperation;
+import org.apache.commons.collections.CollectionUtils;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.StorageException;
+import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
+import org.openecomp.sdc.common.util.ValidationUtils;
+
+import fj.data.Either;
+import mockit.Deencapsulation;
+
+public class ComponentValidationsTest {
+
+ @InjectMocks
+ ComponentValidations testSubject;
+
+ @Mock
+ ToscaOperationFacade toscaOperationFacadeMock;
+
+ @Mock
+ GraphLockOperation graphLockOperationMock;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testValidateComponentInstanceExist() throws Exception {
+ Component component = new Resource();
+ String instanceId = "";
+ boolean result;
+
+ // default test
+ result = ComponentValidations.validateComponentInstanceExist(component, instanceId);
+ }
+
+ @Test
+ public void testGetNormalizedName() throws Exception {
+ ToscaDataDefinition toscaDataDefinition = new AdditionalInfoParameterDataDefinition();
+ toscaDataDefinition.setToscaPresentationValue(JsonPresentationFields.NAME, "mock");
+ String result;
+
+ // default test
+ result = ComponentValidations.getNormalizedName(toscaDataDefinition);
+ }
+
+ @Test
+ public void testValidateNameIsUniqueInComponent() throws Exception {
+ String currentName = "";
+ String newName = "";
+ String newName2 = "mock";
+ Component component = new Resource();
+ boolean result;
+
+ // default test
+ result = ComponentValidations.validateNameIsUniqueInComponent(currentName, newName, component);
+ result = ComponentValidations.validateNameIsUniqueInComponent(currentName, newName2, component);
+ }
+
+ @Test(expected=ComponentException.class)
+ public void testValidateComponentIsCheckedOutByUserAndLockIt() throws Exception {
+ String componentId = "";
+ String userId = "";
+ Component result;
+
+ Mockito.when(toscaOperationFacadeMock.getToscaElement(Mockito.anyString(), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(new Resource()));
+
+ // default test
+ result = testSubject.validateComponentIsCheckedOutByUserAndLockIt(ComponentTypeEnum.RESOURCE, componentId,
+ userId);
+ }
+
+ @Test
+ public void testGetComponent() throws Exception {
+ String componentId = "mock";
+ ComponentTypeEnum componentType = null;
+ Component result;
+
+ Mockito.when(toscaOperationFacadeMock.getToscaElement(Mockito.anyString(), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(new Resource()));
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "getComponent", componentId, ComponentTypeEnum.RESOURCE);
+ }
+
+ @Test(expected = StorageException.class)
+ public void testLockComponent() throws Exception {
+ Component component = new Resource();
+
+ // default test
+ Deencapsulation.invoke(testSubject, "lockComponent", component);
+ }
+
+ @Test(expected = StorageException.class)
+ public void testOnToscaOperationError() throws Exception {
+ Component result;
+
+ // default test
+ result = Deencapsulation.invoke(testSubject, "onToscaOperationError",
+ StorageOperationStatus.ARTIFACT_NOT_FOUND);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/PolicyUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/PolicyUtilsTest.java
new file mode 100644
index 0000000000..ccdd7f858b
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/PolicyUtilsTest.java
@@ -0,0 +1,112 @@
+package org.openecomp.sdc.be.components.validation;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.BeConfDependentTest;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.PolicyDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+
+import fj.data.Either;
+import mockit.Deencapsulation;
+
+public class PolicyUtilsTest extends BeConfDependentTest{
+
+ @Test
+ public void testGetNextPolicyCounter() throws Exception {
+ Map<String, PolicyDefinition> policies = null;
+ int result;
+
+ // default test
+ result = PolicyUtils.getNextPolicyCounter(policies);
+ }
+
+ @Test
+ public void testValidatePolicyFields() throws Exception {
+ PolicyDefinition recievedPolicy = new PolicyDefinition();
+ PolicyDefinition validPolicy = new PolicyDefinition();
+ Map<String, PolicyDefinition> policies = null;
+ Either<PolicyDefinition, ActionStatus> result;
+
+ // default test
+ result = PolicyUtils.validatePolicyFields(recievedPolicy, validPolicy, policies);
+ }
+
+ @Test
+ public void testGetExcludedPolicyTypesByComponent() throws Exception {
+ Component component = new Resource();
+ Set<String> result;
+
+ // default test
+ result = PolicyUtils.getExcludedPolicyTypesByComponent(component);
+ component = new Service();
+ result = PolicyUtils.getExcludedPolicyTypesByComponent(component);
+ }
+
+ @Test
+ public void testExtractNextPolicyCounterFromUniqueId() throws Exception {
+ String uniqueId = "";
+ int result;
+
+ // default test
+ result = Deencapsulation.invoke(PolicyUtils.class, "extractNextPolicyCounterFromUniqueId",
+ new Object[] { uniqueId });
+ }
+
+ @Test
+ public void testExtractNextPolicyCounterFromName() throws Exception {
+ String policyName = "";
+ int result;
+
+ // default test
+ result = Deencapsulation.invoke(PolicyUtils.class, "extractNextPolicyCounterFromName",
+ new Object[] { policyName });
+ }
+
+ @Test
+ public void testExtractNextPolicyCounter() throws Exception {
+ String policyName = "";
+ int endIndex = 0;
+ int result;
+
+ // default test
+ result = Deencapsulation.invoke(PolicyUtils.class, "extractNextPolicyCounter",
+ new Object[] { policyName, endIndex });
+ }
+
+ @Test
+ public void testValidateImmutablePolicyFields() throws Exception {
+ PolicyDefinition receivedPolicy = new PolicyDefinition();
+ PolicyDefinition validPolicy = new PolicyDefinition();
+
+ // default test
+ Deencapsulation.invoke(PolicyUtils.class, "validateImmutablePolicyFields",
+ receivedPolicy, validPolicy);
+ }
+
+ @Test
+ public void testIsUpdatedField() throws Exception {
+ String oldField = "";
+ String newField = "";
+ boolean result;
+
+ // default test
+ result = Deencapsulation.invoke(PolicyUtils.class, "isUpdatedField", new Object[] { oldField, newField });
+ }
+
+ @Test
+ public void testLogImmutableFieldUpdateWarning() throws Exception {
+ String oldValue = "";
+ String newValue = "";
+ JsonPresentationFields field = null;
+
+ // default test
+ Deencapsulation.invoke(PolicyUtils.class, "logImmutableFieldUpdateWarning",
+ new Object[] { oldValue, newValue, JsonPresentationFields.class });
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/UserValidationsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/UserValidationsTest.java
new file mode 100644
index 0000000000..375effd0ee
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/UserValidationsTest.java
@@ -0,0 +1,130 @@
+package org.openecomp.sdc.be.components.validation;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.stubbing.Answer;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.user.IUserBusinessLogic;
+import org.openecomp.sdc.be.user.Role;
+import org.openecomp.sdc.common.datastructure.Wrapper;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.openecomp.sdc.test.utils.TestUtilsSdc;
+import org.slf4j.LoggerFactory;import cucumber.api.java.sk.A;
+import fj.data.Either;
+
+public class UserValidationsTest {
+
+ @InjectMocks
+ UserValidations testSubject;
+
+ @Mock
+ IUserBusinessLogic userAdmin;
+
+ @Mock
+ ComponentsUtils componentsUtils;
+
+ @Before
+ public void setUp() throws Exception {
+ TestUtilsSdc.setFinalStatic(UserValidations.class, "log", LoggerFactory.getLogger(UserValidations.class));
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testValidateUserExists() throws Exception {
+ String userId = "mock";
+ String ecompErrorContext = "mock";
+ User usr = new User();
+ boolean inTransaction = false;
+ Either<User, ResponseFormat> result;
+
+
+ Mockito.when(userAdmin.getUser(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(Either.left(usr));
+
+ // default test
+ result = testSubject.validateUserExists(userId, ecompErrorContext, inTransaction);
+ }
+
+ @Test
+ public void testValidateUserExists2() throws Exception {
+ String userId = "mock";
+ String ecompErrorContext = "mock";
+ boolean inTransaction = false;
+ Either<User, ResponseFormat> result;
+
+
+ Mockito.when(userAdmin.getUser(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(Either.right(ActionStatus.USER_NOT_FOUND));
+
+ // default test
+ result = testSubject.validateUserExists(userId, ecompErrorContext, inTransaction);
+ }
+
+ @Test
+ public void testValidateUserRole() throws Exception {
+ User user = new User();
+ List<Role> roles = new LinkedList<>();
+ Either<Boolean, ResponseFormat> result;
+
+ user.setRole(Role.DESIGNER.name());
+
+ // test 1
+ result = testSubject.validateUserRole(user, roles);
+ }
+
+ @Test
+ public void testValidateUserExistsActionStatus() throws Exception {
+ String userId = "mock";
+ String ecompErrorContext = "mock";
+ Either<User, ActionStatus> result;
+ User usr = new User();
+
+ Mockito.when(userAdmin.getUser(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(Either.left(usr));
+
+ // default test
+ result = testSubject.validateUserExistsActionStatus(userId, ecompErrorContext);
+ }
+
+ @Test
+ public void testValidateUserExistsActionStatus2() throws Exception {
+ String userId = "mock";
+ String ecompErrorContext = "mock";
+ Either<User, ActionStatus> result;
+ User usr = new User();
+
+ Mockito.when(userAdmin.getUser(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(Either.right(ActionStatus.USER_NOT_FOUND));
+
+ // default test
+ result = testSubject.validateUserExistsActionStatus(userId, ecompErrorContext);
+ }
+
+ @Test
+ public void testValidateUserNotEmpty() throws Exception {
+ User user = new User();
+ String ecompErrorContext = "mock";
+ Either<User, ResponseFormat> result;
+
+ // default test
+ result = testSubject.validateUserNotEmpty(user, ecompErrorContext);
+ }
+
+ @Test
+ public void testValidateUserExist() throws Exception {
+ String userId = "";
+ String ecompErrorContext = "";
+ Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
+
+ Mockito.when(userAdmin.getUser(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(Either.right(ActionStatus.USER_NOT_FOUND));
+
+ // default test
+ testSubject.validateUserExist(userId, ecompErrorContext, errorWrapper);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairTest.java
new file mode 100644
index 0000000000..fd0bd4115e
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairTest.java
@@ -0,0 +1,136 @@
+package org.openecomp.sdc.be.datamodel;
+
+import java.util.Set;
+
+import javax.annotation.Generated;
+
+import org.junit.Test;
+
+public class NameIdPairTest {
+
+ private NameIdPair createTestSubject() {
+ return new NameIdPair("", "");
+ }
+
+ @Test
+ public void testGetName() throws Exception {
+ NameIdPair testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getName();
+ }
+
+ @Test
+ public void testSetName() throws Exception {
+ NameIdPair testSubject;
+ String name = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setName(name);
+ }
+
+ @Test
+ public void testGetId() throws Exception {
+ NameIdPair testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getId();
+ }
+
+ @Test
+ public void testSetId() throws Exception {
+ NameIdPair testSubject;
+ String id = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setId(id);
+ }
+
+ @Test
+ public void testGetOwnerId() throws Exception {
+ NameIdPair testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.put("ownerId", "mock");
+ result = testSubject.getOwnerId();
+ }
+
+ @Test
+ public void testSetOwnerId() throws Exception {
+ NameIdPair testSubject;
+ String ownerId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOwnerId(ownerId);
+ }
+
+ @Test
+ public void testGetWrappedData() throws Exception {
+ NameIdPair testSubject;
+ Set<NameIdPairWrapper> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getWrappedData();
+ }
+
+ @Test
+ public void testSetWrappedData() throws Exception {
+ NameIdPair testSubject;
+ Set<NameIdPairWrapper> data = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setWrappedData(data);
+ }
+
+ @Test
+ public void testAddWrappedData() throws Exception {
+ NameIdPair testSubject;
+ NameIdPairWrapper nameIdPairWrapper = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.addWrappedData(nameIdPairWrapper);
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ NameIdPair testSubject;
+ Object o = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(o);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ NameIdPair testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ String name = "";
+ String id = "";
+ NameIdPair result;
+
+ // default test
+ result = NameIdPair.create(name, id);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairWrapperTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairWrapperTest.java
new file mode 100644
index 0000000000..452d02d3ea
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairWrapperTest.java
@@ -0,0 +1,73 @@
+package org.openecomp.sdc.be.datamodel;
+
+import org.junit.Test;
+
+public class NameIdPairWrapperTest {
+
+ private NameIdPairWrapper createTestSubject() {
+ return new NameIdPairWrapper();
+ }
+
+ @Test
+ public void testInit() throws Exception {
+ NameIdPairWrapper testSubject;
+ NameIdPair nameIdPair = new NameIdPair("mock", "mock");
+
+ // default test
+ testSubject = createTestSubject();
+
+ testSubject.init(nameIdPair);
+ }
+
+ @Test
+ public void testGetId() throws Exception {
+ NameIdPairWrapper testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setId("mock");
+ result = testSubject.getId();
+ }
+
+ @Test
+ public void testSetId() throws Exception {
+ NameIdPairWrapper testSubject;
+ String id = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setId(id);
+ }
+
+ @Test
+ public void testGetData() throws Exception {
+ NameIdPairWrapper testSubject;
+ NameIdPair result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getData();
+ }
+
+ @Test
+ public void testSetData() throws Exception {
+ NameIdPairWrapper testSubject;
+ NameIdPair data = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setData(data);
+ }
+
+ @Test
+ public void testGetNameIdPair() throws Exception {
+ NameIdPairWrapper testSubject;
+ NameIdPair nameIdPair = new NameIdPair("mock", "mock");
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.init(nameIdPair);
+ testSubject.getNameIdPair();
+ }
+} \ No newline at end of file
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 48aff6627a..9dda8cbb5d 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
@@ -3,6 +3,7 @@ package org.openecomp.sdc.be.datamodel;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collections;
+import java.util.LinkedList;
import org.junit.Before;
import org.junit.Test;
@@ -10,10 +11,15 @@ import org.openecomp.sdc.be.components.utils.PolicyDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
import org.openecomp.sdc.be.components.utils.ServiceBuilder;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
+import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum;
+import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
+import org.openecomp.sdc.be.ui.model.UiComponentMetadata;
+
+import mockit.Deencapsulation;
public class UiComponentDataConverterTest {
@@ -57,7 +63,32 @@ public class UiComponentDataConverterTest {
UiComponentDataTransfer componentDTO = UiComponentDataConverter.getUiDataTransferFromServiceByParams(resourceWithPolicies, Collections.singletonList("policies"));
assertThat(componentDTO.getPolicies()).isEqualTo(resourceWithPolicies.resolvePoliciesList());
}
-
+
+ @Test
+ public void testAll() {
+ Service resourceWithPolicies = buildServiceWithPolicies();
+ Resource resource = new Resource();
+ Service service = new Service();
+ UiComponentMetadata componentDTO = UiComponentDataConverter.convertToUiComponentMetadata(resource);
+ componentDTO = UiComponentDataConverter.convertToUiComponentMetadata(service);
+
+ UiComponentDataTransfer dataTransfer = new UiComponentDataTransfer();
+
+
+ for (ComponentFieldsEnum iterable_element : ComponentFieldsEnum.values()) {
+ Deencapsulation.invoke(UiComponentDataConverter.class, "setUiTranferDataByFieldName", dataTransfer, resource, iterable_element.getValue());
+ }
+
+ LinkedList<String> linkedList = new LinkedList<>();
+
+ for (ComponentFieldsEnum object : ComponentFieldsEnum.values()) {
+ linkedList.add(object.getValue());
+ }
+
+ UiComponentDataConverter.getUiDataTransferFromResourceByParams(resource, linkedList);
+
+ }
+
private Resource buildResourceWithPolicies() {
return new ResourceBuilder()
.addPolicy(policy1)
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java
new file mode 100644
index 0000000000..0e564c1249
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java
@@ -0,0 +1,78 @@
+package org.openecomp.sdc.be.datamodel.utils;
+
+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.info.ArtifactTemplateInfo;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
+
+public class ArtifactUtilsTest {
+
+ private ArtifactUtils createTestSubject() {
+ return new ArtifactUtils();
+ }
+
+ @Test
+ public void testFindMasterArtifact() throws Exception {
+ Map<String, ArtifactDefinition> deplymentArtifact = new HashMap<>();
+ List<ArtifactDefinition> artifacts = new LinkedList<>();
+ List<String> artifactsList = new LinkedList<>();
+ ArtifactDefinition result;
+
+ // default test
+ result = ArtifactUtils.findMasterArtifact(deplymentArtifact, artifacts, artifactsList);
+ }
+
+ @Test
+ public void testBuildJsonForUpdateArtifact() throws Exception {
+ String artifactId = "";
+ String artifactName = "";
+ String artifactType = "";
+ ArtifactGroupTypeEnum artifactGroupType = ArtifactGroupTypeEnum.DEPLOYMENT;
+ String label = "";
+ String displayName = "";
+ String description = "";
+ byte[] artifactContentent = new byte[] { ' ' };
+ List<ArtifactTemplateInfo> updatedRequiredArtifacts = null;
+ boolean isFromCsar = false;
+ Map<String, Object> result;
+
+ // test 1
+ artifactId = null;
+ result = ArtifactUtils.buildJsonForUpdateArtifact(artifactId, artifactName, artifactType, artifactGroupType,
+ label, displayName, description, artifactContentent, updatedRequiredArtifacts, isFromCsar);
+
+ // test 2
+ /*artifactId = "";
+ result = ArtifactUtils.buildJsonForUpdateArtifact(artifactId, artifactName, artifactType, artifactGroupType,
+ label, displayName, description, artifactContentent, updatedRequiredArtifacts, isFromCsar);
+ Assert.assertEquals(null, result);*/
+ }
+
+ @Test
+ public void testBuildJsonForArtifact() throws Exception {
+ ArtifactTemplateInfo artifactTemplateInfo = new ArtifactTemplateInfo();
+ artifactTemplateInfo.setFileName("mock.mock.heat");
+ byte[] artifactContentent = new byte[] { ' ' };
+ int atrifactLabelCounter = 0;
+ Map<String, Object> result;
+
+ // default test
+ result = ArtifactUtils.buildJsonForArtifact(artifactTemplateInfo, artifactContentent, atrifactLabelCounter);
+ }
+
+ @Test
+ public void testFindArtifactInList() throws Exception {
+ List<ArtifactDefinition> createdArtifacts = new LinkedList<>();
+ String artifactId = "mock";
+ ArtifactDefinition result;
+
+ // default test
+ result = ArtifactUtils.findArtifactInList(createdArtifacts, artifactId);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java
new file mode 100644
index 0000000000..5ed11a553e
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java
@@ -0,0 +1,35 @@
+package org.openecomp.sdc.be.datamodel.utils;
+
+import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.IO_INPUT_PARAMETERS;
+
+import java.util.LinkedList;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
+import org.openecomp.sdc.be.model.Operation;
+
+public class InterfaceUIDataConverterTest {
+
+ @Test
+ public void testConvertInterfaceDataToOperationData() throws Exception {
+ InterfaceOperationDataDefinition interfaceOperation = new InterfaceOperationDataDefinition();
+ Operation result;
+
+ // default test
+ result = InterfaceUIDataConverter.convertInterfaceDataToOperationData(interfaceOperation);
+ }
+
+ @Test
+ public void testConvertOperationDataToInterfaceData() throws Exception {
+ Operation operationData = new Operation();
+ InterfaceOperationDataDefinition result;
+ ListDataDefinition<OperationInputDefinition> inputs = new ListDataDefinition<>();
+ operationData.setInputs(inputs);
+ operationData.setImplementation(new ArtifactDataDefinition());
+ // default test
+ result = InterfaceUIDataConverter.convertOperationDataToInterfaceData(operationData);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/NodeTypeConvertUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/NodeTypeConvertUtilsTest.java
new file mode 100644
index 0000000000..d75d760076
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/NodeTypeConvertUtilsTest.java
@@ -0,0 +1,18 @@
+package org.openecomp.sdc.be.datamodel.utils;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.datamodel.api.CategoryTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+
+public class NodeTypeConvertUtilsTest {
+
+ @Test
+ public void testGetCategoryNodeTypeByComponentParam() throws Exception {
+ // test 1
+ for (ComponentTypeEnum comp : ComponentTypeEnum.values()) {
+ for (CategoryTypeEnum cat : CategoryTypeEnum.values()) {
+ NodeTypeConvertUtils.getCategoryNodeTypeByComponentParam(comp, cat);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java
new file mode 100644
index 0000000000..d62098d96e
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java
@@ -0,0 +1,69 @@
+package org.openecomp.sdc.be.distribution.api.client;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.junit.Test;
+
+public class RegistrationRequestTest {
+
+ private RegistrationRequest createTestSubject() {
+ return new RegistrationRequest("", "", false);
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ List<String> distEnvEndPoints = new LinkedList<>();
+ new RegistrationRequest("mock", "mock", distEnvEndPoints , false);
+ }
+
+ @Test
+ public void testGetApiPublicKey() throws Exception {
+ RegistrationRequest testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getApiPublicKey();
+ }
+
+ @Test
+ public void testGetDistrEnvName() throws Exception {
+ RegistrationRequest testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDistrEnvName();
+ }
+
+ @Test
+ public void testGetIsConsumerToSdcDistrStatusTopic() throws Exception {
+ RegistrationRequest testSubject;
+ Boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getIsConsumerToSdcDistrStatusTopic();
+ }
+
+ @Test
+ public void testGetDistEnvEndPoints() throws Exception {
+ RegistrationRequest testSubject;
+ List<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDistEnvEndPoints();
+ }
+
+ @Test
+ public void testSetDistEnvEndPoints() throws Exception {
+ RegistrationRequest testSubject;
+ List<String> distEnvEndPoints = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setDistEnvEndPoints(distEnvEndPoints);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java
new file mode 100644
index 0000000000..7285f226d5
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java
@@ -0,0 +1,32 @@
+package org.openecomp.sdc.be.distribution.api.client;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class ServerListResponseTest {
+
+ private ServerListResponse createTestSubject() {
+ return new ServerListResponse();
+ }
+
+ @Test
+ public void testGetUebServerList() throws Exception {
+ ServerListResponse testSubject;
+ List<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getUebServerList();
+ }
+
+ @Test
+ public void testSetUebServerList() throws Exception {
+ ServerListResponse testSubject;
+ List<String> uebServerList = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setUebServerList(uebServerList);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java
new file mode 100644
index 0000000000..88d4959c25
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java
@@ -0,0 +1,50 @@
+package org.openecomp.sdc.be.distribution.api.client;
+
+import org.junit.Test;
+
+public class TopicRegistrationResponseTest {
+
+ private TopicRegistrationResponse createTestSubject() {
+ return new TopicRegistrationResponse();
+ }
+
+ @Test
+ public void testSetDistrNotificationTopicName() throws Exception {
+ TopicRegistrationResponse testSubject;
+ String distrNotificationTopicName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setDistrNotificationTopicName(distrNotificationTopicName);
+ }
+
+ @Test
+ public void testSetDistrStatusTopicName() throws Exception {
+ TopicRegistrationResponse testSubject;
+ String distrStatusTopicName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setDistrStatusTopicName(distrStatusTopicName);
+ }
+
+ @Test
+ public void testGetDistrNotificationTopicName() throws Exception {
+ TopicRegistrationResponse testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDistrNotificationTopicName();
+ }
+
+ @Test
+ public void testGetDistrStatusTopicName() throws Exception {
+ TopicRegistrationResponse testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDistrStatusTopicName();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java
new file mode 100644
index 0000000000..54fe824a38
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java
@@ -0,0 +1,50 @@
+package org.openecomp.sdc.be.distribution.api.client;
+
+import org.junit.Test;
+
+public class TopicUnregistrationResponseTest {
+
+ private TopicUnregistrationResponse createTestSubject() {
+ return new TopicUnregistrationResponse("", "", CambriaOperationStatus.AUTHENTICATION_ERROR, CambriaOperationStatus.AUTHENTICATION_ERROR);
+ }
+
+ @Test
+ public void testGetDistrNotificationTopicName() throws Exception {
+ TopicUnregistrationResponse testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDistrNotificationTopicName();
+ }
+
+ @Test
+ public void testGetDistrStatusTopicName() throws Exception {
+ TopicUnregistrationResponse testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDistrStatusTopicName();
+ }
+
+ @Test
+ public void testGetNotificationUnregisterResult() throws Exception {
+ TopicUnregistrationResponse testSubject;
+ CambriaOperationStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getNotificationUnregisterResult();
+ }
+
+ @Test
+ public void testGetStatusUnregisterResult() throws Exception {
+ TopicUnregistrationResponse testSubject;
+ CambriaOperationStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatusUnregisterResult();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/dto/ExternalRefDTOTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/dto/ExternalRefDTOTest.java
new file mode 100644
index 0000000000..28f01194b0
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/dto/ExternalRefDTOTest.java
@@ -0,0 +1,45 @@
+package org.openecomp.sdc.be.dto;
+
+import org.junit.Test;
+
+public class ExternalRefDTOTest {
+
+ private ExternalRefDTO createTestSubject() {
+ return new ExternalRefDTO();
+ }
+
+ @Test
+ public void testConstructor() throws Exception {
+ new ExternalRefDTO("mock");
+ }
+
+ @Test
+ public void testGetReferenceUUID() throws Exception {
+ ExternalRefDTO testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getReferenceUUID();
+ }
+
+ @Test
+ public void testSetReferenceUUID() throws Exception {
+ ExternalRefDTO testSubject;
+ String referenceUUID = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setReferenceUUID(referenceUUID);
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ ExternalRefDTO 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/dto/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/be/dto/TestSuite.java
new file mode 100644
index 0000000000..6178d3855f
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/dto/TestSuite.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.be.dto;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses(
+
+{ ExternalRefDTOTest.class })
+public class TestSuite { // nothing
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java
new file mode 100644
index 0000000000..94e040e2a3
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java
@@ -0,0 +1,452 @@
+package org.openecomp.sdc.be.ecomp;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Test;
+import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.openecomp.portalsdk.core.restful.domain.EcompRole;
+import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+
+public class EcompIntImplTest {
+
+ private EcompIntImpl createTestSubject() {
+ return new EcompIntImpl();
+ }
+
+ @Test(expected=PortalAPIException.class)
+ public void testPushUser() throws Exception {
+ EcompIntImpl testSubject;
+ EcompUser user = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.pushUser(user);
+ }
+
+ @Test(expected=PortalAPIException.class)
+ public void testEditUser() throws Exception {
+ EcompIntImpl testSubject;
+ String loginId = "";
+ EcompUser user = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.editUser(loginId, user);
+ }
+
+ @Test(expected=PortalAPIException.class)
+ public void testGetUser() throws Exception {
+ EcompIntImpl testSubject;
+ String loginId = "";
+ EcompUser result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getUser(loginId);
+ }
+
+ @Test(expected=PortalAPIException.class)
+ public void testGetUsers() throws Exception {
+ EcompIntImpl testSubject;
+ List<EcompUser> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getUsers();
+ }
+
+ @Test
+ public void testGetAvailableRoles() throws Exception {
+ EcompIntImpl testSubject;
+ List<EcompRole> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAvailableRoles();
+ }
+
+ /*@Test
+ public void testPushUserRole() throws Exception {
+ EcompIntImpl testSubject;
+ String loginId = "";
+ List<EcompRole> roles = null;
+
+ // test 1
+ testSubject = createTestSubject();
+ roles = null;
+ testSubject.pushUserRole(loginId, roles);
+ }*/
+
+ @Test(expected=PortalAPIException.class)
+ public void testGetUserRoles() throws Exception {
+ EcompIntImpl testSubject;
+ String loginId = "";
+ List<EcompRole> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getUserRoles(loginId);
+ }
+
+ @Test
+ public void testIsAppAuthenticated() throws Exception {
+ EcompIntImpl testSubject;
+ boolean result;
+ HttpServletRequestImpl httpServletRequestImpl = new HttpServletRequestImpl();
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isAppAuthenticated(httpServletRequestImpl);
+ }
+
+ @Test
+ public void testGetUserId() throws Exception {
+ EcompIntImpl testSubject;
+ HttpServletRequestImpl httpServletRequestImpl = new HttpServletRequestImpl();
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getUserId(httpServletRequestImpl);
+ }
+
+ private class HttpServletRequestImpl implements HttpServletRequest {
+
+ @Override
+ public Object getAttribute(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration getAttributeNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getContentLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ServletInputStream getInputStream() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getParameter(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration getParameterNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Map getParameterMap() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getProtocol() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getScheme() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getServerName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getServerPort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public BufferedReader getReader() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRemoteAddr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRemoteHost() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setAttribute(String name, Object o) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeAttribute(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Locale getLocale() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration getLocales() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isSecure() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public RequestDispatcher getRequestDispatcher(String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRealPath(String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getRemotePort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getLocalName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getLocalAddr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getLocalPort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getAuthType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Cookie[] getCookies() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getDateHeader(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getHeader(String name) {
+ // TODO Auto-generated method stub
+ return "mock";
+ }
+
+ @Override
+ public Enumeration getHeaders(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration getHeaderNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getIntHeader(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPathInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPathTranslated() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getContextPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getQueryString() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRemoteUser() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isUserInRole(String role) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRequestedSessionId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRequestURI() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public StringBuffer getRequestURL() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getServletPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public HttpSession getSession(boolean create) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public HttpSession getSession() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdValid() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromCookie() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromURL() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromUrl() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java
new file mode 100644
index 0000000000..c255aa353d
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/TestSuite.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.be.ecomp;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses(
+
+{ EcompIntImplTest.class, GenerateEcompErrorFileTest.class })
+public class TestSuite { // nothing
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java
new file mode 100644
index 0000000000..a47447b4c7
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverterTest.java
@@ -0,0 +1,263 @@
+package org.openecomp.sdc.be.ecomp.converters;
+
+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.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ArtifactMetadata;
+import org.openecomp.sdc.be.externalapi.servlet.representation.AssetMetadata;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceAssetDetailedMetadata;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceAssetMetadata;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceInstanceMetadata;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ServiceAssetDetailedMetadata;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ServiceAssetMetadata;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.DistributionStatusEnum;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+import mockit.Deencapsulation;
+
+public class AssetMetadataConverterTest {
+
+ private AssetMetadataConverter createTestSubject() {
+ return new AssetMetadataConverter();
+ }
+
+ @Test
+ public void testConvertToAssetMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ List<? extends Component> componentList = null;
+ String serverBaseURL = "";
+ boolean detailed = false;
+ Either<List<? extends AssetMetadata>, ResponseFormat> result;
+
+ // test 1
+ testSubject = createTestSubject();
+ componentList = null;
+ result = testSubject.convertToAssetMetadata(componentList, serverBaseURL, detailed);
+ }
+
+ @Test
+ public void testConvertToSingleAssetMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ Resource component = new Resource();
+ String serverBaseURL = "";
+ boolean detailed = false;
+ Either<? extends AssetMetadata, ResponseFormat> result;
+ component.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertToSingleAssetMetadata(component, serverBaseURL, detailed);
+ }
+
+ @Test
+ public void testConvertToMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ String serverBaseURL = "";
+ boolean detailed = false;
+ Resource curr = new Resource();
+ Either<? extends AssetMetadata, ResponseFormat> result;
+ curr.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "convertToMetadata", ComponentTypeEnum.RESOURCE, serverBaseURL,
+ detailed, curr);
+ }
+
+ @Test
+ public void testGenerateResourceMeatdata() throws Exception {
+ AssetMetadataConverter testSubject;
+ String serverBaseURL = "";
+ Resource curr = new Resource();
+ Either<? extends AssetMetadata, ResponseFormat> result;
+ curr.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "generateResourceMeatdata", serverBaseURL, true, curr);
+ }
+
+ @Test
+ public void testCreateMetadaObject() throws Exception {
+ AssetMetadataConverter testSubject;
+ AssetMetadata result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "createMetadaObject", true, ComponentTypeEnum.RESOURCE);
+ }
+
+ @Test
+ public void testGenerateServiceMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ String serverBaseURL = "";
+ boolean detailed = false;
+ Service curr = new Service();
+ curr.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
+ curr.setDistributionStatus(DistributionStatusEnum.DISTRIBUTED);
+ Either<? extends AssetMetadata, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "generateServiceMetadata", serverBaseURL, detailed, curr);
+ }
+
+ @Test
+ public void testConvertToAsset() throws Exception {
+ AssetMetadataConverter testSubject;
+ ResourceAssetMetadata asset = new ResourceAssetMetadata();
+ Resource component = new Resource();
+ String serverBaseURL = "";
+ ResourceAssetMetadata result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "convertToAsset", asset, component, serverBaseURL, true);
+ }
+
+ @Test
+ public void testConvertToResourceMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ ResourceAssetMetadata assetToPopulate = new ResourceAssetMetadata();
+ Resource resource = new Resource();
+ String serverBaseURL = "";
+ boolean detailed = false;
+ ResourceAssetMetadata result;
+ resource.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "convertToResourceMetadata", assetToPopulate, resource,
+ serverBaseURL, true);
+ }
+
+ @Test
+ public void testConvertToServiceAssetMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ ServiceAssetMetadata assetToPopulate = new ServiceAssetMetadata();
+ Service service = new Service();
+ service.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
+ service.setDistributionStatus(DistributionStatusEnum.DISTRIBUTED);
+ String serverBaseURL = "";
+ boolean detailed = false;
+ ServiceAssetMetadata result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "convertToServiceAssetMetadata", assetToPopulate, service,
+ serverBaseURL, true);
+ }
+
+ @Test
+ public void testConvertToResourceDetailedMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ ResourceAssetDetailedMetadata assetToPopulate = new ResourceAssetDetailedMetadata();
+ Resource resource = new Resource();
+ String serverBaseURL = "";
+ Either<ResourceAssetDetailedMetadata, StorageOperationStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "convertToResourceDetailedMetadata", assetToPopulate, resource,
+ serverBaseURL);
+ }
+
+ @Test
+ public void testConvertToServiceDetailedMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ ServiceAssetDetailedMetadata assetToPopulate = new ServiceAssetDetailedMetadata();
+ Service service = new Service();
+ String serverBaseURL = "";
+ Either<ServiceAssetDetailedMetadata, StorageOperationStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "convertToServiceDetailedMetadata", assetToPopulate, service,
+ serverBaseURL);
+ }
+
+ @Test
+ public void testPopulateResourceWithArtifacts() throws Exception {
+ AssetMetadataConverter testSubject;
+ ResourceAssetDetailedMetadata asset = new ResourceAssetDetailedMetadata();
+ Resource resource = new Resource();
+ String serverBaseURL = "";
+ Map<String, ArtifactDefinition> artifacts = new HashMap<>();
+ ResourceAssetDetailedMetadata result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "populateResourceWithArtifacts", asset, resource, serverBaseURL,
+ artifacts);
+ }
+
+ @Test
+ public void testPopulateServiceWithArtifacts() throws Exception {
+ AssetMetadataConverter testSubject;
+ ServiceAssetDetailedMetadata asset = new ServiceAssetDetailedMetadata();
+ Service service = new Service();
+ Map<String, ArtifactDefinition> artifacts = new HashMap<>();
+ ServiceAssetDetailedMetadata result;
+ service.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
+ service.setDistributionStatus(DistributionStatusEnum.DISTRIBUTED);
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "populateServiceWithArtifacts",
+ asset, Service.class, artifacts);
+ }
+
+ @Test
+ public void testPopulateAssetWithArtifacts() throws Exception {
+ AssetMetadataConverter testSubject;
+ Resource component = new Resource();
+ Map<String, ArtifactDefinition> artifacts = new HashMap<>();
+ List<ArtifactMetadata> result;
+
+ // test 1
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "populateAssetWithArtifacts", component, artifacts);
+ Assert.assertEquals(null, result);
+ }
+
+ @Test
+ public void testConvertToArtifactMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ String componentType = "";
+ String componentUUID = "";
+ String resourceInstanceName = "";
+ ArtifactMetadata result;
+
+ // test 1
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "convertToArtifactMetadata", artifact, componentType,
+ componentUUID, resourceInstanceName);
+ }
+
+ @Test
+ public void testConvertToResourceInstanceMetadata() throws Exception {
+ AssetMetadataConverter testSubject;
+ List<ComponentInstance> componentInstances = new LinkedList<>();
+ String componentType = "";
+ String componentUUID = "";
+ Either<List<ResourceInstanceMetadata>, StorageOperationStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "convertToResourceInstanceMetadata",
+ new Object[] { componentInstances, componentType, componentUUID });
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java
new file mode 100644
index 0000000000..528b9b6b69
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java
@@ -0,0 +1,25 @@
+package org.openecomp.sdc.be.ecomp.converters;
+
+import org.junit.Test;
+import org.openecomp.portalsdk.core.restful.domain.EcompRole;
+import org.openecomp.sdc.be.user.Role;
+
+public class EcompRoleConverterTest {
+
+ @Test
+ public void testConvertEcompRoleToRole() throws Exception {
+ EcompRole ecompRole = new EcompRole();
+ String result;
+
+ // test 1
+ for (Role iterable_element : Role.values()) {
+ ecompRole.setId(new Long(iterable_element.ordinal()));
+ EcompRoleConverter.convertEcompRoleToRole(ecompRole);
+ }
+
+ EcompRoleConverter.convertEcompRoleToRole(null);
+
+ ecompRole.setId(new Long(4523535));
+ EcompRoleConverter.convertEcompRoleToRole(ecompRole);
+ }
+} \ No newline at end of file