aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authorayalaben <ayala.benzvi@amdocs.com>2018-01-03 08:38:27 +0200
committerayalaben <ayala.benzvi@amdocs.com>2018-01-03 14:55:56 +0200
commit5c5d34c913a2d8451061b44a8ee2fec19354316c (patch)
tree9abde771395824756bfe13dde9e0faa3b1ffe453 /openecomp-be/lib
parent0abdaacf1dffaabf8fed86bc04b97105d9008385 (diff)
Unit Tests
Change-Id: I39ee00e80475aa93b0f99a350b56754c31c6e9b6 Issue-ID: SDC-860 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java49
2 files changed, 28 insertions, 28 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java
index be0686ef5a..2210932669 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java
@@ -1,5 +1,6 @@
package org.openecomp.core.utilities.file;
+import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.IOException;
@@ -26,7 +27,8 @@ public class FileContentHandlerTest {
final byte[] content = new byte[size];
Arrays.fill(content, (byte) 44);
contentHandler.addFile(FILE_NAME, content);
- assertEquals(contentHandler.processFileContent(FILE_NAME, optional -> {
+
+ byte[] actualContent = contentHandler.processFileContent(FILE_NAME, optional -> {
try {
byte[] buffer = new byte[size];
@@ -37,7 +39,8 @@ public class FileContentHandlerTest {
throw new RuntimeException("Unexpected error", e);
}
- }), content);
+ });
+ Assert.assertTrue(Arrays.equals(actualContent, content));
}
@Test
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
index 418da9a770..74bdeef16e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
@@ -28,7 +28,6 @@ import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.commons.health.data.HealthInfo;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.UserInfo;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Item;
@@ -49,6 +48,8 @@ import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.ByteArrayInputStream;
@@ -65,10 +66,15 @@ public class ServiceModelDaoFactoryTest {
private static final String baseServiceTemplateName = "baseYaml.yaml";
private static String artifact001;
- static {
+ @BeforeMethod
+ public void setUp(){
SessionContextProviderFactory.getInstance().createInterface().create("test");
}
+ @AfterMethod
+ public void tearDaown(){
+ SessionContextProviderFactory.getInstance().createInterface().close();
+ }
@Test
public void storeServiceModelTest() {
@@ -85,14 +91,6 @@ public class ServiceModelDaoFactoryTest {
serviceModelDaoZusammen.storeServiceModel(vspId, version, model);
}
- private SessionContext getSessionContext() {
- SessionContext context = new SessionContext();
- context.setUser(new UserInfo("USER_A"));
- context.setTenant("asdc");
- return context;
- }
-
-
@Test
public void getServiceModelTest() {
@@ -133,14 +131,13 @@ public class ServiceModelDaoFactoryTest {
serviceModelElementInfo);
zusammenAdaptor.addElement(element);
- Object model =
+ ToscaServiceModel model =
serviceModelDaoZusammen.getServiceModel(vspId, version);
Assert.assertNotNull(model);
- Assert.assertTrue(model instanceof ToscaServiceModel);
- if (model instanceof ToscaServiceModel) {
- setArtifact((ToscaServiceModel) model);
- }
+ setArtifact(model);
+ Assert.assertEquals(artifact001,"dataFileName");
+
}
private static void setArtifact(ToscaServiceModel model) {
@@ -173,15 +170,15 @@ public class ServiceModelDaoFactoryTest {
Map<String, byte[]> artifacts = new HashMap<>();
artifacts.put("art1", "this is art1".getBytes());
artifacts.put("art2", ("this is art2 desc:" + CommonMethods.nextUuId()).getBytes());
- artifacts.put("art2", ("this is art3 desc:" + CommonMethods.nextUuId()).getBytes());
- artifacts.put("art2", ("this is art4 desc:" + CommonMethods.nextUuId()).getBytes());
+ artifacts.put("art3", ("this is art3 desc:" + CommonMethods.nextUuId()).getBytes());
+ artifacts.put("art4", ("this is art4 desc:" + CommonMethods.nextUuId()).getBytes());
FileContentHandler fileContentHandler = new FileContentHandler();
fileContentHandler.putAll(artifacts);
return fileContentHandler;
}
- public ServiceTemplate getServiceTemplate() {
+ private ServiceTemplate getServiceTemplate() {
ServiceTemplate serviceTemplate = new ServiceTemplate();
serviceTemplate.setTosca_definitions_version("version 1.0");
serviceTemplate.setDescription(CommonMethods.nextUuId());
@@ -191,18 +188,18 @@ public class ServiceModelDaoFactoryTest {
private class ZusammenAdaptorMock implements ZusammenAdaptor {
private ItemVersion itemVersion;
- private Map<String, ElementInfo> elementInfoMap = new HashMap();
+ private Map<String, ElementInfo> elementInfoMap = new HashMap<>();
private Collection<Element> elements = new ArrayList<>();
- public void setItemVersion(ItemVersion itemVersion) {
+ private void setItemVersion(ItemVersion itemVersion) {
this.itemVersion = itemVersion;
}
- public void addElementInfo(String key, ElementInfo elementInfo) {
+ private void addElementInfo(String key, ElementInfo elementInfo) {
elementInfoMap.put(key, elementInfo);
}
- public void addElement(Element element) {
+ private void addElement(Element element) {
elements.add(element);
}
@@ -225,14 +222,14 @@ public class ServiceModelDaoFactoryTest {
@Override
public Optional<Element> getElement(SessionContext context, ElementContext elementContext,
String elementId) {
- return null;
+ return Optional.empty();
}
@Override
public Optional<Element> getElementByName(SessionContext context,
ElementContext elementContext,
Id parentElementId, String elementName) {
- return null;
+ return Optional.empty();
}
@Override
@@ -372,7 +369,7 @@ public class ServiceModelDaoFactoryTest {
public Optional<ElementInfo> getElementInfo(SessionContext context,
ElementContext elementContext,
Id elementId) {
- return null;
+ return Optional.empty();
}
@Override
@@ -396,7 +393,7 @@ public class ServiceModelDaoFactoryTest {
public Optional<ElementConflict> getElementConflict(SessionContext context,
ElementContext elementContext,
Id id) {
- return null;
+ return Optional.empty();
}
@Override