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
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 539b640..becfac9 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 @@
 @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 6619030..fe90ed2 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 @@
 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.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.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 @@
   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 @@
           ArgumentMatchers.eq(entityId)
           )).thenReturn(e);
 
+      componentDependencies = new ComponentDependenciesImpl(componentDependencyModelManager);
+
     } catch (Exception e) {
       logger.error(e.getMessage(), e);
     }
@@ -119,8 +110,6 @@
     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 @@
   @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 @@
   @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 @@
   @Test
   public void testUpdate() {
 
-    ComponentDependencies componentDependencies = new ComponentDependenciesImpl();
-
     ComponentDependencyModel model = new ComponentDependencyModel();
     model.setRelationType(ComponentRelationType.dependsOn.name());
     model.setSourceId("sourceid");
@@ -183,7 +167,6 @@
   @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 @@
     } catch (ClassCastException ex) {
       Assert.fail("unexpected class for DTO " + rsp.getEntity().getClass().getName());
     }
-
-
-
   }
 }