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;
MockitoAnnotations.initMocks(this);
}
+ @AfterMethod
+ public void tearDown(){
+ imageManager = null;
+ }
+
@Test
public void createImage() {
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
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;
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;
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);
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ vspDetails.setFeatureGroups(fgs);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
try {
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);
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);
@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);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
deploymentFlavor.setModel(deploymentFlavorId + "name");
deploymentFlavor.setDescription(deploymentFlavorId + " desc");
+ deploymentFlavor.setFeatureGroupId(FG_ID);
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
return deploymentFlavorEntity;
}
}
- 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);
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;
MockitoAnnotations.initMocks(this);
}
+ @AfterMethod
+ public void tearDown(){
+ monitoringUploadsManager = null;
+ }
+
@Test(expectedExceptions = CoreException.class)
public void testUploadEmptyZip() {
processFile(ZIP_DIR + EMPTY_ZIP_FILE_NAME, inputStream ->
}
@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
package org.openecomp.core.utilities.file;
+import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.IOException;
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];
throw new RuntimeException("Unexpected error", e);
}
- }), content);
+ });
+ Assert.assertTrue(Arrays.equals(actualContent, content));
}
@Test
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;
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;
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() {
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() {
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) {
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());
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);
}
@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
public Optional<ElementInfo> getElementInfo(SessionContext context,
ElementContext elementContext,
Id elementId) {
- return null;
+ return Optional.empty();
}
@Override
public Optional<ElementConflict> getElementConflict(SessionContext context,
ElementContext elementContext,
Id id) {
- return null;
+ return Optional.empty();
}
@Override