diff options
author | Tal Gitelman <tg851x@intl.att.com> | 2018-05-21 20:09:22 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-05-22 10:38:48 +0000 |
commit | 44288aebbfc62466e6e423c5041f5524ffc62d19 (patch) | |
tree | 655335043c4a1092fd2b410c7759d87809cc65b0 /catalog-be | |
parent | a1e1776d772f41b9102efee4c5a0b8c2032a83f5 (diff) |
new unit tests for sdc-be
Change-Id: I98f8a6c32f2603b55006ddd55789b72c1f1b050a
Issue-ID: SDC-1333
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be')
17 files changed, 1127 insertions, 11 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java index f0c8ec214f..a5982c1f01 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java @@ -82,7 +82,7 @@ public final class EcompUserConverter { convertedUser.setFirstName(ecompUser.getFirstName()); convertedUser.setLastName(ecompUser.getLastName()); - if (!ecompUser.getLoginId().isEmpty()) { + if (ecompUser.getLoginId() != null && !ecompUser.getLoginId().isEmpty()) { convertedUser.setUserId(ecompUser.getLoginId()); } else { convertedUser.setUserId(ecompUser.getOrgUserId()); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java new file mode 100644 index 0000000000..fa16003792 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java @@ -0,0 +1,28 @@ +package org.openecomp.sdc.be.ecomp.converters; + +import org.junit.Test; +import org.openecomp.portalsdk.core.restful.domain.EcompUser; +import org.openecomp.sdc.be.model.User; + +import fj.data.Either; + +public class EcompUserConverterTest { + + @Test + public void testConvertUserToEcompUser() throws Exception { + User asdcUser = new User(); + Either<EcompUser, String> result; + + // test 1 + result = EcompUserConverter.convertUserToEcompUser(asdcUser); + } + + @Test + public void testConvertEcompUserToUser() throws Exception { + EcompUser ecompUser = new EcompUser(); + Either<User, String> result; + + // test 1 + result = EcompUserConverter.convertEcompUserToUser(ecompUser); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/exception/SdcActionExceptionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/exception/SdcActionExceptionTest.java new file mode 100644 index 0000000000..487886eeca --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/exception/SdcActionExceptionTest.java @@ -0,0 +1,21 @@ +package org.openecomp.sdc.be.exception; + +import org.junit.Test; +import org.openecomp.sdc.be.dao.api.ActionStatus; + +public class SdcActionExceptionTest { + + private SdcActionException createTestSubject() { + return new SdcActionException(ActionStatus.AAI_ARTIFACT_GENERATION_FAILED); + } + + @Test + public void testGetActionStatus() throws Exception { + SdcActionException testSubject; + ActionStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getActionStatus(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionRespInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionRespInfoTest.java new file mode 100644 index 0000000000..329db3bc4d --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionRespInfoTest.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.be.externalapi.servlet.representation; + +import org.junit.Test; + +public class ServiceDistributionRespInfoTest { + + private ServiceDistributionRespInfo createTestSubject() { + return new ServiceDistributionRespInfo(); + } + + @Test + public void testCtr() throws Exception { + new ServiceDistributionRespInfo("mock"); + } + + @Test + public void testGetDistributionId() throws Exception { + ServiceDistributionRespInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDistributionId(); + } + + @Test + public void testSetDistributionId() throws Exception { + ServiceDistributionRespInfo testSubject; + String distributionId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDistributionId(distributionId); + } +}
\ No newline at end of file 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 7871dd9d2b..a206d5f531 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 @@ -4,6 +4,7 @@ import java.util.List; import org.apache.tinkerpop.gremlin.structure.T; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.mockito.Mockito; import org.openecomp.sdc.be.auditing.impl.AuditingManager; @@ -48,7 +49,7 @@ public class ComponentsUtilsTest { ConfigurationManager configurationManager = new ConfigurationManager(configurationSource); ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class)); } - + @Test public void testGetAuditingManager() throws Exception { ComponentsUtils testSubject; @@ -60,8 +61,6 @@ public class ComponentsUtilsTest { } - - @Test public void testConvertJsonToObjectUsingObjectMapper() throws Exception { ComponentsUtils testSubject; @@ -120,12 +119,17 @@ public class ComponentsUtilsTest { public void testGetResponseFormatByResource() throws Exception { ComponentsUtils testSubject; ActionStatus actionStatus = ActionStatus.ACCEPTED; - Resource resource = new Resource(); ResponseFormat result; - + Resource resource = null; // test 1 testSubject = createTestSubject(); result = testSubject.getResponseFormatByResource(actionStatus, resource); + resource = new Resource(); + result = testSubject.getResponseFormatByResource(actionStatus, resource); + result = testSubject.getResponseFormatByResource(ActionStatus.COMPONENT_VERSION_ALREADY_EXIST, resource); + result = testSubject.getResponseFormatByResource(ActionStatus.RESOURCE_NOT_FOUND, resource); + result = testSubject.getResponseFormatByResource(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, resource); + result = testSubject.getResponseFormatByResource(ActionStatus.COMPONENT_IN_USE, resource); } @@ -145,19 +149,21 @@ public class ComponentsUtilsTest { testSubject = createTestSubject(); resourceName = ""; result = testSubject.getResponseFormatByResource(actionStatus, resourceName); + result = testSubject.getResponseFormatByResource(ActionStatus.RESOURCE_NOT_FOUND, resourceName); } @Test public void testGetResponseFormatByCapabilityType() throws Exception { ComponentsUtils testSubject; - ActionStatus actionStatus = ActionStatus.ACCEPTED; CapabilityTypeDefinition capabilityType = new CapabilityTypeDefinition(); ResponseFormat result; // test 1 testSubject = createTestSubject(); - result = testSubject.getResponseFormatByCapabilityType(actionStatus, capabilityType); + result = testSubject.getResponseFormatByCapabilityType(ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST, null); + result = testSubject.getResponseFormatByCapabilityType(ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST, capabilityType); + result = testSubject.getResponseFormatByCapabilityType(ActionStatus.AAI_ARTIFACT_GENERATION_FAILED, capabilityType); } @@ -165,13 +171,16 @@ public class ComponentsUtilsTest { public void testGetResponseFormatByElement() throws Exception { ComponentsUtils testSubject; ActionStatus actionStatus = ActionStatus.ACCEPTED; - T obj = null; + Object obj = null; ResponseFormat result; // test 1 testSubject = createTestSubject(); obj = null; result = testSubject.getResponseFormatByElement(actionStatus, obj); + obj = new Object(); + result = testSubject.getResponseFormatByElement(actionStatus, obj); + result = testSubject.getResponseFormatByElement(ActionStatus.MISSING_CAPABILITY_TYPE, obj); } @@ -186,6 +195,12 @@ public class ComponentsUtilsTest { testSubject = createTestSubject(); user = null; result = testSubject.getResponseFormatByUser(actionStatus, user); + user = new User(); + result = testSubject.getResponseFormatByUser(ActionStatus.INVALID_USER_ID, user); + result = testSubject.getResponseFormatByUser(ActionStatus.INVALID_EMAIL_ADDRESS, user); + result = testSubject.getResponseFormatByUser(ActionStatus.INVALID_ROLE, user); + result = testSubject.getResponseFormatByUser(ActionStatus.USER_NOT_FOUND, user); + result = testSubject.getResponseFormatByUser(ActionStatus.ADDITIONAL_INFORMATION_EMPTY_STRING_NOT_ALLOWED, user); } @@ -226,9 +241,10 @@ public class ComponentsUtilsTest { // default test testSubject = createTestSubject(); result = testSubject.getResponseFormatByArtifactId(actionStatus, artifactId); + result = testSubject.getResponseFormatByArtifactId(ActionStatus.RESOURCE_NOT_FOUND, artifactId); } - + @Ignore @Test public void testGetInvalidContentErrorAndAudit() throws Exception { ComponentsUtils testSubject; @@ -260,7 +276,7 @@ public class ComponentsUtilsTest { @Test public void testAuditResource_1() throws Exception { ComponentsUtils testSubject; - ResponseFormat responseFormat = null; + ResponseFormat responseFormat = new ResponseFormat(); User modifier = null; String resourceName = ""; AuditingActionEnum actionEnum = null; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/DownloadArtifactLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/DownloadArtifactLogicTest.java new file mode 100644 index 0000000000..c68138e2d4 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/DownloadArtifactLogicTest.java @@ -0,0 +1,84 @@ +package org.openecomp.sdc.be.impl; + +import java.util.LinkedList; +import java.util.List; + +import javax.ws.rs.core.Response; + +import org.junit.Test; +import org.openecomp.sdc.be.dao.api.ResourceUploadStatus; +import org.openecomp.sdc.be.info.ArtifactAccessInfo; +import org.openecomp.sdc.be.resources.data.ESArtifactData; + +import com.att.aft.dme2.internal.jersey.core.util.Base64; + +import fj.data.Either; +import groovyjarjarantlr.ByteBuffer; + +public class DownloadArtifactLogicTest { + + private DownloadArtifactLogic createTestSubject() { + return new DownloadArtifactLogic(); + } + + @Test + public void testDownloadArtifact() throws Exception { + DownloadArtifactLogic testSubject; + String artifactName = ""; + String artifactId = ""; + Response result; + + // default test + testSubject = createTestSubject(); + result = testSubject.downloadArtifact(artifactName, Either.right(ResourceUploadStatus.COMPONENT_NOT_EXIST), artifactId); + result = testSubject.downloadArtifact(artifactName, Either.right(ResourceUploadStatus.ALREADY_EXIST), artifactId); + ESArtifactData ad = new ESArtifactData(); + ad.setDataAsArray(Base64.encode("mock")); + result = testSubject.downloadArtifact(artifactName, Either.left(ad ), artifactId); + } + + @Test + public void testConvertArtifactList() throws Exception { + DownloadArtifactLogic testSubject; + List<ESArtifactData> artifactsList = new LinkedList<>(); + artifactsList.add(new ESArtifactData()); + String servletPath = "mock"; + List<ArtifactAccessInfo> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.convertArtifactList(artifactsList, servletPath); + } + + @Test + public void testCreateArtifactListResponse() throws Exception { + DownloadArtifactLogic testSubject; + String serviceName = "mock"; + Either<List<ESArtifactData>, ResourceUploadStatus> getArtifactsStatus = Either.right(ResourceUploadStatus.COMPONENT_NOT_EXIST); + String servletPath = "mock"; + Response result; + + // default test + testSubject = createTestSubject(); + + result = testSubject.createArtifactListResponse(serviceName, getArtifactsStatus, servletPath); + getArtifactsStatus = Either.right(ResourceUploadStatus.ALREADY_EXIST); + result = testSubject.createArtifactListResponse(serviceName, getArtifactsStatus, servletPath); + List<ESArtifactData> artifactsList = new LinkedList<>(); + artifactsList.add(new ESArtifactData()); + getArtifactsStatus = Either.left(artifactsList); + result = testSubject.createArtifactListResponse(serviceName, getArtifactsStatus, servletPath); + } + + @Test + public void testBuildResponse() throws Exception { + DownloadArtifactLogic testSubject; + int status = 0; + String errorMessage = ""; + Response result; + + // default test + testSubject = createTestSubject(); + result = testSubject.buildResponse(status, errorMessage); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ForwardingPathUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ForwardingPathUtilsTest.java new file mode 100644 index 0000000000..099d622578 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ForwardingPathUtilsTest.java @@ -0,0 +1,252 @@ +package org.openecomp.sdc.be.impl; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.javatuples.Pair; +import org.junit.Test; +import org.openecomp.sdc.be.components.impl.ResponseFormatManager; +import org.openecomp.sdc.be.components.merge.instance.DataForMergeHolder; +import org.openecomp.sdc.be.datamodel.NameIdPair; +import org.openecomp.sdc.be.datamodel.NameIdPairWrapper; +import org.openecomp.sdc.be.datamodel.ServiceRelations; +import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.Service; + +import com.google.common.collect.SetMultimap; +import com.google.common.collect.TreeMultimap; + +import mockit.Deencapsulation; + +public class ForwardingPathUtilsTest { + + private ForwardingPathUtils createTestSubject() { + return new ForwardingPathUtils(); + } + + @Test + public void testConvertServiceToServiceRelations() throws Exception { + ForwardingPathUtils testSubject; + Service service = new Service(); + ServiceRelations result; + + // default test + testSubject = createTestSubject(); + result = testSubject.convertServiceToServiceRelations(service); + List<ComponentInstance> resourceInstances = new LinkedList<>(); + ComponentInstance e = new ComponentInstance(); + e.setCapabilities(new HashMap<>()); + resourceInstances.add(e); + service.setComponentInstances(resourceInstances); + + result = testSubject.convertServiceToServiceRelations(service); + } + + @Test + public void testAddNodes() throws Exception { + ForwardingPathUtils testSubject; + List<NameIdPairWrapper> cpOptions = new LinkedList<>(); + Map<NameIdPair, Set<NameIdPair>> options = new HashMap<>(); + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "addNodes", cpOptions, options); + } + + @Test + public void testCreateWrapper() throws Exception { + ForwardingPathUtils testSubject; + NameIdPair cpOption = new NameIdPair("mock", "mock"); + NameIdPairWrapper result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "createWrapper", cpOption); + } + + @Test + public void testGetResponseFormatManager() throws Exception { + ForwardingPathUtils testSubject; + ResponseFormatManager result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "getResponseFormatManager"); + } + + @Test + public void testFindForwardingPathNamesToDeleteOnComponentInstanceDeletion() throws Exception { + ForwardingPathUtils testSubject; + Service containerService = new Service(); + containerService.setForwardingPaths(new HashMap<>()); + String componentInstanceId = ""; + Set<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.findForwardingPathNamesToDeleteOnComponentInstanceDeletion(containerService, + componentInstanceId); + } + + @Test + public void testFindForwardingPathToDeleteOnCIDeletion() throws Exception { + ForwardingPathUtils testSubject; + Service containerService = new Service(); + containerService.setForwardingPaths(new HashMap<>()); + String componentInstanceId = ""; + Map<String, ForwardingPathDataDefinition> result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "findForwardingPathToDeleteOnCIDeletion", containerService, + componentInstanceId); + } + + @Test + public void testElementContainsCI_1() throws Exception { + ForwardingPathUtils testSubject; + ForwardingPathElementDataDefinition elementDataDefinitions = new ForwardingPathElementDataDefinition(); + elementDataDefinitions.setFromNode("mock"); + String componentInstanceId = "mock"; + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "elementContainsCI", elementDataDefinitions, componentInstanceId); + } + + @Test + public void testUpdateForwardingPathOnVersionChange() throws Exception { + ForwardingPathUtils testSubject; + Service containerService = new Service(); + containerService.setForwardingPaths(new HashMap<>()); + DataForMergeHolder dataHolder = new DataForMergeHolder(); + Component updatedContainerComponent = new Service(); + String newInstanceId = ""; + Pair<Map<String, ForwardingPathDataDefinition>, Map<String, ForwardingPathDataDefinition>> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.updateForwardingPathOnVersionChange(containerService, dataHolder, + updatedContainerComponent, newInstanceId); + } + + @Test + public void testGetForwardingPathsToBeDeletedOnVersionChange() throws Exception { + ForwardingPathUtils testSubject; + Service containerService = new Service(); + containerService.setForwardingPaths(new HashMap<>()); + DataForMergeHolder dataHolder = new DataForMergeHolder(); + Component updatedContainerComponent = new Service(); + Set<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getForwardingPathsToBeDeletedOnVersionChange(containerService, dataHolder, + updatedContainerComponent); + } + + @Test + public void testUpdateCI() throws Exception { + ForwardingPathUtils testSubject; + ForwardingPathDataDefinition inFP = new ForwardingPathDataDefinition(); + inFP.setPathElements(new ListDataDefinition<>()); + String oldCI = ""; + String newCI = ""; + ForwardingPathDataDefinition result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "updateCI", inFP, oldCI, newCI); + } + + @Test + public void testUpdateElement() throws Exception { + ForwardingPathUtils testSubject; + ForwardingPathElementDataDefinition element = new ForwardingPathElementDataDefinition(); + element.setFromNode("mock"); + element.setToNode("mock"); + element.setToCP("mock"); + String oldCI = ""; + String newCI = ""; + ForwardingPathElementDataDefinition result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "updateElement", element, oldCI, newCI); + } + + @Test + public void testElementContainsCIAndForwarder_1() throws Exception { + ForwardingPathUtils testSubject; + ForwardingPathElementDataDefinition elementDataDefinitions = new ForwardingPathElementDataDefinition(); + elementDataDefinitions.setFromNode("mock"); + elementDataDefinitions.setToNode("mock"); + elementDataDefinitions.setToCP("mock"); + String oldCIId = "mock"; + Component newCI = new Resource(); + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "elementContainsCIAndForwarder", elementDataDefinitions, oldCIId, + newCI); + } + + @Test + public void testCiContainsForwarder() throws Exception { + ForwardingPathUtils testSubject; + Component newCI = new Resource(); + String capabilityID = "mock"; + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "ciContainsForwarder", newCI, capabilityID); + newCI.setCapabilities(new HashMap<>()); + result = Deencapsulation.invoke(testSubject, "ciContainsForwarder", newCI, capabilityID); + } + + @Test + public void testElementContainsCIAndDoesNotContainForwarder() throws Exception { + ForwardingPathUtils testSubject; + ForwardingPathDataDefinition forwardingPathDataDefinition = new ForwardingPathDataDefinition(); + ListDataDefinition<ForwardingPathElementDataDefinition> pathElements = new ListDataDefinition<>(); + forwardingPathDataDefinition.setPathElements(pathElements); + String oldCIId = ""; + Component newCI = new Resource(); + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "elementContainsCIAndDoesNotContainForwarder", + forwardingPathDataDefinition, oldCIId, newCI); + } + + @Test + public void testElementContainsCIAndDoesNotContainForwarder_1() throws Exception { + ForwardingPathUtils testSubject; + ForwardingPathElementDataDefinition elementDataDefinitions = new ForwardingPathElementDataDefinition(); + elementDataDefinitions.setFromNode("mock"); + elementDataDefinitions.setToNode("mock"); + elementDataDefinitions.setToCP("mock"); + String oldCIId = ""; + Component newCI = new Resource(); + boolean result; + + // default test + testSubject = createTestSubject(); + result = Deencapsulation.invoke(testSubject, "elementContainsCIAndDoesNotContainForwarder", + elementDataDefinitions, oldCIId, newCI); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java new file mode 100644 index 0000000000..be42541295 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java @@ -0,0 +1,43 @@ +package org.openecomp.sdc.be.impl; + +import org.junit.Test; +import org.openecomp.sdc.be.user.IUserBusinessLogic; + +import com.google.gson.Gson; + +public class ServletUtilsTest { + + private ServletUtils createTestSubject() { + return new ServletUtils(); + } + + @Test + public void testGetComponentsUtils() throws Exception { + ServletUtils testSubject; + ComponentsUtils result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getComponentsUtils(); + } + + @Test + public void testGetGson() throws Exception { + ServletUtils testSubject; + Gson result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getGson(); + } + + @Test + public void testGetUserAdmin() throws Exception { + ServletUtils testSubject; + IUserBusinessLogic result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getUserAdmin(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java index 4bff2ecdeb..c947d6258a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java @@ -1,6 +1,7 @@ package org.openecomp.sdc.be.info; import org.junit.Test; +import org.openecomp.sdc.be.resources.data.ESArtifactData; public class ArtifactAccessInfoTest { @@ -9,6 +10,11 @@ public class ArtifactAccessInfoTest { return new ArtifactAccessInfo(); } + @Test + public void testCtor() throws Exception { + new ArtifactAccessInfo(new ESArtifactData()); + new ArtifactAccessInfo(new ESArtifactData(), "mock"); + } @Test public void testGetName() throws Exception { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java index 23abecb67d..698be20124 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java @@ -9,6 +9,10 @@ public class DistributionStatusOfServiceInfoTest { return new DistributionStatusOfServiceInfo(); } + @Test + public void testCtor() throws Exception { + new DistributionStatusOfServiceInfo("","","",""); + } @Test public void testGetDistributionID() throws Exception { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusTest.java new file mode 100644 index 0000000000..f8ce8ade58 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusTest.java @@ -0,0 +1,39 @@ +package org.openecomp.sdc.be.info; + +import org.junit.Test; + +public class DistributionStatusTest { + + private DistributionStatus createTestSubject() { + return DistributionStatus.DEPLOYED; + } + + @Test + public void testGetName() throws Exception { + DistributionStatus testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getName(); + } + + @Test + public void testGetAuditingStatus() throws Exception { + DistributionStatus testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAuditingStatus(); + } + + @Test + public void testGetStatusByAuditingStatusName() throws Exception { + String auditingStatus = ""; + DistributionStatus result; + + // default test + result = DistributionStatus.getStatusByAuditingStatusName(auditingStatus); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/MergedArtifactInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/MergedArtifactInfoTest.java new file mode 100644 index 0000000000..ce86e81342 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/MergedArtifactInfoTest.java @@ -0,0 +1,131 @@ +package org.openecomp.sdc.be.info; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.junit.Test; +import org.openecomp.sdc.be.model.ArtifactDefinition; + +import mockit.Deencapsulation; + +public class MergedArtifactInfoTest { + + private MergedArtifactInfo createTestSubject() { + MergedArtifactInfo testSubject = new MergedArtifactInfo(); + testSubject.setJsonArtifactTemplate(new ArtifactTemplateInfo()); + LinkedList<ArtifactDefinition> createdArtifact = new LinkedList<>(); + ArtifactDefinition e = new ArtifactDefinition(); + e.setArtifactName("mock"); + createdArtifact.add(e); + testSubject.setCreatedArtifact(createdArtifact); + return testSubject; + } + + @Test + public void testGetCreatedArtifact() throws Exception { + MergedArtifactInfo testSubject; + List<ArtifactDefinition> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCreatedArtifact(); + } + + @Test + public void testSetCreatedArtifact() throws Exception { + MergedArtifactInfo testSubject; + List<ArtifactDefinition> createdArtifact = new LinkedList<>(); + + // default test + testSubject = createTestSubject(); + testSubject.setCreatedArtifact(createdArtifact); + } + + @Test + public void testGetJsonArtifactTemplate() throws Exception { + MergedArtifactInfo testSubject; + ArtifactTemplateInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getJsonArtifactTemplate(); + } + + @Test + public void testSetJsonArtifactTemplate() throws Exception { + MergedArtifactInfo testSubject; + ArtifactTemplateInfo jsonArtifactTemplate = new ArtifactTemplateInfo(); + + // default test + testSubject = createTestSubject(); + testSubject.setJsonArtifactTemplate(jsonArtifactTemplate); + } + + @Test + public void testGetListToAssociateArtifactToGroup() throws Exception { + MergedArtifactInfo testSubject; + List<ArtifactTemplateInfo> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getListToAssociateArtifactToGroup(); + } + + @Test + public void testGetListToDissotiateArtifactFromGroup() throws Exception { + MergedArtifactInfo testSubject; + List<ArtifactDefinition> deletedArtifacts = new LinkedList<>(); + List<ArtifactDefinition> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getListToDissotiateArtifactFromGroup(deletedArtifacts); + } + + @Test + public void testGetListToUpdateArtifactInGroup() throws Exception { + MergedArtifactInfo testSubject; + List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>> result; + + // default test + testSubject = createTestSubject(); + + result = testSubject.getListToUpdateArtifactInGroup(); + } + + @Test + public void testGetUpdateArtifactsInGroup() throws Exception { + MergedArtifactInfo testSubject; + List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>> resList = new LinkedList<>(); + List<ArtifactTemplateInfo> jsonArtifacts = new LinkedList<>(); + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "getUpdateArtifactsInGroup", resList, resList); + } + + @Test + public void testGetNewArtifactsInGroup() throws Exception { + MergedArtifactInfo testSubject; + List<ArtifactTemplateInfo> resList = new LinkedList<>(); + List<ArtifactTemplateInfo> jsonArtifacts = new LinkedList<>(); + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "getNewArtifactsInGroup", resList, resList); + } + + @Test + public void testCreateArtifactsGroupSet() throws Exception { + MergedArtifactInfo testSubject; + List<ArtifactTemplateInfo> parsedGroupTemplateList = new LinkedList<>(); + Set<String> parsedArtifactsName = new HashSet<>(); + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "createArtifactsGroupSet", parsedGroupTemplateList, parsedArtifactsName); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifactsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifactsTest.java new file mode 100644 index 0000000000..ebb7d2febb --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifactsTest.java @@ -0,0 +1,56 @@ +package org.openecomp.sdc.be.info; + +import java.util.EnumMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; +import org.openecomp.sdc.be.model.ArtifactDefinition; + +public class NodeTypeInfoToUpdateArtifactsTest { + + private NodeTypeInfoToUpdateArtifacts createTestSubject() { + return new NodeTypeInfoToUpdateArtifacts("", null); + } + + @Test + public void testGetNodeName() throws Exception { + NodeTypeInfoToUpdateArtifacts testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getNodeName(); + } + + @Test + public void testSetNodeName() throws Exception { + NodeTypeInfoToUpdateArtifacts testSubject; + String nodeName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setNodeName(nodeName); + } + + @Test + public void testGetNodeTypesArtifactsToHandle() throws Exception { + NodeTypeInfoToUpdateArtifacts testSubject; + Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getNodeTypesArtifactsToHandle(); + } + + @Test + public void testSetNodeTypesArtifactsToHandle() throws Exception { + NodeTypeInfoToUpdateArtifacts testSubject; + Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = null; + + // default test + testSubject = createTestSubject(); + testSubject.setNodeTypesArtifactsToHandle(nodeTypesArtifactsToHandle); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/OperationalEnvInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/OperationalEnvInfoTest.java new file mode 100644 index 0000000000..67ee993675 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/OperationalEnvInfoTest.java @@ -0,0 +1,189 @@ +package org.openecomp.sdc.be.info; + +import org.junit.Test; + +public class OperationalEnvInfoTest { + + private OperationalEnvInfo createTestSubject() { + return new OperationalEnvInfo(); + } + + @Test + public void testGetOperationalEnvId() throws Exception { + OperationalEnvInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperationalEnvId(); + } + + @Test + public void testSetOperationalEnvId() throws Exception { + OperationalEnvInfo testSubject; + String operationalEnvId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setOperationalEnvId(operationalEnvId); + } + + @Test + public void testGetOperationalEnvName() throws Exception { + OperationalEnvInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperationalEnvName(); + } + + @Test + public void testSetOperationalEnvName() throws Exception { + OperationalEnvInfo testSubject; + String operationalEnvName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setOperationalEnvName(operationalEnvName); + } + + @Test + public void testGetOperationalEnvType() throws Exception { + OperationalEnvInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperationalEnvType(); + } + + @Test + public void testSetOperationalEnvType() throws Exception { + OperationalEnvInfo testSubject; + String operationalEnvType = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setOperationalEnvType(operationalEnvType); + } + + @Test + public void testGetOperationalEnvStatus() throws Exception { + OperationalEnvInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOperationalEnvStatus(); + } + + @Test + public void testSetOperationalEnvStatus() throws Exception { + OperationalEnvInfo testSubject; + String operationalEnvStatus = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setOperationalEnvStatus(operationalEnvStatus); + } + + @Test + public void testGetTenantContext() throws Exception { + OperationalEnvInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getTenantContext(); + } + + @Test + public void testSetTenantContext() throws Exception { + OperationalEnvInfo testSubject; + String tenantContext = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setTenantContext(tenantContext); + } + + @Test + public void testGetWorkloadContext() throws Exception { + OperationalEnvInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getWorkloadContext(); + } + + @Test + public void testSetWorkloadContext() throws Exception { + OperationalEnvInfo testSubject; + String workloadContext = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setWorkloadContext(workloadContext); + } + + @Test + public void testGetResourceVersion() throws Exception { + OperationalEnvInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceVersion(); + } + + @Test + public void testSetResourceVersion() throws Exception { + OperationalEnvInfo testSubject; + String resourceVersion = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceVersion(resourceVersion); + } + + @Test + public void testGetRelationships() throws Exception { + OperationalEnvInfo testSubject; + RelationshipList result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationships(); + } + + @Test + public void testSetRelationships() throws Exception { + OperationalEnvInfo testSubject; + RelationshipList relationships = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationships(relationships); + } + + @Test + public void testToString() throws Exception { + OperationalEnvInfo testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } + + @Test + public void testCreateFromJson() throws Exception { + String json = "{}"; + OperationalEnvInfo result; + + // default test + result = OperationalEnvInfo.createFromJson(json); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelatedToPropertyTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelatedToPropertyTest.java new file mode 100644 index 0000000000..9bfa6a5216 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelatedToPropertyTest.java @@ -0,0 +1,50 @@ +package org.openecomp.sdc.be.info; + +import org.junit.Test; + +public class RelatedToPropertyTest { + + private RelatedToProperty createTestSubject() { + return new RelatedToProperty(); + } + + @Test + public void testGetPropertyKey() throws Exception { + RelatedToProperty testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getPropertyKey(); + } + + @Test + public void testSetPropertyKey() throws Exception { + RelatedToProperty testSubject; + String propertyKey = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setPropertyKey(propertyKey); + } + + @Test + public void testGetPropertyValue() throws Exception { + RelatedToProperty testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getPropertyValue(); + } + + @Test + public void testSetPropertyValue() throws Exception { + RelatedToProperty testSubject; + String propertyValue = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setPropertyValue(propertyValue); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipDataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipDataTest.java new file mode 100644 index 0000000000..3a3ac2c577 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipDataTest.java @@ -0,0 +1,50 @@ +package org.openecomp.sdc.be.info; + +import org.junit.Test; + +public class RelationshipDataTest { + + private RelationshipData createTestSubject() { + return new RelationshipData(); + } + + @Test + public void testSetRelationshipkey() throws Exception { + RelationshipData testSubject; + String relationshipKey = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationshipkey(relationshipKey); + } + + @Test + public void testGetRelationshipKey() throws Exception { + RelationshipData testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationshipKey(); + } + + @Test + public void testSetRelationshipValue() throws Exception { + RelationshipData testSubject; + String relationshipValue = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationshipValue(relationshipValue); + } + + @Test + public void testGetRelationshipValue() throws Exception { + RelationshipData testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationshipValue(); + } +}
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipTest.java new file mode 100644 index 0000000000..8463495542 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipTest.java @@ -0,0 +1,112 @@ +package org.openecomp.sdc.be.info; + +import java.util.List; + +import org.junit.Test; + +public class RelationshipTest { + + private Relationship createTestSubject() { + return new Relationship(); + } + + @Test + public void testGetRelatedTo() throws Exception { + Relationship testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelatedTo(); + } + + @Test + public void testSetRelatedTo() throws Exception { + Relationship testSubject; + String relatedTo = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelatedTo(relatedTo); + } + + @Test + public void testGetRelatedLink() throws Exception { + Relationship testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelatedLink(); + } + + @Test + public void testSetRelatedLink() throws Exception { + Relationship testSubject; + String relatedLink = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelatedLink(relatedLink); + } + + @Test + public void testGetRelationshipData() throws Exception { + Relationship testSubject; + List<RelationshipData> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationshipData(); + } + + @Test + public void testSetRelationshipData() throws Exception { + Relationship testSubject; + List<RelationshipData> relationshipData = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationshipData(relationshipData); + } + + @Test + public void testGetRelationshipLabel() throws Exception { + Relationship testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationshipLabel(); + } + + @Test + public void testSetRelationshipLabel() throws Exception { + Relationship testSubject; + String relationshipLabel = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationshipLabel(relationshipLabel); + } + + @Test + public void testGetRelatedToProperty() throws Exception { + Relationship testSubject; + List<RelatedToProperty> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelatedToProperty(); + } + + @Test + public void testSetRelatedToProperty() throws Exception { + Relationship testSubject; + List<RelatedToProperty> relatedToProperty = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRelatedToProperty(relatedToProperty); + } +}
\ No newline at end of file |