From 0b6f485d1ba5007056eb71b779bc844b4948de36 Mon Sep 17 00:00:00 2001 From: tragait Date: Fri, 14 Feb 2020 17:48:50 +0000 Subject: SO API extenstion to retrieve all PNF workflow This commit implements SO request handler API onap/so/infra/workflowSpecifications/v[x]/pnfWorkFlows. It is used to get all the pnf workflows exist in catalogdb. Issue-ID: SO-2660 Change-Id: Ieeca8a6afef917b6e3ba927d38ed5509dcaf253c Signed-off-by: tragait --- .../org/onap/so/db/catalog/client/CatalogDbClient.java | 12 ++++++++++-- .../db/catalog/data/repository/WorkflowRepository.java | 6 ++++-- .../onap/so/db/catalog/client/CatalogDbClientTest.java | 16 +++++++++++++++- .../catalog/data/repository/WorkflowRepositoryTest.java | 10 ++++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) (limited to 'mso-catalog-db') 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 cf066f9721..26c33941ed 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -158,6 +158,7 @@ public class CatalogDbClient { protected static final String HOMING_INSTANCE = "/homingInstance"; protected static final String ARTIFACT_UUID = "artifactUUID"; protected static final String SOURCE = "source"; + protected static final String RESOURCE_TARGET = "resource_target"; private static final String TARGET_ENTITY = "SO:CatalogDB"; private static final String ASTERISK = "*"; @@ -209,6 +210,7 @@ public class CatalogDbClient { private String findVnfResourceCustomizationByModelUuid = "/findVnfResourceCustomizationByModelUuid"; private String findBBNameSelectionReferenceByControllerActorAndScopeAndAction = "/findBBNameSelectionReferenceByControllerActorAndScopeAndAction"; + private String findWorkflowByResourceTarget = "/findByResourceTarget"; private String serviceURI; private String vfModuleURI; @@ -348,6 +350,7 @@ public class CatalogDbClient { findWorkflowByVnfModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByVnfModelUUID; findWorkflowByPnfModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByPnfModelUUID; findWorkflowBySource = endpoint + WORKFLOW + SEARCH + findWorkflowBySource; + findWorkflowByResourceTarget = endpoint + WORKFLOW + SEARCH + findWorkflowByResourceTarget; findVnfResourceCustomizationByModelUuid = endpoint + VNF_RESOURCE_CUSTOMIZATION + SEARCH + findVnfResourceCustomizationByModelUuid; @@ -1084,6 +1087,11 @@ public class CatalogDbClient { getUri(UriBuilder.fromUri(findWorkflowBySource).queryParam(SOURCE, source).build().toString())); } + public List findWorkflowByResourceTarget(String resourceTarget) { + return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByResourceTarget) + .queryParam(RESOURCE_TARGET, resourceTarget).build().toString())); + } + public String getEndpoint() { return endpoint; } 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 91c6940e95..93ec54a2eb 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,6 +33,8 @@ public interface WorkflowRepository extends JpaRepository { List findBySource(String source); + List findByResourceTarget(String resourceTarget); + /** * Used to fetch the @{link Workflow} by the Model UUID. * 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 66fc0f5dc5..79e3cbcc08 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 @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Nordix + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -179,7 +181,7 @@ public class CatalogDbClientTest { } @Test - public final void testFindWorkflowByPnfModelUUID() throws Exception { + public final void testFindWorkflowByPnfModelUUID() { String pnfResourceModelUUID = "f2d1f2b2-88bb-49da-b716-36ae420ccbff"; doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any()); @@ -190,4 +192,16 @@ public class CatalogDbClientTest { } + @Test + public final void testFindWorkflowByResourceTarget() { + // when + final String pnf_resource = "pnf"; + doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any()); + catalogDbClient.findWorkflowByResourceTarget(pnf_resource); + + // verify + verify(catalogDbClient).getMultipleResources(any(Client.class), eq(UriBuilder.fromUri("/findByResourceTarget") + .queryParam(CatalogDbClient.RESOURCE_TARGET, pnf_resource).build())); + } + } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java index b07e82b8a8..e47c61d8b4 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java @@ -55,4 +55,14 @@ public class WorkflowRepositoryTest extends BaseTest { Assert.assertTrue("testingWorkflow.bpmn".equals(workflows.get(0).getArtifactName())); } + @Test + public void findByResourceTargetTest() { + List workflows = workflowRepository.findByResourceTarget("pnf"); + + Assert.assertTrue(workflows != null); + Assert.assertTrue(workflows.size() == 1); + + Assert.assertTrue("DummyPnfWorkflow".equals(workflows.get(0).getArtifactName())); + } + } -- cgit 1.2.3-korg