aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Lima <rodrigo.lima@yoppworks.com>2020-05-06 13:18:09 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-10 06:25:04 +0000
commit3502173f27ae1b8d43fd654c6f5ed1f25d885a1d (patch)
tree605c787fc71ce98ad8c075d4ccf157f7aa69b1f1
parentcdadb774cce59454fc217ac34edb9ac7130a06b2 (diff)
Remove powermock from ComponentDependenciesImplTest
- Remove powermock from ComponentDependenciesImplTest and add new constructor to ComponentDependenciesImpl Issue-ID: SDC-3027 Signed-off-by: Rodrigo Lima <rodrigo.lima@yoppworks.com> Change-Id: I045e268230d94d4f52c4b85069eddade7678edee
-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/ComponentDependenciesImpl.java12
-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/ComponentDependenciesImplTest.java30
2 files changed, 15 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/ComponentDependenciesImpl.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/ComponentDependenciesImpl.java
index 539b6408a1..becfac97b6 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/ComponentDependenciesImpl.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/ComponentDependenciesImpl.java
@@ -40,8 +40,16 @@ import java.util.Collection;
@Scope(value = "prototype")
public class ComponentDependenciesImpl implements ComponentDependencies {
- private final ComponentDependencyModelManager componentDependencyModelManager =
- ComponentDependencyModelManagerFactory.getInstance().createInterface();
+ private final ComponentDependencyModelManager componentDependencyModelManager;
+
+ public ComponentDependenciesImpl() {
+ this.componentDependencyModelManager =
+ ComponentDependencyModelManagerFactory.getInstance().createInterface();
+ }
+
+ public ComponentDependenciesImpl(ComponentDependencyModelManager componentDependencyModelManager) {
+ this.componentDependencyModelManager = componentDependencyModelManager;
+ }
@Override
public Response create(ComponentDependencyModel 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/ComponentDependenciesImplTest.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/ComponentDependenciesImplTest.java
index 66190305ef..fe90ed2528 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/ComponentDependenciesImplTest.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/ComponentDependenciesImplTest.java
@@ -23,16 +23,12 @@ package org.openecomp.sdcrests.vsp.rest.services;
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.activitylog.ActivityLogManagerFactory;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyCreationDto;
@@ -41,8 +37,6 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyRe
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRelationType;
import org.openecomp.sdcrests.vsp.rest.ComponentDependencies;
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;
@@ -50,11 +44,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({ComponentDependenciesImpl.class, ComponentDependencyModelManagerFactory.class})
public class ComponentDependenciesImplTest {
private Logger logger = LoggerFactory.getLogger(org.openecomp.sdcrests.vsp.rest.services.ComponentDependenciesImplTest.class);
@@ -70,15 +61,13 @@ public class ComponentDependenciesImplTest {
private final String entityId = "" + System.currentTimeMillis();
private final String user = "cs0008";
+ private ComponentDependencies componentDependencies;
+
@Before
public void setUp() {
try {
initMocks(this);
- mockStatic(ComponentDependencyModelManagerFactory.class);
- when(ComponentDependencyModelManagerFactory.getInstance()).thenReturn(componentDependencyModelManagerFactory);
- when(componentDependencyModelManagerFactory.createInterface()).thenReturn(componentDependencyModelManager);
-
ComponentDependencyModelEntity e = new ComponentDependencyModelEntity();
e.setSourceComponentId("sourceid");
e.setTargetComponentId("targetid");
@@ -107,6 +96,8 @@ public class ComponentDependenciesImplTest {
ArgumentMatchers.eq(entityId)
)).thenReturn(e);
+ componentDependencies = new ComponentDependenciesImpl(componentDependencyModelManager);
+
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
@@ -119,8 +110,6 @@ public class ComponentDependenciesImplTest {
model.setSourceId("sourceid");
model.setTargetId("targetid");
-
- ComponentDependencies componentDependencies = new ComponentDependenciesImpl();
Response rsp = componentDependencies.create(model, vspId, versionId, user);
Assert.assertEquals("Response should be 200", 200, rsp.getStatus());
Object e = rsp.getEntity();
@@ -136,7 +125,6 @@ public class ComponentDependenciesImplTest {
@Test
public void testList() {
- ComponentDependencies componentDependencies = new ComponentDependenciesImpl();
Response rsp = componentDependencies.list(vspId, versionId, user);
Assert.assertEquals("Response should be 200", 200, rsp.getStatus());
Object e = rsp.getEntity();
@@ -157,8 +145,6 @@ public class ComponentDependenciesImplTest {
@Test
public void testDelete() {
- ComponentDependencies componentDependencies = new ComponentDependenciesImpl();
-
Response rsp = componentDependencies.delete(vspId, versionId, entityId, user);
Assert.assertEquals("Response should be 200", 200, rsp.getStatus());
Assert.assertNull(rsp.getEntity());
@@ -168,8 +154,6 @@ public class ComponentDependenciesImplTest {
@Test
public void testUpdate() {
- ComponentDependencies componentDependencies = new ComponentDependenciesImpl();
-
ComponentDependencyModel model = new ComponentDependencyModel();
model.setRelationType(ComponentRelationType.dependsOn.name());
model.setSourceId("sourceid");
@@ -183,7 +167,6 @@ public class ComponentDependenciesImplTest {
@Test
public void testGet() {
- ComponentDependencies componentDependencies = new ComponentDependenciesImpl();
Response rsp = componentDependencies.get(vspId, versionId, entityId, user);
Assert.assertEquals("Response should be 200", 200, rsp.getStatus());
Assert.assertNotNull(rsp.getEntity());
@@ -193,8 +176,5 @@ public class ComponentDependenciesImplTest {
} catch (ClassCastException ex) {
Assert.fail("unexpected class for DTO " + rsp.getEntity().getClass().getName());
}
-
-
-
}
}