diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib')
1 files changed, 23 insertions, 26 deletions
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 |