summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mso-catalog-db/pom.xml12
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java66
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java51
-rw-r--r--pom.xml38
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 @@
<artifactId>jersey-common</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>2.28.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <version>2.0.4</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
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 <T> List<T> getMultipleResources(Client<T> client, URI uri) {
+ protected <T> List<T> getMultipleResources(Client<T> client, URI uri) {
Iterable<T> iterator = client.getAll(uri);
List<T> list = new ArrayList<>();
Iterator<T> 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<Workflow> wfList = new ArrayList<Workflow>();
- wfList.add(wf);
-
- PowerMockito.doReturn(wfList).when(mockedCatalogDbClient, "getMultipleResources",
- ArgumentMatchers.<Client<Workflow>>any(), ArgumentMatchers.anyObject());
- List<Workflow> 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<Workflow> 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 @@
<docker.buildArg.project_version>${project.version}</docker.buildArg.project_version>
<docker.buildArg.artifact_id>${project.artifactId}</docker.buildArg.artifact_id>
<docker.buildArg.docker_repository>${dockerPullRepo}</docker.buildArg.docker_repository>
- <enforcer.skip>true</enforcer.skip>
+ <enforcer.skip>false</enforcer.skip>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<releaseNexusPath>content/repositories/releases/</releaseNexusPath>
<snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath>
@@ -497,6 +497,42 @@
</dependency>
</dependencies>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.0.0-M3</version>
+ <executions>
+ <execution>
+ <id>enforce-property</id>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>enforce-no-snapshots</id>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>enforce-banned-dependencies</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <bannedDependencies>
+ <excludes>
+ <exclude>org.powermock</exclude>
+ </excludes>
+ <searchTransitive>false</searchTransitive>
+ </bannedDependencies>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>