summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java9
-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
5 files changed, 52 insertions, 52 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
index d78f4045b6..698afe62d4 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
@@ -12,6 +12,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.impl.ImageManagerImpl;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
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;
@@ -41,6 +42,11 @@ public class ImagesTest {
MockitoAnnotations.initMocks(this);
}
+ @AfterMethod
+ public void tearDown(){
+ imageManager = null;
+ }
+
@Test
public void createImage() {
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
index 35893409df..be53a1a71a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
@@ -31,6 +31,7 @@ import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import static org.mockito.Matchers.anyObject;
@@ -43,6 +44,8 @@ public class DeploymentFlavorManagerImplTest {
private static final String COMPONENT_ID = "COMPONENT_ID";
private static final String DF1_ID = "df1";
private static final String DF2_ID = "df2";
+ private static final String FG_ID = "FG_ID";
+ private static final List<String> fgs = Collections.singletonList(FG_ID);
@Mock
private CompositionEntityDataManager compositionEntityDataManagerMock;
@@ -88,6 +91,7 @@ public class DeploymentFlavorManagerImplTest {
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ vspDetails.setFeatureGroups(fgs);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
deploymentFlavorManager.createDeploymentFlavor(expected);
@@ -161,6 +165,7 @@ public class DeploymentFlavorManagerImplTest {
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ vspDetails.setFeatureGroups(fgs);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
try {
@@ -190,6 +195,7 @@ public class DeploymentFlavorManagerImplTest {
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ vspDetails.setFeatureGroups(fgs);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, null);
@@ -222,6 +228,7 @@ public class DeploymentFlavorManagerImplTest {
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ vspDetails.setFeatureGroups(fgs);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, null);
@@ -299,30 +306,11 @@ public class DeploymentFlavorManagerImplTest {
@Test
public void testGetNonExistingDepFlavorId_negative() {
- testGet_negative(VSP_ID, VERSION, "non existing image id",
+ testGet_negative(VSP_ID, VERSION,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
- /*
- @Test
- public void testGet() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- CompositionEntityResponse<DeploymentFlavor> response =
- deploymentFlavorManager.getDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- Assert.assertEquals(response.getId(), expected.getId());
- Assert
- .assertEquals(response.getData().getModel(), expected.getDeploymentFlavorCompositionData().
- getModel());
- Assert.assertEquals(response.getData().getDescription(),
- expected.getDeploymentFlavorCompositionData().
- getDescription());
- }
-*/
@Test
public void testDeleteDepFlavorOnHEAT() {
DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
@@ -374,6 +362,7 @@ public class DeploymentFlavorManagerImplTest {
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
deploymentFlavor.setModel(deploymentFlavorId + "name");
deploymentFlavor.setDescription(deploymentFlavorId + " desc");
+ deploymentFlavor.setFeatureGroupId(FG_ID);
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
return deploymentFlavorEntity;
@@ -395,10 +384,10 @@ public class DeploymentFlavorManagerImplTest {
}
}
- private void testGet_negative(String vspId, Version version, String deploymentFlavorId,
+ private void testGet_negative(String vspId, Version version,
String expectedErrorCode) {
try {
- deploymentFlavorManager.getDeploymentFlavor(vspId, version, deploymentFlavorId);
+ deploymentFlavorManager.getDeploymentFlavor(vspId, version, "non existing image id");
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
index 5e735ff74e..470dca40ff 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
@@ -10,6 +10,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploa
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
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;
@@ -50,6 +51,11 @@ public class MonitoringUploadsManagerImplTest {
MockitoAnnotations.initMocks(this);
}
+ @AfterMethod
+ public void tearDown(){
+ monitoringUploadsManager = null;
+ }
+
@Test(expectedExceptions = CoreException.class)
public void testUploadEmptyZip() {
processFile(ZIP_DIR + EMPTY_ZIP_FILE_NAME, inputStream ->
@@ -59,8 +65,7 @@ public class MonitoringUploadsManagerImplTest {
}
@Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp =
- "Monitoring file uploaded for vendor software product with Id vspId and version version_id " +
- "is invalid: Invalid zip file")
+ "Invalid zip file")
public void testUploadInvalidZip() {
processFile("/notZipFile", inputStream ->
monitoringUploadsManager
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