From 914a63fedde46ac22466bd114f11ba35266fde28 Mon Sep 17 00:00:00 2001 From: Yuli Shlosberg Date: Wed, 18 Oct 2017 16:45:59 +0300 Subject: add more unit tests to BE components Change-Id: Ic14375454aac2960cd9b250e98991ca073e17a24 Issue-Id: SDC-467 Signed-off-by: Yuli Shlosberg (cherry picked from commit 8c4c1dd56dedace1c59d32f5c51c285da05301bf) --- .../be/components/ServiceBusinessLogicTest.java | 24 +++++---- .../sdc/be/servlets/CsarBuildServletTest.java | 49 +++++++++++++++++ .../sdc/be/servlets/RepresentationUtilsTest.java | 48 +++++++++++++++++ .../openecomp/sdc/be/tosca/ArtifactTypesTest.java | 38 ++++++++++++++ .../sdc/be/tosca/ToscaRepresentationTest.java | 61 ++++++++++++++++++++++ 5 files changed, 210 insertions(+), 10 deletions(-) create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java (limited to 'catalog-be/src/test/java/org') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java index d8b82da396..95845c3660 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java @@ -20,7 +20,19 @@ package org.openecomp.sdc.be.components; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletContext; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.Ignore; @@ -70,15 +82,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; +import fj.data.Either; public class ServiceBusinessLogicTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java new file mode 100644 index 0000000000..daacb79de5 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java @@ -0,0 +1,49 @@ +package org.openecomp.sdc.be.servlets; + +import javax.annotation.Generated; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; + +import org.junit.Test; +import org.openecomp.sdc.be.resources.data.ESArtifactData; + +import ch.qos.logback.classic.Logger; + + +public class CsarBuildServletTest { + + private CsarBuildServlet createTestSubject() { + return new CsarBuildServlet(); + } + + + @Test + public void testGetDefaultTemplate() throws Exception { + CsarBuildServlet testSubject; + HttpServletRequest request = null; + String serviceName = ""; + String serviceVersion = ""; + Response result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDefaultTemplate(request, serviceName, serviceVersion); + } + + + @Test + public void testGetToscaCsarTemplate() throws Exception { + CsarBuildServlet testSubject; + HttpServletRequest request = null; + String serviceName = ""; + String serviceVersion = ""; + Response result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getToscaCsarTemplate(request, serviceName, serviceVersion); + } + + + +} \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java new file mode 100644 index 0000000000..c56fd474b4 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RepresentationUtilsTest.java @@ -0,0 +1,48 @@ +package org.openecomp.sdc.be.servlets; + +import javax.annotation.Generated; + +import org.apache.tinkerpop.gremlin.structure.T; +import org.junit.Test; +import org.openecomp.sdc.be.model.ArtifactDefinition; + +public class RepresentationUtilsTest { + + private RepresentationUtils createTestSubject() { + return new RepresentationUtils(); + } + + + @Test + public void testConvertJsonToArtifactDefinitionForUpdate() throws Exception { + String content = ""; + Class clazz = null; + ArtifactDefinition result; + + // default test + result = RepresentationUtils.convertJsonToArtifactDefinitionForUpdate(content, clazz); + } + + + @Test + public void testToRepresentation() throws Exception { + T elementToRepresent = null; + Object result; + + // default test + result = RepresentationUtils.toRepresentation(elementToRepresent); + } + + + + + @Test + public void testConvertJsonToArtifactDefinition() throws Exception { + String content = ""; + Class clazz = null; + ArtifactDefinition result; + + // default test + result = RepresentationUtils.convertJsonToArtifactDefinition(content, clazz); + } +} \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java new file mode 100644 index 0000000000..dec4e78008 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ArtifactTypesTest.java @@ -0,0 +1,38 @@ +package org.openecomp.sdc.be.tosca; + +import java.util.List; + +import javax.annotation.Generated; + +import org.junit.Test; +import org.openecomp.sdc.generator.data.ArtifactType; + + +public class ArtifactTypesTest { + + private ArtifactTypes createTestSubject() { + return new ArtifactTypes(); + } + + + @Test + public void testGetArtifactTypes() throws Exception { + ArtifactTypes testSubject; + List result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactTypes(); + } + + + @Test + public void testSetArtifactTypes() throws Exception { + ArtifactTypes testSubject; + List artifactTypes = null; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactTypes(artifactTypes); + } +} \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java new file mode 100644 index 0000000000..9af90bb9e4 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaRepresentationTest.java @@ -0,0 +1,61 @@ +package org.openecomp.sdc.be.tosca; + +import java.util.List; + +import javax.annotation.Generated; + +import org.apache.commons.lang3.tuple.Triple; +import org.junit.Test; +import org.openecomp.sdc.be.model.Component; + + +public class ToscaRepresentationTest { + + private ToscaRepresentation createTestSubject() { + return new ToscaRepresentation(); + } + + + @Test + public void testGetMainYaml() throws Exception { + ToscaRepresentation testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMainYaml(); + } + + + @Test + public void testSetMainYaml() throws Exception { + ToscaRepresentation testSubject; + String mainYaml = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setMainYaml(mainYaml); + } + + + @Test + public void testGetDependencies() throws Exception { + ToscaRepresentation testSubject; + List> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDependencies(); + } + + + @Test + public void testSetDependencies() throws Exception { + ToscaRepresentation testSubject; + List> dependancies = null; + + // default test + testSubject = createTestSubject(); + testSubject.setDependencies(dependancies); + } +} \ No newline at end of file -- cgit 1.2.3-korg