summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorRodrigo Lima <rodrigo.lima@yoppworks.com>2020-05-05 16:21:45 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-10 06:24:43 +0000
commit2fcd69426559f3464840309444596a3978d5f8e6 (patch)
tree8bca16cc54b3a026f8d0afc3f4349052e08bc11a /openecomp-be
parentfeb112c63e395bd682b09a43d6a03d13eb29dcd4 (diff)
Remove powermock from ComponentMonitoringUploadsImplTest
- Remove powermock from ComponentMonitoringUploadsImplTest. - Add new constructor to ComponentMonitoringUploadsImpl. Issue-ID: SDC-3024 Signed-off-by: Rodrigo Lima <rodrigo.lima@yoppworks.com> Change-Id: Ic8583db9c459c4d39258129a3b70cc108b30d7de
Diffstat (limited to 'openecomp-be')
-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/ComponentMonitoringUploadsImpl.java17
-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/ComponentMonitoringUploadsImplTest.java33
2 files changed, 19 insertions, 31 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/ComponentMonitoringUploadsImpl.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/ComponentMonitoringUploadsImpl.java
index 3b90a38827..25c99b294b 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/ComponentMonitoringUploadsImpl.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/ComponentMonitoringUploadsImpl.java
@@ -50,10 +50,19 @@ import java.io.InputStream;
@Scope(value = "prototype")
//@Validated
public class ComponentMonitoringUploadsImpl implements ComponentMonitoringUploads {
- private MonitoringUploadsManager
- monitoringUploadsManager = MonitoringUploadsManagerFactory.getInstance().createInterface();
- private ComponentManager componentManager =
- ComponentManagerFactory.getInstance().createInterface();
+ private final MonitoringUploadsManager monitoringUploadsManager;
+ private final ComponentManager componentManager;
+
+ public ComponentMonitoringUploadsImpl() {
+ this.monitoringUploadsManager = MonitoringUploadsManagerFactory.getInstance().createInterface();
+ this.componentManager = ComponentManagerFactory.getInstance().createInterface();
+ }
+
+ public ComponentMonitoringUploadsImpl(MonitoringUploadsManager monitoringUploadsManager,
+ ComponentManager componentManager) {
+ this.monitoringUploadsManager = monitoringUploadsManager;
+ this.componentManager = componentManager;
+ }
@Override
public Response upload(Attachment attachment,
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/ComponentMonitoringUploadsImplTest.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/ComponentMonitoringUploadsImplTest.java
index 40b4bc9651..119a5dbe53 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/ComponentMonitoringUploadsImplTest.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/ComponentMonitoringUploadsImplTest.java
@@ -26,46 +26,32 @@ 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.core.enrichment.types.MonitoringUploadType;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
-import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
-import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.MonitoringUploadsManagerImpl;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+
import javax.ws.rs.core.Response;
import java.io.ByteArrayInputStream;
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({MonitoringUploadsManagerImpl.class, MonitoringUploadsManagerFactory.class, ComponentManagerFactory.class})
public class ComponentMonitoringUploadsImplTest {
private Logger logger = LoggerFactory.getLogger(ComponentMonitoringUploadsImplTest.class);
@Mock
- private ComponentManagerFactory componentManagerFactory;
-
- @Mock
private ComponentManager componentManager;
@Mock
- private MonitoringUploadsManagerFactory uploadsFactory;
-
- @Mock
private MonitoringUploadsManager uploadsManager;
private final String vspId = UUID.randomUUID().toString();
@@ -73,19 +59,13 @@ public class ComponentMonitoringUploadsImplTest {
private final String componentId = "" + System.currentTimeMillis();
private final String user = "cs0008";
+ private ComponentMonitoringUploadsImpl bean;
+
@Before
public void setUp() {
try {
initMocks(this);
- mockStatic(ComponentManagerFactory.class);
- when(ComponentManagerFactory.getInstance()).thenReturn(componentManagerFactory);
- when(componentManagerFactory.createInterface()).thenReturn(componentManager);
-
- mockStatic(MonitoringUploadsManagerFactory.class);
- when(MonitoringUploadsManagerFactory.getInstance()).thenReturn(uploadsFactory);
- when(uploadsFactory.createInterface()).thenReturn(uploadsManager);
-
MonitoringUploadStatus result = new MonitoringUploadStatus();
result.setSnmpPoll("p");
result.setSnmpTrap("t");
@@ -95,6 +75,8 @@ public class ComponentMonitoringUploadsImplTest {
ArgumentMatchers.any(),
ArgumentMatchers.eq(componentId))).thenReturn(result);
+ this.bean = new ComponentMonitoringUploadsImpl(uploadsManager, componentManager);
+
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
@@ -102,7 +84,6 @@ public class ComponentMonitoringUploadsImplTest {
@Test
public void testUpload() {
- ComponentMonitoringUploadsImpl bean = new ComponentMonitoringUploadsImpl();
byte[] bytes = "Hello".getBytes();
Attachment a = new Attachment("foo", new ByteArrayInputStream(bytes), new ContentDisposition("filename"));
String type = MonitoringUploadType.SNMP_POLL.toString();
@@ -120,7 +101,6 @@ public class ComponentMonitoringUploadsImplTest {
@Test
public void testDelete() {
- ComponentMonitoringUploadsImpl bean = new ComponentMonitoringUploadsImpl();
String type = MonitoringUploadType.SNMP_POLL.toString();
try {
Response rsp = bean.delete(vspId, versionId, componentId, type, user);
@@ -135,7 +115,6 @@ public class ComponentMonitoringUploadsImplTest {
@Test
public void testList() {
- ComponentMonitoringUploadsImpl bean = new ComponentMonitoringUploadsImpl();
try {
Response rsp = bean.list(vspId, versionId, componentId, user);
Assert.assertEquals("Response should be 200", HttpStatus.SC_OK, rsp.getStatus());