aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-catalog-db/src')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java8
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java15
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java34
3 files changed, 56 insertions, 1 deletions
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 8754673f40..7873d70bd4 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
@@ -133,6 +133,7 @@ public class CatalogDbClient {
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";
@@ -201,6 +202,7 @@ public class CatalogDbClient {
private String findPnfResourceCustomizationByModelUuid = "/findPnfResourceCustomizationByModelUuid";
private String findWorkflowByArtifactUUID = "/findByArtifactUUID";
private String findWorkflowByModelUUID = "/findWorkflowByModelUUID";
+ private String findWorkflowByPnfModelUUID = "/findWorkflowByPnfModelUUID";
private String findWorkflowBySource = "/findBySource";
private String findVnfResourceCustomizationByModelUuid = "/findVnfResourceCustomizationByModelUuid";
@@ -338,6 +340,7 @@ public class CatalogDbClient {
findWorkflowByArtifactUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByArtifactUUID;
findWorkflowByModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByModelUUID;
+ findWorkflowByPnfModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByPnfModelUUID;
findWorkflowBySource = endpoint + WORKFLOW + SEARCH + findWorkflowBySource;
findVnfResourceCustomizationByModelUuid =
@@ -998,6 +1001,11 @@ public class CatalogDbClient {
.queryParam(VNF_RESOURCE_MODEL_UUID, vnfResourceModelUUID).build().toString()));
}
+ public List<Workflow> findWorkflowByPnfModelUUID(String pnfResourceModelUUID) {
+ return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByPnfModelUUID)
+ .queryParam(PNF_RESOURCE_MODEL_UUID, pnfResourceModelUUID).build().toString()));
+ }
+
public List<Workflow> findWorkflowBySource(String source) {
return this.getMultipleResources(workflowClient,
getUri(UriBuilder.fromUri(findWorkflowBySource).queryParam(SOURCE, source).build().toString()));
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
index 8bcc60c8be..f1b399325e 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
@@ -39,10 +39,23 @@ public interface WorkflowRepository extends JpaRepository<Workflow, Integer> {
* This operation is required by {@link org.onap.so.db.catalog.client.CatalogDbClient} to provide Workflow based on
* model UUID without projection.
*
- * @param vnfResourceModelUUIDmodel UUID
+ * @param vnfResourceModelUUID UUID
* @return List of Workflow
*/
@Query(value = "select b.* from vnf_resource_to_workflow a join workflow b where a.WORKFLOW_ID = b.ID and a.VNF_RESOURCE_MODEL_UUID = ?1",
nativeQuery = true)
List<Workflow> findWorkflowByModelUUID(String vnfResourceModelUUID);
+
+ /**
+ * Used to fetch the @{link Workflow} by the Pnf Model UUID.
+ *
+ * This operation is required by {@link org.onap.so.db.catalog.client.CatalogDbClient} to provide Workflow based on
+ * pnf model UUID without projection.
+ *
+ * @param pnfResourceModelUUID UUID
+ * @return List of Workflow
+ */
+ @Query(value = "select b.* from pnf_resource_to_workflow a join workflow b where a.WORKFLOW_ID = b.ID and a.PNF_RESOURCE_MODEL_UUID = ?1",
+ nativeQuery = true)
+ List<Workflow> findWorkflowByPnfModelUUID(String pnfResourceModelUUID);
}
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 b82c17dc84..d87ed517f4 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
@@ -20,23 +20,39 @@
package org.onap.so.db.catalog.client;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
+import java.util.List;
import javax.persistence.EntityNotFoundException;
import org.junit.Before;
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.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;
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(CatalogDbClient.class)
public class CatalogDbClientTest {
private CatalogDbClient catalogDbClient;
+ private CatalogDbClient mockedCatalogDbClient;
+
@Before
public void init() {
catalogDbClient = new CatalogDbClient();
+ mockedCatalogDbClient = PowerMockito.spy(catalogDbClient);
}
@Rule
@@ -171,4 +187,22 @@ public class CatalogDbClientTest {
assertTrue(aCvnfc.getModelCustomizationUUID().equals("a123"));
}
+ @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());
+ }
+
}