aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api
diff options
context:
space:
mode:
authorRodrigo Lima <rodrigo.lima@yoppworks.com>2020-05-06 17:52:15 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-10 06:25:15 +0000
commitde9fa5a0053b1348b56daf4cbd1039fe8bdd956f (patch)
treec4d11df260389d133e890c9094fc16d0526fed99 /openecomp-be/api
parent3502173f27ae1b8d43fd654c6f5ed1f25d885a1d (diff)
Remove powermock from ImagesImplTest
- Remove powermock from ImagesImplTest and add new constructor to ImagesImpl Issue-ID: SDC-3038 Signed-off-by: Rodrigo Lima <rodrigo.lima@yoppworks.com> Change-Id: I6439a90a71d9de94c2233f8b64fed9da4860dd2e
Diffstat (limited to 'openecomp-be/api')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java16
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImplTest.java28
2 files changed, 17 insertions, 27 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java
index b7ade2a627..7971b48427 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java
@@ -49,9 +49,19 @@ import java.util.Collection;
@Scope(value = "prototype")
public class ImagesImpl implements Images {
- private ImageManager imageManager = ImageManagerFactory.getInstance().createInterface();
- private ComponentManager componentManager =
- ComponentManagerFactory.getInstance().createInterface();
+ private final ImageManager imageManager;
+ private final ComponentManager componentManager;
+
+ public ImagesImpl() {
+ this.imageManager = ImageManagerFactory.getInstance().createInterface();
+ this.componentManager =
+ ComponentManagerFactory.getInstance().createInterface();
+ }
+
+ public ImagesImpl(ImageManager imageManager, ComponentManager componentManager) {
+ this.imageManager = imageManager;
+ this.componentManager = componentManager;
+ }
@Override
public Response create(ImageRequestDto request, String vspId, String versionId,
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImplTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImplTest.java
index fa268c69d0..349ab9b401 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImplTest.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImplTest.java
@@ -24,7 +24,6 @@ import org.apache.http.HttpStatus;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.openecomp.sdc.logging.api.Logger;
@@ -44,8 +43,6 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
import javax.ws.rs.core.Response;
import java.util.Collection;
@@ -53,11 +50,8 @@ import java.util.Collections;
import java.util.UUID;
import static org.mockito.MockitoAnnotations.initMocks;
-import static org.powermock.api.mockito.PowerMockito.mockStatic;
-import static org.powermock.api.mockito.PowerMockito.when;
+import static org.mockito.Mockito.when;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ComputeImpl.class, ComponentManagerFactory.class, ImageManagerFactory.class})
public class ImagesImplTest {
private Logger logger = LoggerFactory.getLogger(ImagesImplTest.class);
@@ -80,21 +74,13 @@ public class ImagesImplTest {
private final String imageId = "" + System.currentTimeMillis();
private final String user = "cs0008";
+ private ImagesImpl ii;
+
@Before
public void setUp() {
try {
initMocks(this);
- mockStatic(ComponentManagerFactory.class);
- when(ComponentManagerFactory.getInstance()).thenReturn(componentManagerFactory);
- when(componentManagerFactory.createInterface()).thenReturn(componentManager);
-
- mockStatic(ImageManagerFactory.class);
- when(ImageManagerFactory.getInstance()).thenReturn(imageManagerFactory);
- when(imageManagerFactory.createInterface()).thenReturn(imageManager);
-
-
-
ImageEntity ie = new ImageEntity();
ie.setComponentId(componentId);
ie.setId(imageId);
@@ -132,6 +118,7 @@ public class ImagesImplTest {
ArgumentMatchers.eq(componentId),
ArgumentMatchers.eq(imageId))).thenReturn(qr);
+ ii = new ImagesImpl(imageManager, componentManager);
} catch (Exception e) {
logger.error(e.getMessage(), e);
@@ -140,7 +127,6 @@ public class ImagesImplTest {
@Test
public void testList() {
- ImagesImpl ii = new ImagesImpl();
Response rsp = ii.list(vspId, versionId, componentId, user);
Assert.assertEquals("Response should be 200", HttpStatus.SC_OK, rsp.getStatus());
@@ -159,7 +145,6 @@ public class ImagesImplTest {
dto.setDescription("hello");
dto.setFileName("name");
- ImagesImpl ii = new ImagesImpl();
Response rsp = ii.create(dto, vspId, versionId, componentId, user);
Assert.assertEquals("Response should be 200", HttpStatus.SC_OK, rsp.getStatus());
Object e = rsp.getEntity();
@@ -175,7 +160,6 @@ public class ImagesImplTest {
@Test
public void testDelete() {
- ImagesImpl ii = new ImagesImpl();
Response rsp = ii.delete(vspId, versionId, componentId, imageId, user);
Assert.assertEquals("Response should be 200", HttpStatus.SC_OK, rsp.getStatus());
Assert.assertNull(rsp.getEntity());
@@ -184,7 +168,6 @@ public class ImagesImplTest {
@Test
public void testGet() {
- ImagesImpl ii = new ImagesImpl();
Response rsp = ii.get(vspId, versionId, componentId, imageId, user);
Assert.assertEquals("Response should be 200", HttpStatus.SC_OK, rsp.getStatus());
Assert.assertNotNull(rsp.getEntity());
@@ -192,7 +175,6 @@ public class ImagesImplTest {
@Test
public void testUpdate() {
- ImagesImpl ii = new ImagesImpl();
ImageRequestDto dto = new ImageRequestDto();
Response rsp = ii.update(dto, vspId, versionId, componentId, imageId, user);
Assert.assertEquals("Response should be 200", HttpStatus.SC_OK, rsp.getStatus());
@@ -201,7 +183,6 @@ public class ImagesImplTest {
@Test
public void testGetQuestionaire() {
- ImagesImpl ii = new ImagesImpl();
Response rsp = ii.getQuestionnaire(vspId, versionId, componentId, imageId, user);
Assert.assertEquals("Response should be 200", HttpStatus.SC_OK, rsp.getStatus());
try {
@@ -217,7 +198,6 @@ public class ImagesImplTest {
@Test
public void testUpdateQuestionaire() {
- ImagesImpl ii = new ImagesImpl();
Response rsp = ii.updateQuestionnaire("helloworld", vspId, versionId, componentId, imageId, user);
Assert.assertEquals("Response should be 200", HttpStatus.SC_OK, rsp.getStatus());
Assert.assertNull(rsp.getEntity());