From 7d6464baa60086d83c7f3c4f2034175b14158e0d Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Fri, 10 Jan 2020 10:16:16 -0500 Subject: removed powermock dependecy and added it to removed powermock dependecy and added it to enforcer plugin Issue-ID: SO-2597 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ib2dff9818fffaef1b356db03795fdca238dfed75 --- mso-catalog-db/pom.xml | 12 ---- .../onap/so/db/catalog/client/CatalogDbClient.java | 66 +++++++++++----------- .../so/db/catalog/client/CatalogDbClientTest.java | 51 ++++++----------- pom.xml | 38 ++++++++++++- 4 files changed, 88 insertions(+), 79 deletions(-) diff --git a/mso-catalog-db/pom.xml b/mso-catalog-db/pom.xml index 610ed25096..6a4a6774e6 100644 --- a/mso-catalog-db/pom.xml +++ b/mso-catalog-db/pom.xml @@ -107,17 +107,5 @@ jersey-common test - - org.mockito - mockito-core - 2.28.2 - test - - - org.powermock - powermock-api-mockito2 - 2.0.4 - test - diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index 7873d70bd4..7f5907e9bf 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -124,38 +124,38 @@ public class CatalogDbClient { private static final String SEARCH = "/search"; private static final String URI_SEPARATOR = "/"; - private static final String SERVICE_MODEL_UUID = "serviceModelUUID"; - private static final String SERVICE_NAME = "serviceName"; - private static final String MODEL_UUID = "modelUUID"; - private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID"; - private static final String ACTION = "action"; - private static final String MODEL_NAME = "modelName"; - private static final String MODEL_VERSION = "modelVersion"; - private static final String MODEL_INVARIANT_UUID = "modelInvariantUUID"; - private static final String VNF_RESOURCE_MODEL_UUID = "vnfResourceModelUUID"; - private static final String PNF_RESOURCE_MODEL_UUID = "pnfResourceModelUUID"; - private static final String NF_ROLE = "nfRole"; - private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID"; - private static final String VNF_COMPONENT_TYPE = "vnfComponentType"; - private static final String BUILDING_BLOCK_NAME = "buildingBlockName"; - private static final String RESOURCE_TYPE = "resourceType"; - private static final String ORCHESTRATION_STATUS = "orchestrationStatus"; - private static final String TARGET_ACTION = "targetAction"; - private static final String REQUEST_SCOPE = "requestScope"; - private static final String IS_ALACARTE = "isALaCarte"; - private static final String CLOUD_OWNER = "cloudOwner"; - private static final String FLOW_NAME = "flowName"; - private static final String ERROR_MESSAGE = "errorMessage"; - private static final String SERVICE_ROLE = "serviceRole"; - private static final String SERVICE_TYPE = "serviceType"; - private static final String VNF_TYPE = "vnfType"; - private static final String ERROR_CODE = "errorCode"; - private static final String WORK_STEP = "workStep"; - private static final String CLLI = "clli"; - private static final String CLOUD_VERSION = "cloudVersion"; - private static final String HOMING_INSTANCE = "/homingInstance"; - private static final String ARTIFACT_UUID = "artifactUUID"; - private static final String SOURCE = "source"; + protected static final String SERVICE_MODEL_UUID = "serviceModelUUID"; + protected static final String SERVICE_NAME = "serviceName"; + protected static final String MODEL_UUID = "modelUUID"; + protected static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID"; + protected static final String ACTION = "action"; + protected static final String MODEL_NAME = "modelName"; + protected static final String MODEL_VERSION = "modelVersion"; + protected static final String MODEL_INVARIANT_UUID = "modelInvariantUUID"; + protected static final String VNF_RESOURCE_MODEL_UUID = "vnfResourceModelUUID"; + protected static final String PNF_RESOURCE_MODEL_UUID = "pnfResourceModelUUID"; + protected static final String NF_ROLE = "nfRole"; + protected static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID"; + protected static final String VNF_COMPONENT_TYPE = "vnfComponentType"; + protected static final String BUILDING_BLOCK_NAME = "buildingBlockName"; + protected static final String RESOURCE_TYPE = "resourceType"; + protected static final String ORCHESTRATION_STATUS = "orchestrationStatus"; + protected static final String TARGET_ACTION = "targetAction"; + protected static final String REQUEST_SCOPE = "requestScope"; + protected static final String IS_ALACARTE = "isALaCarte"; + protected static final String CLOUD_OWNER = "cloudOwner"; + protected static final String FLOW_NAME = "flowName"; + protected static final String ERROR_MESSAGE = "errorMessage"; + protected static final String SERVICE_ROLE = "serviceRole"; + protected static final String SERVICE_TYPE = "serviceType"; + protected static final String VNF_TYPE = "vnfType"; + protected static final String ERROR_CODE = "errorCode"; + protected static final String WORK_STEP = "workStep"; + protected static final String CLLI = "clli"; + protected static final String CLOUD_VERSION = "cloudVersion"; + protected static final String HOMING_INSTANCE = "/homingInstance"; + protected static final String ARTIFACT_UUID = "artifactUUID"; + protected static final String SOURCE = "source"; private static final String TARGET_ENTITY = "SO:CatalogDB"; private static final String ASTERISK = "*"; @@ -820,7 +820,7 @@ public class CatalogDbClient { return client.get(uri); } - private List getMultipleResources(Client client, URI uri) { + protected List getMultipleResources(Client client, URI uri) { Iterable iterator = client.getAll(uri); List list = new ArrayList<>(); Iterator it = iterator.iterator(); diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index d87ed517f4..66fc0f5dc5 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -19,42 +19,33 @@ */ package org.onap.so.db.catalog.client; + import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; import java.util.ArrayList; import java.util.List; import javax.persistence.EntityNotFoundException; -import org.junit.Before; +import javax.ws.rs.core.UriBuilder; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.ArgumentMatchers; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import uk.co.blackpepper.bowman.Client; import org.onap.so.db.catalog.beans.Workflow; +import uk.co.blackpepper.bowman.Client; -@RunWith(PowerMockRunner.class) -@PrepareForTest(CatalogDbClient.class) +@RunWith(MockitoJUnitRunner.class) public class CatalogDbClientTest { + @Spy private CatalogDbClient catalogDbClient; - - private CatalogDbClient mockedCatalogDbClient; - - @Before - public void init() { - catalogDbClient = new CatalogDbClient(); - mockedCatalogDbClient = PowerMockito.spy(catalogDbClient); - } - @Rule public ExpectedException thrown = ExpectedException.none(); @@ -190,19 +181,13 @@ public class CatalogDbClientTest { @Test public final void testFindWorkflowByPnfModelUUID() throws Exception { String pnfResourceModelUUID = "f2d1f2b2-88bb-49da-b716-36ae420ccbff"; - Workflow wf = new Workflow(); - wf.setArtifactUUID("b2fd5627-55e4-4f4f-8064-9e6f443e9152"); - wf.setArtifactName("DummyPnfWorkflow"); - wf.setVersion(1.0); - List wfList = new ArrayList(); - wfList.add(wf); - - PowerMockito.doReturn(wfList).when(mockedCatalogDbClient, "getMultipleResources", - ArgumentMatchers.>any(), ArgumentMatchers.anyObject()); - List results = mockedCatalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID); - assertEquals(wf.getArtifactUUID(), results.get(0).getArtifactUUID()); - assertEquals(wf.getArtifactName(), results.get(0).getArtifactName()); - assertEquals(wf.getVersion(), results.get(0).getVersion()); + + doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any()); + List results = catalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID); + verify(catalogDbClient).getMultipleResources(any(Client.class), + eq(UriBuilder.fromUri("/findWorkflowByPnfModelUUID") + .queryParam(CatalogDbClient.PNF_RESOURCE_MODEL_UUID, pnfResourceModelUUID).build())); + } } diff --git a/pom.xml b/pom.xml index 12d5040aed..9e27d8cf23 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ ${project.version} ${project.artifactId} ${dockerPullRepo} - true + false https://nexus.onap.org content/repositories/releases/ content/repositories/snapshots/ @@ -497,6 +497,42 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + enforce-property + + true + + + + enforce-no-snapshots + + true + + + + enforce-banned-dependencies + + enforce + + + + + + org.powermock + + false + + + true + + + + -- cgit 1.2.3-korg