diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp')
8 files changed, 69 insertions, 107 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java index c7aa81873b..047015e16a 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java @@ -21,6 +21,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.errors.VersioningErrorCodes; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -59,6 +60,11 @@ public class ComponentManagerImplTest { MockitoAnnotations.initMocks(this); } + @AfterMethod + public void tearDown() { + componentManager = null; + } + @Test public void testListWhenNone() { Collection<ComponentEntity> components = componentManager.listComponents(VSP_ID, VERSION); @@ -89,10 +95,6 @@ public class ComponentManagerImplTest { VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED); } - /* @Test - public void testCreate() { - COMP1_ID = testCreate(VSP_ID); - }*/ @Test public void testCreate() { ComponentEntity expected = new ComponentEntity(VSP_ID, null, null); @@ -131,7 +133,7 @@ public class ComponentManagerImplTest { doReturn(vspComponentList).when(componentDaoMock).list(anyObject()); try { - ComponentEntity created = componentManager.createComponent(expected); + componentManager.createComponent(expected); } catch (CoreException exception) { Assert.assertEquals("Creation of only one VFC per VSP allowed.", exception.code().message()); Assert.assertEquals(VendorSoftwareProductErrorCodes.VSP_VFC_COUNT_EXCEED, @@ -180,7 +182,7 @@ public class ComponentManagerImplTest { .validateEntity(anyObject(), anyObject(), anyObject()); try { - CompositionEntityValidationData created = componentManager.updateComponent(expected); + componentManager.updateComponent(expected); } catch (CoreException exception) { Assert.assertEquals("VFC with specified name already present in given VSP.", exception.code().message()); @@ -326,7 +328,7 @@ public class ComponentManagerImplTest { } @Test - public void testComponentNullQuestionnaire() throws Exception { + public void testComponentNullQuestionnaire() { doReturn(new ComponentEntity(VSP_ID, VERSION, COMP1_ID)).when(componentDaoMock) .getQuestionnaireData(VSP_ID, VERSION, COMP1_ID); String schema = "schema string"; @@ -335,7 +337,7 @@ public class ComponentManagerImplTest { QuestionnaireResponse questionnaire = componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID); Assert.assertNotNull(questionnaire); - Assert.assertEquals(questionnaire.getData(), null); + Assert.assertNull(questionnaire.getData()); Assert.assertEquals(questionnaire.getSchema(), schema); Assert.assertNull(questionnaire.getErrorMessage()); } @@ -389,20 +391,6 @@ public class ComponentManagerImplTest { .updateQuestionnaireData(VSP_ID, VERSION, COMP1_ID, "questionnaire data"); } -/* - @Test(dependsOnMethods = "testDelete") - public void testDeleteList() { - ComponentEntity comp3 = new ComponentEntity(VSP_ID, null, null); - comp3.setName("comp3 name"); - comp3.setDescription("comp3 desc"); - componentManager.createComponent(comp3, USER); - - componentManager.deleteComponents(VSP_ID, USER); - - Collection<ComponentEntity> actual = componentManager.listComponents(VSP_ID, null, USER); - Assert.assertEquals(actual.size(), 0); - }*/ - private void testGet(String vspId, Version version, String componentId, ComponentEntity expected) { @@ -443,16 +431,6 @@ public class ComponentManagerImplTest { } } - private void testList_negative(String vspId, Version version, - String expectedErrorCode) { - try { - componentManager.listComponents(vspId, version); - Assert.fail(); - } catch (CoreException exception) { - Assert.assertEquals(exception.code().id(), expectedErrorCode); - } - } - private void testDeleteList_negative(String vspId, Version version, String expectedErrorCode) { try { @@ -474,7 +452,7 @@ public class ComponentManagerImplTest { } - public static ComponentEntity createComponent(String vspId, Version version, String compId) { + private static ComponentEntity createComponent(String vspId, Version version, String compId) { ComponentEntity componentEntity = new ComponentEntity(vspId, version, compId); ComponentData compData = new ComponentData(); compData.setName(compId + " name"); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java index 9058a73632..265ba007d4 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java @@ -7,6 +7,7 @@ import org.mockito.Spy; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; @@ -22,6 +23,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.errors.VersioningErrorCodes; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -64,6 +66,11 @@ public class ComputeManagerImplTest { MockitoAnnotations.initMocks(this); } + @AfterMethod + public void tearDown() { + computeManager = null; + } + @Test public void testListWhenNone() { Collection<ListComputeResponse> computes = 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 6a5e7fa70c..35893409df 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 @@ -24,6 +24,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavo import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.errors.VersioningErrorCodes; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -62,6 +63,11 @@ public class DeploymentFlavorManagerImplTest { MockitoAnnotations.initMocks(this); } + @AfterMethod + public void tearDown() { + deploymentFlavorManager = null; + } + @Test public void testListWhenNone() { final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java index d9b4188f5e..553e433ccb 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java @@ -19,6 +19,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.errors.VersioningErrorCodes; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -57,6 +58,12 @@ public class ImageManagerImplTest { MockitoAnnotations.initMocks(this); } + @AfterMethod + public void tearDown() { + imageManager = null; + } + + @Test public void testListWhenNone() { final Collection<ImageEntity> imageEntities = diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java index 54687dc80d..f3cb2035da 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java @@ -20,14 +20,17 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl; + import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes; import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager; @@ -38,6 +41,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.errors.VersioningErrorCodes; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -54,6 +58,7 @@ public class NetworkManagerImplTest { private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); private static final String VSP_ID = "vsp"; + private static final String USER_ID = "test_user1"; private static final Version VERSION = new Version("version_id"); private static final String NETWORK1_ID = "network1"; private static final String NETWORK2_ID = "network2"; @@ -62,6 +67,9 @@ public class NetworkManagerImplTest { private NetworkDao networkDaoMock; @Mock private CompositionEntityDataManager compositionEntityDataManagerMock; + @Mock + private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao; + @InjectMocks @Spy private NetworkManagerImpl networkManager; @@ -78,6 +86,13 @@ public class NetworkManagerImplTest { @BeforeMethod public void setUp() throws Exception { MockitoAnnotations.initMocks(this); + SessionContextProviderFactory.getInstance().createInterface().create(USER_ID); + } + + @AfterMethod + public void tearDown() { + networkManager = null; + SessionContextProviderFactory.getInstance().createInterface().close(); } @Test @@ -98,52 +113,12 @@ public class NetworkManagerImplTest { Assert.assertEquals(actual.size(), 2); } -/* @Test(dependsOnMethods = "testListWhenNone") - public void testCreate() { - NETWORK1_ID = testCreate(VSP_ID); - } - - private String testCreate(String vspId) { - NetworkEntity expected = new NetworkEntity(vspId, null, null); - Network networkData = new Network(); - networkData.setName("network1 name"); - networkData.setDhcp(true); - expected.setNetworkCompositionData(networkData); - - - NetworkEntity created = networkManager.createNetwork(expected); - Assert.assertNotNull(created); - expected.setId(created.getId()); - expected.setVersion(VERSION01); - - NetworkEntity actual = networkDaoMock.getNetwork(vspId, VERSION01, created.getId()); - - Assert.assertEquals(actual, expected); - return created.getId(); - } - - @Test(dependsOnMethods = {"testCreate"}) - public void testCreateWithExistingName_negative() { - NetworkEntity network = new NetworkEntity(VSP_ID, null, null); - Network networkData = new Network(); - networkData.setName("network1 name"); - networkData.setDhcp(true); - network.setNetworkCompositionData(networkData); - testCreate_negative(network, UniqueValueUtil.UNIQUE_VALUE_VIOLATION); - }*/ - @Test public void testCreateOnUploadVsp_negative() { testCreate_negative(new NetworkEntity(VSP_ID, VERSION, null), VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED); } - /* @Test(dependsOnMethods = {"testCreate"}) - public void testCreateWithExistingNameUnderOtherVsp() { - testCreate(vsp2Id); - } - */ - @Test public void testUpdateNonExistingNetworkId_negative() { testUpdate_negative(VSP_ID, VERSION, NETWORK1_ID, @@ -161,6 +136,7 @@ public class NetworkManagerImplTest { doReturn(toBeReturned) .when(compositionEntityDataManagerMock) .validateEntity(anyObject(), anyObject(), anyObject()); + doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(),anyObject()); NetworkEntity networkEntity = new NetworkEntity(VSP_ID, VERSION, NETWORK1_ID); Network networkData = new Network(); @@ -188,6 +164,7 @@ public class NetworkManagerImplTest { doReturn(network) .when(networkDaoMock).get(anyObject()); doReturn("schema string").when(networkManager).getCompositionSchema(anyObject()); + doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(),anyObject()); CompositionEntityResponse<Network> response = networkManager.getNetwork(VSP_ID, VERSION, NETWORK1_ID); @@ -196,40 +173,6 @@ public class NetworkManagerImplTest { Assert.assertNotNull(response.getSchema()); } - /* - @Test(dependsOnMethods = {"testUpdateOnUploadVsp", "testList"}) - public void testCreateWithERemovedName() { - testCreate(VSP_ID); - } - - @Test(dependsOnMethods = "testList") - public void testDeleteNonExistingNetworkId_negative() { - testDelete_negative(VSP_ID, "non existing network id", VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND); - }*/ - -/* - @Test(dependsOnMethods = "testList") - public void testDelete() { - networkManager.deleteNetwork(VSP_ID, NETWORK1_ID); - NetworkEntity actual = networkDaoMock.getNetwork(VSP_ID, VERSION01, NETWORK1_ID); - Assert.assertNull(actual); - } - - - - @Test(dependsOnMethods = "testDelete") - public void testDeleteList() { - NetworkEntity network3 = new NetworkEntity(VSP_ID, null, null); - network3.setName("network3 name"); - network3.setDescription("network3 desc"); - networkManager.createNetwork(network3); - - networkManager.deleteNetworks(VSP_ID); - - Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, null); - Assert.assertEquals(actual.size(), 0); - }*/ - @Test(dependsOnMethods = "testList") public void testDeleteOnUploadVsp_negative() { testDelete_negative(VSP_ID, VERSION, NETWORK1_ID, @@ -238,6 +181,7 @@ public class NetworkManagerImplTest { private void testCreate_negative(NetworkEntity network, String expectedErrorCode) { try { + doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(),anyObject()); networkManager.createNetwork(network); Assert.fail(); } catch (CoreException exception) { @@ -281,6 +225,7 @@ public class NetworkManagerImplTest { private void testDelete_negative(String vspId, Version version, String networkId, String expectedErrorCode) { try { + doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(),anyObject()); networkManager.deleteNetwork(vspId, version, networkId); Assert.fail(); } catch (CoreException exception) { diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java index 959b501c19..dd71073cbd 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java @@ -23,6 +23,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.errors.VersioningErrorCodes; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -68,6 +69,11 @@ public class NicManagerImplTest { MockitoAnnotations.initMocks(this); } + @AfterMethod + public void tearDown() { + nicManager = null; + } + @Test public void testListWhenNone() { Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java index b925ab9270..1df437ef7b 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java @@ -18,6 +18,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.errors.VersioningErrorCodes; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -61,6 +62,12 @@ public class ProcessManagerImplTest { MockitoAnnotations.initMocks(this); } + @AfterMethod + public void tearDown() { + processManager = null; + } + + @Test public void testListWhenNone() { Collection<ProcessEntity> processes = diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java index 7721817c3b..9ef408c460 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java @@ -69,6 +69,7 @@ import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder; import org.openecomp.sdc.versioning.types.VersionInfo; import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -151,6 +152,11 @@ public class VendorSoftwareProductManagerImplTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); } + + @AfterMethod + public void tearDown(){ + vendorSoftwareProductManager = null; + } /* @Test public void testListWhenNone() { |