diff options
37 files changed, 559 insertions, 616 deletions
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java index 0e25729610..00e5c4aaec 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java @@ -127,13 +127,6 @@ public class NssmfManager { break; case TRANSPORT: - AllocateTnNssi tn = nssmiAllocate.getAllocateTnNssi(); - assertObjectNotNull(tn); - assertObjectNotNull(tn.getNsiInfo()); - assertObjectNotNull(tn.getNsiInfo().getNsiId()); - nsiId = tn.getNsiInfo().getNsiId(); - allocateReq = marshal(tn); - allocateUrl = AllocateTnNssi.URL; break; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index 37fef1aa64..10f39f717f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -304,6 +304,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE); + if (portIds == null) + return; for (String portId : portIds) { Port port = osClient.getPortById(portId); Network network = osClient.getNetworkById(port.getNetworkId()); @@ -321,7 +323,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { lIf.setInterfaceRole(port.getvNicType()); } boolean isL2Multicast = false; - if (port.getProfile().get("trusted") != null) { + if (port.getProfile() != null && port.getProfile().get("trusted") != null) { String trusted = port.getProfile().get("trusted").toString(); if (Boolean.parseBoolean(trusted)) { isL2Multicast = true; diff --git a/adapters/so-appc-orchestrator/pom.xml b/adapters/so-appc-orchestrator/pom.xml index 2229c1a60b..68814fc075 100644 --- a/adapters/so-appc-orchestrator/pom.xml +++ b/adapters/so-appc-orchestrator/pom.xml @@ -56,6 +56,16 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>original</id> + <phase>package</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <executions> <execution> diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java index 65e7b35506..99b83f1de3 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java @@ -59,9 +59,9 @@ public class ApplicationControllerClient { private static final String CLIENT_NAME = "MSO"; - private static final String API_VER = "2.00"; - private static final String ORIGINATOR_ID = "MSO"; - private static final int FLAGS_TTL = 65000; + protected static final String API_VER = "2.00"; + protected static final String ORIGINATOR_ID = "MSO"; + protected static final int FLAGS_TTL = 65000; private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClient.class); @Autowired @@ -216,13 +216,12 @@ public class ApplicationControllerClient { return requestObject; } - private CommonHeader buildCommonHeader(String requestId, String requestorId) { + protected CommonHeader buildCommonHeader(String requestId, String requestorId) { CommonHeader commonHeader = new CommonHeader(); commonHeader.setApiVer(API_VER); commonHeader.setOriginatorId(ORIGINATOR_ID); commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); commonHeader.setSubRequestId(UUID.randomUUID().toString()); - // commonHeader.setXOnapRequestorid(requestorId); Flags flags = new Flags(); String flagsMode = "NORMAL"; Mode mode = Mode.valueOf(flagsMode); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java deleted file mode 100644 index dc5b6308bb..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.appc; - -import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; -import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; -import org.onap.appc.client.lcm.api.ApplicationContext; -import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; -import org.onap.appc.client.lcm.exceptions.AppcClientException; -import org.onap.appc.client.lcm.model.*; -import org.onap.appc.client.lcm.model.Flags.Force; -import org.onap.appc.client.lcm.model.Flags.Mode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.time.Instant; -import java.util.Properties; -import java.util.UUID; - -@Component -@Deprecated -public class ApplicationControllerClientV2 { - - private static final String CLIENT_NAME = "MSO"; - private static final String API_VER = "2.00"; - private static final String ORIGINATOR_ID = "MSO"; - private static final int FLAGS_TTL = 65000; - private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClientV2.class); - - // @Autowired - ApplicationControllerConfiguration applicationControllerConfiguration; - - // @Autowired - private ApplicationControllerSupport appCSupport; - - private static LifeCycleManagerStateful client; - - // @PostConstruct - public void buildClient() { - client = this.getAppCClient(""); - } - - // @PostConstruct - public void buildClient(String controllerType) { - client = this.getAppCClient(controllerType); - } - - public Status runCommand(Action action, ActionIdentifiers actionIdentifiers, Payload payload, String requestID) - throws ApplicationControllerOrchestratorException { - Object requestObject; - requestObject = createRequest(action, actionIdentifiers, payload, requestID); - appCSupport.logLCMMessage(requestObject); - Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false); - try { - Object response = lcmMethod.invoke(client, requestObject); - return appCSupport.getStatusFromGenericResponse(response); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e); - } - } - - public LifeCycleManagerStateful getAppCClient(String controllerType) { - if (client == null) - try { - client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) - .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); - } catch (AppcClientException e) { - logger.error("Error in getting LifeCycleManagerStateful Client", e); - } - return client; - } - - protected Properties getLCMProperties(String controllerType) { - Properties properties = new Properties(); - properties.put("topic.read", applicationControllerConfiguration.getReadTopic()); - properties.put("topic.read.timeout", applicationControllerConfiguration.getReadTimeout()); - properties.put("client.response.timeout", applicationControllerConfiguration.getResponseTimeout()); - properties.put("topic.write", applicationControllerConfiguration.getWrite()); - properties.put("poolMembers", applicationControllerConfiguration.getPoolMembers()); - properties.put("client.key", applicationControllerConfiguration.getClientKey()); - properties.put("client.secret", applicationControllerConfiguration.getClientSecret()); - properties.put("client.name", CLIENT_NAME); - properties.put("service", applicationControllerConfiguration.getService()); - return properties; - } - - public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { - Object requestObject = appCSupport.getInput(action.name()); - try { - CommonHeader commonHeader = buildCommonHeader(requestId); - requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, - commonHeader); - requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); - requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class) - .invoke(requestObject, identifier); - if (payload != null) { - requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload); - } - } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { - logger.error("Error building Appc request", e); - } - return requestObject; - } - - private CommonHeader buildCommonHeader(String requestId) { - CommonHeader commonHeader = new CommonHeader(); - commonHeader.setApiVer(API_VER); - commonHeader.setOriginatorId(ORIGINATOR_ID); - commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); - commonHeader.setSubRequestId(requestId); - Flags flags = new Flags(); - String flagsMode = "NORMAL"; - Mode mode = Mode.valueOf(flagsMode); - flags.setMode(mode); - String flagsForce = "FALSE"; - Force force = Force.valueOf(flagsForce); - flags.setForce(force); - flags.setTtl(FLAGS_TTL); - commonHeader.setFlags(flags); - Instant timestamp = Instant.now(); - ZULU zulu = new ZULU(timestamp.toString()); - commonHeader.setTimestamp(zulu); - return commonHeader; - } - - public Flags createRequestFlags() { - Flags flags = new Flags(); - flags.setTtl(6000); - return flags; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java deleted file mode 100644 index b39ba5f63f..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.appc; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ApplicationControllerConfiguration { - @Value("${appc.client.topic.read.name}") - private String readTopic; - - @Value("${appc.client.topic.read.timeout}") - private String readTimeout; - - @Value("${appc.client.response.timeout}") - private String responseTimeout; - - @Value("${appc.client.topic.write}") - private String write; - - @Value("${appc.client.poolMembers}") - private String poolMembers; - - @Value("${appc.client.key}") - private String clientKey; - - @Value("${appc.client.secret}") - private String clientSecret; - - @Value("${appc.client.service}") - private String service; - - public String getClientKey() { - return clientKey; - } - - public String getClientSecret() { - return clientSecret; - } - - public String getPoolMembers() { - return poolMembers; - } - - public String getReadTimeout() { - return readTimeout; - } - - public String getResponseTimeout() { - return responseTimeout; - } - - public String getReadTopic() { - return readTopic; - } - - public String getService() { - return service; - } - - public String getWrite() { - return write; - } -} - diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java deleted file mode 100644 index c242017838..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.appc; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.appc.client.lcm.model.Action; -import org.onap.appc.client.lcm.model.ActionIdentifiers; -import org.onap.appc.client.lcm.model.CheckLockInput; -import org.onap.appc.client.lcm.model.Status; -import org.onap.so.BaseTest; -import java.util.Properties; -import java.util.UUID; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class ApplicationControllerClientV2Test { - - @Mock - ApplicationControllerSupport applicationControllerSupport; - - @Mock - ApplicationControllerConfiguration applicationControllerConfiguration; - - @InjectMocks - ApplicationControllerClientV2 client; - - - @Before - public void setup() { - when(applicationControllerConfiguration.getReadTopic()).thenReturn("APPC-TEST-AMDOCS2"); - when(applicationControllerConfiguration.getReadTimeout()).thenReturn("120000"); - when(applicationControllerConfiguration.getResponseTimeout()).thenReturn("120000"); - when(applicationControllerConfiguration.getWrite()).thenReturn("APPC-TEST-AMDOCS1-DEV3"); - when(applicationControllerConfiguration.getService()).thenReturn("ueb"); - when(applicationControllerConfiguration.getPoolMembers()) - .thenReturn("localhost:3904,localhost:3904,localhost:3904"); - when(applicationControllerConfiguration.getClientKey()).thenReturn("iaEMAfjsVsZnraBP"); - when(applicationControllerConfiguration.getClientSecret()).thenReturn("wcivUjsjXzmGFBfxMmyJu9dz"); - // client.buildClient(); - } - - @BeforeClass - public static void beforeClass() { - System.setProperty("mso.config.path", "src/test/resources"); - } - - @Ignore - @Test - public void createRequest_CheckLock_RequestBuilt() { - ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); - actionIdentifiers.setVnfId("vnfId"); - // when(applicationControllerSupport.getInput(eq(Action.CheckLock.name()))).thenReturn(new CheckLockInput()); - CheckLockInput checkLockInput = - (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null, "requestId"); - assertEquals(checkLockInput.getAction().name(), "CheckLock"); - } - - @Ignore - @Test - public void runCommand_liveAppc() { - ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); - // actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f"); - actionIdentifiers.setVnfId("2d2bf10e-81a5-"); - Status status; - // when(applicationControllerSupport.getInput(eq(Action.Lock.name()))).thenReturn(new LockInput()); - // when(applicationControllerSupport.getAPIMethod(anyString(),any(),anyBoolean())).thenCallRealMethod(); - try { - status = client.runCommand(Action.Lock, actionIdentifiers, null, UUID.randomUUID().toString()); - } catch (ApplicationControllerOrchestratorException e) { - status = new Status(); - status.setCode(e.getAppcCode()); - status.setMessage(e.getMessage()); - } - assertEquals("Status of run command is correct", status.getCode(), 306); - } - - @Ignore - @Test - public void runCommand_CheckLock_RequestBuilt() { - ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); - actionIdentifiers.setVnfId("fusion-vpp-vnf-001"); - Status status; - try { - status = client.runCommand(Action.Unlock, actionIdentifiers, null, "requestId"); - } catch (ApplicationControllerOrchestratorException e) { - status = new Status(); - status.setCode(e.getAppcCode()); - status.setMessage(e.getMessage()); - } - assertEquals("Status of run command is correct", status.getCode(), 309); - } - - @Ignore - @Test - public void test_getLCMPropertiesHelper() { - Properties properties = client.getLCMProperties(""); - assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3"); - assertEquals(properties.get("topic.read.timeout"), "120000"); - assertEquals(properties.get("client.response.timeout"), "120000"); - assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2"); - assertEquals(properties.get("poolMembers"), "localhost:3904,localhost:3904,localhost:3904"); - assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP"); - assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz"); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java index 805597cd12..00dda299b6 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java @@ -20,7 +20,19 @@ package org.onap.so.bpmn.infrastructure.process; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; import org.junit.Test; @@ -35,14 +47,6 @@ import org.onap.so.bpmn.mock.FileUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static org.assertj.core.api.Assertions.fail; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** * Basic Integration test for ServiceLevelUpgrade.bpmn workflow. diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java index 0671354bd6..e26195158d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java @@ -20,32 +20,58 @@ package org.onap.so.bpmn.infrastructure.service.level; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.Workflow; +import org.onap.so.db.catalog.client.CatalogDbClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; -import java.util.List; /** - * Abstract class for Service level upgrade Execution, it should be extended for service level upgrade tasks. + * Parent class for Service level upgrade Execution, it should be extended for service level upgrade tasks. */ -public abstract class AbstractServiceLevelPreparable { +public class ServiceLevelPreparable { - protected static final Logger LOG = LoggerFactory.getLogger(AbstractServiceLevelPreparable.class); + protected static final Logger LOG = LoggerFactory.getLogger(ServiceLevelPreparable.class); @Autowired protected ExceptionBuilder exceptionBuilder; + @Autowired + protected CatalogDbClient catalogDbClient; + /** - * This method fetches workflow names to be invoked based on the controller scope . + * Fetches workflow names based on the controller scope and operation name. * * @param scope Controller scope + * @param operationName healthcheck/softwareUpgrade * @return String value of Workflow name */ - protected abstract String fetchWorkflowUsingScope(DelegateExecution execution, final String scope); + protected String fetchWorkflowUsingScope(final String scope, String operationName) { + Optional<String> wflName = Optional.empty(); + try { + List<Workflow> workflows = catalogDbClient.findWorkflowByOperationName(operationName); + if (!workflows.isEmpty()) { + wflName = Optional.ofNullable( + workflows.stream().filter(workflow -> workflow.getResourceTarget().equalsIgnoreCase(scope)) + .findFirst().get().getName()); + } + } catch (Exception e) { + // do nothing and assign the default workflow in finally + LOG.error("Error occurred while fetching workflow name from CatalogDb {}", e); + } finally { + if (wflName.isEmpty()) { + wflName = Optional.of(ServiceLevelConstants.WORKFLOW_OPERATIONS_MAP.get(operationName).get(scope)); + } + } + return wflName.get(); + + } /** * This method validates the execution parameters to be passed for health check workflow. diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java index 34ebb308c3..d94641846d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java @@ -1,5 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.service.level.impl; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + public class ServiceLevelConstants { public static final String BPMN_REQUEST = "bpmnRequest"; public static final String RESOURCE_TYPE = "resourceType"; @@ -8,13 +32,27 @@ public class ServiceLevelConstants { public static final String PNF = "pnf"; public static final String VNF = "vnf"; public static final String EMPTY_STRING = ""; - public static final String WORKFLOW_TO_INVOKE = "healthCheckWorkflow"; + public static final String HEALTH_CHECK_WORKFLOW_TO_INVOKE = "healthCheckWorkflow"; public static final String SOFTWARE_WORKFLOW_TO_INVOKE = "softwareUpgradeWorkflow"; - public static final String GENERIC_PNF_HEALTH_CHECK_WORKFLOW = "GenericPnfHealthCheck"; - public static final String PNF_SOFTWARE_UPGRADE_WORKFLOW = "PNFSoftwareUpgrade"; + public static final String HEALTH_CHECK_OPERATION = "ResourceHealthCheck"; + public static final String SW_UP_OPERATION = "ResourceSoftwareUpgrade"; public static final String CONTROLLER_STATUS = "ControllerStatus"; public static final int ERROR_CODE = 601; - // TODO This value needs to be updated once vnf health check workflow is available - protected static final String GENERIC_VNF_HEALTH_CHECK_WORKFLOW = "GenericVNFHealthCheck"; + + // TODO GenericVNFHealthCheck and GenericVnfSoftwareUpgrade workflow names should be updated once the workflow is + // implemented. + public static final Map<String, String> DEFAULT_HEALTH_CHECK_WORKFLOWS = + Map.of(PNF, "GenericPnfHealthCheck", VNF, "GenericVNFHealthCheck"); + + public static final Map<String, String> DEFAULT_SOFTWARE_UP_WORKFLOWS = + Map.of(PNF, "PNFSoftwareUpgrade", VNF, "GenericVnfSoftwareUpgrade"); + + // Maps operation name with workflows + public static final Map<String, Map<String, String>> WORKFLOW_OPERATIONS_MAP = Map.of(HEALTH_CHECK_OPERATION, + DEFAULT_HEALTH_CHECK_WORKFLOWS, SW_UP_OPERATION, DEFAULT_SOFTWARE_UP_WORKFLOWS); + + public static final List<String> VALID_CONTROLLER_SCOPE = Arrays.asList(PNF, VNF); + + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java index 5b772760f0..59884ecbc2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java @@ -20,59 +20,54 @@ package org.onap.so.bpmn.infrastructure.service.level.impl; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable; +import org.onap.so.bpmn.infrastructure.service.level.ServiceLevelPreparable; import org.springframework.stereotype.Component; -import java.util.Arrays; -import java.util.List; + /** * Fetches health check workflow based on the controller_scope. Invoke the corresponding health check workflow after * validation. */ @Component("ServiceLevelPreparation") -public class ServiceLevelPreparation extends AbstractServiceLevelPreparable implements JavaDelegate { +public class ServiceLevelPreparation extends ServiceLevelPreparable implements JavaDelegate { - private static final List<String> PNF_HC_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, + private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); + // TODO Update the list with vnf health check parameters if any validation needed + private static final List<String> VNF_HEALTH_CHECK_PARAMS = Collections.emptyList(); + + private static final Map<String, List<String>> HEALTH_CHECK_PARAMS_MAP = Map.of(ServiceLevelConstants.PNF, + PNF_HEALTH_CHECK_PARAMS, ServiceLevelConstants.VNF, VNF_HEALTH_CHECK_PARAMS); + @Override public void execute(DelegateExecution execution) throws Exception { if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE) && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) { final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE); LOG.debug("Scope retrieved from delegate execution: " + controllerScope); - final String wflName = fetchWorkflowUsingScope(execution, controllerScope); - LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName); - - if (ServiceLevelConstants.PNF.equalsIgnoreCase(controllerScope)) { - validateParamsWithScope(execution, controllerScope, PNF_HC_PARAMS); + if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) { + final String wflName = + fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.HEALTH_CHECK_OPERATION); + LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName); + validateParamsWithScope(execution, controllerScope, HEALTH_CHECK_PARAMS_MAP.get(controllerScope)); LOG.info("Parameters validated successfully for {}", wflName); + execution.setVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE, wflName); + execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING); + } else { + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, + "Invalid Controller scope to prepare resource level health check"); } - execution.setVariable(ServiceLevelConstants.WORKFLOW_TO_INVOKE, wflName); - execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING); } else { exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, - "Controller scope not found to invoke resource level health check"); - } - } - - @Override - public String fetchWorkflowUsingScope(DelegateExecution execution, final String scope) { - String wflName = null; - switch (scope.toLowerCase()) { - case ServiceLevelConstants.PNF: - wflName = ServiceLevelConstants.GENERIC_PNF_HEALTH_CHECK_WORKFLOW; - break; - case ServiceLevelConstants.VNF: - wflName = ServiceLevelConstants.GENERIC_VNF_HEALTH_CHECK_WORKFLOW; - break; - default: - exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, - "No valid health check work flow retrieved for the scope: " + scope); + "Resource type not found in the execution to invoke resource level health check"); } - return wflName; } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java index dfc77d6f0c..9d7d8efb65 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java @@ -1,34 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.service.level.impl; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable; +import org.onap.so.bpmn.infrastructure.service.level.ServiceLevelPreparable; import org.springframework.stereotype.Component; -import java.util.Arrays; -import java.util.List; @Component -public class ServiceLevelUpgrade extends AbstractServiceLevelPreparable implements JavaDelegate { +public class ServiceLevelUpgrade extends ServiceLevelPreparable implements JavaDelegate { - private static final List<String> PNF_SWU_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, + private static final List<String> PNF_SOFTWARE_UP_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); - @Override - protected String fetchWorkflowUsingScope(DelegateExecution execution, String scope) { - String wflName = null; - switch (scope.toLowerCase()) { - case ServiceLevelConstants.PNF: - wflName = ServiceLevelConstants.PNF_SOFTWARE_UPGRADE_WORKFLOW; - break; - case ServiceLevelConstants.VNF: - wflName = ServiceLevelConstants.GENERIC_VNF_HEALTH_CHECK_WORKFLOW; - break; - default: - exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, - "No valid health check work flow retrieved for the scope: " + scope); - } - return wflName; - } + // TODO Update the list with vnf software upgrade parameters if any validation needed + private static final List<String> VNF_SOFTWARE_UP_PARAMS = Collections.emptyList(); + + private static final Map<String, List<String>> SOFTWARE_UP_PARAMS_MAP = Map.of(ServiceLevelConstants.PNF, + PNF_SOFTWARE_UP_PARAMS, ServiceLevelConstants.VNF, VNF_SOFTWARE_UP_PARAMS); + @Override public void execute(DelegateExecution execution) throws Exception { @@ -36,19 +48,20 @@ public class ServiceLevelUpgrade extends AbstractServiceLevelPreparable implemen && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) { final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE); LOG.debug("Scope retrieved from delegate execution: " + controllerScope); - final String wflName = fetchWorkflowUsingScope(execution, controllerScope); - LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName); - - if ("pnf".equalsIgnoreCase(controllerScope)) { - validateParamsWithScope(execution, controllerScope, PNF_SWU_PARAMS); + if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) { + final String wflName = fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.SW_UP_OPERATION); + LOG.debug("Software Upgrade workflow fetched for the scope: {} is: {}", controllerScope, wflName); + validateParamsWithScope(execution, controllerScope, SOFTWARE_UP_PARAMS_MAP.get(controllerScope)); LOG.info("Parameters validated successfully for {}", wflName); execution.setVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE, wflName); execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ""); + } else { + exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, + "Invalid Controller scope for resource level software upgrade"); } - } else { exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE, - "Controller scope not found to invoke resource level health check"); + "Resource type not found in the execution to invoke resource level software upgrade"); } } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java index 340b2776a4..0b1c5b0f5e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java @@ -20,6 +20,13 @@ package org.onap.so.bpmn.infrastructure.service.level; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; @@ -27,23 +34,16 @@ 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.InjectMocks; +import org.mockito.Spy; +import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants; import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelPreparation; import org.onap.so.client.exception.ExceptionBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import static org.assertj.core.api.Assertions.assertThat; +import org.onap.so.db.catalog.beans.Workflow; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {ServiceLevelPreparation.class, ExceptionBuilder.class}) -public class ServiceLevelPreparationTest { +public class ServiceLevelPreparationTest extends BaseTaskTest { private static final String TEST_PNF_SCOPE = "pnf"; private static final String TEST_PROCESS_KEY = "testProcessKey"; @@ -52,42 +52,29 @@ public class ServiceLevelPreparationTest { private static final String RESOURCE_TYPE = "resourceType"; private static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; private static final String PNF_NAME = "pnfName"; - private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID, - ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME); + private static final String HEALTH_CHECK_OPERATION = "ResourceHealthCheck"; + private static final String PNF_HEALTH_CHECK_WORKFLOW = "PNFHealthCheck"; + private static final Map<String, List<String>> HEALTH_CHECK_PARAMS_MAP = Map.of(TEST_PNF_SCOPE, + Arrays.asList(SERVICE_INSTANCE_ID, RESOURCE_TYPE, BPMN_REQUEST, PNF_NAME), "vnf", Collections.emptyList()); + + private List<Workflow> workflowList = new ArrayList<>(); - private Map<String, String> pnfHealthCheckTestParams = new HashMap<>(); + @Rule + public ExpectedException thrown = ExpectedException.none(); - @Autowired + @InjectMocks private ServiceLevelPreparation serviceLevelPrepare; - @Autowired + @InjectMocks + @Spy private ExceptionBuilder exceptionBuilder; - @Rule - public ExpectedException thrown = ExpectedException.none(); - private DelegateExecution execution = new DelegateExecutionFake(); private DelegateExecution invalidExecution = new DelegateExecutionFake(); @Before public void setUpPnfUpgradeTest() { - pnfHealthCheckTestParams.put("TEST_SERVICE_MODEL_INFO", "d4c6855e-3be2-5dtu-9390-c999a38829bc"); - pnfHealthCheckTestParams.put("TEST_SERVICE_INSTANCE_NAME", "test_service_id"); - pnfHealthCheckTestParams.put("TEST_PNF_CORRELATION_ID", "pnfCorrelationId"); - pnfHealthCheckTestParams.put("TEST_MODEL_UUID", "6bc0b04d-1873-4721-b53d-6615225b2a28"); - pnfHealthCheckTestParams.put("TEST_PNF_UUID", "c93g70d9-8de3-57f1-7de1-f5690ac2b005"); - pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_NAME", "serviceUpgrade"); - pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_VERSION", "1.0.2"); - pnfHealthCheckTestParams.put("TEST_PRC_CUSTOMIZATION_UUID", "PRC_customizationUuid"); - pnfHealthCheckTestParams.put("TEST_RESOURCE_CUSTOMIZATION_UUID_PARAM", "9acb3a83-8a52-412c-9a45-901764938144"); - pnfHealthCheckTestParams.put("TEST_PRC_INSTANCE_NAME", "Demo_pnf"); - pnfHealthCheckTestParams.put("TEST_PRC_CONTROLLER_ACTOR", "cds"); - pnfHealthCheckTestParams.put("TEST_REQUEST_PAYLOAD", "test_payload"); - - for (String param : PNF_HEALTH_CHECK_PARAMS) { - execution.setVariable(param, pnfHealthCheckTestParams.get("TEST_" + param)); - } execution.setVariable(RESOURCE_TYPE, TEST_PNF_SCOPE); execution.setVariable(TEST_PROCESS_KEY, PROCESS_KEY_VALUE); execution.setVariable(BPMN_REQUEST, "bpmnRequestValue"); @@ -95,14 +82,22 @@ public class ServiceLevelPreparationTest { execution.setVariable(PNF_NAME, "PnfDemo"); invalidExecution.setVariables(execution.getVariables()); + + Workflow pnfWorkflow = new Workflow(); + pnfWorkflow.setName(PNF_HEALTH_CHECK_WORKFLOW); + pnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION); + pnfWorkflow.setResourceTarget(TEST_PNF_SCOPE); + workflowList.add(pnfWorkflow); + + when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList); } @Test public void executePnfUpgradeSuccessTest() throws Exception { serviceLevelPrepare.execute(execution); // Expect the pnf health check workflow to be set in to execution if validation is successful - assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.WORKFLOW_TO_INVOKE))) - .isEqualTo("GenericPnfHealthCheck"); + assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE))) + .isEqualTo("PNFHealthCheck"); } @Test @@ -110,7 +105,8 @@ public class ServiceLevelPreparationTest { invalidExecution.removeVariable(BPMN_REQUEST); // BPMN exception is thrown in case of validation failure or invalid execution thrown.expect(BpmnError.class); - serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE, PNF_HEALTH_CHECK_PARAMS); + serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE, + HEALTH_CHECK_PARAMS_MAP.get(TEST_PNF_SCOPE)); } @Test @@ -129,6 +125,32 @@ public class ServiceLevelPreparationTest { } + @Test + public void validateDefaultWorkflowIsSetWithoutDBData() throws Exception { + // Mock empty workflow list in db response + when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(new ArrayList<Workflow>()); + serviceLevelPrepare.execute(execution); + // Expect default workflow gets assigned when workflow name not found in db. + assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE))) + .isEqualTo(ServiceLevelConstants.DEFAULT_HEALTH_CHECK_WORKFLOWS.get(TEST_PNF_SCOPE)); + } + + @Test + public void validateWorkflowSetFromDb() throws Exception { + Workflow vnfWorkflow = new Workflow(); + vnfWorkflow.setName("VNFHealthCheck"); + vnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION); + vnfWorkflow.setResourceTarget("vnf"); + workflowList.add(vnfWorkflow); + // Mock db response with multiple worklfows mapped with same operation name + when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList); + serviceLevelPrepare.execute(execution); + + // Expect right workflow gets assigned from db based on the controller scope. + assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE))) + .isEqualTo(PNF_HEALTH_CHECK_WORKFLOW); + } + } diff --git a/common/pom.xml b/common/pom.xml index 08554480c3..ff13da4ee6 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -271,6 +271,15 @@ </exclusions> </dependency> <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.validation</groupId> + <artifactId>validation-api</artifactId> + </dependency> + <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java new file mode 100644 index 0000000000..64f1df2590 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java @@ -0,0 +1,23 @@ +package org.onap.so.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class AdditionalProperties implements Serializable { + + private static final long serialVersionUID = -4020397418955518175L; + + private SliceProfile sliceProfile; + + private List<EndPoint> endPoints; + + private NsiInfo nsiInfo; + + private String scriptName; + + private ModifyAction modifyAction; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java index 484f5b42b1..156f999773 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java @@ -25,12 +25,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) public class AllocateAnNssi { + @Deprecated public final static String URL = "/api/rest/provMns/v1/an/NSS" + "/SliceProfiles"; private String nsstId; - private String flavorId; - private String nssiId; private String nssiName; @@ -51,14 +50,6 @@ public class AllocateAnNssi { this.nsstId = nsstId; } - public String getFlavorId() { - return flavorId; - } - - public void setFlavorId(String flavorId) { - this.flavorId = flavorId; - } - public String getNssiId() { return nssiId; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java index d03673368c..1d8b15e69a 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java @@ -27,6 +27,7 @@ import java.io.Serializable; public class AllocateCnNssi implements Serializable { public final static String URL = "/api/rest/provMns/v1/NSS/SliceProfiles"; + private static final long serialVersionUID = 4909074863148869163L; private String nsstId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateNssi.java new file mode 100644 index 0000000000..1dc6d0f1c5 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateNssi.java @@ -0,0 +1,4 @@ +package org.onap.so.beans.nsmf; + +public class AllocateNssi { +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java index b66fb133d2..f85cb0cd85 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java @@ -20,90 +20,17 @@ package org.onap.so.beans.nsmf; -import com.fasterxml.jackson.annotation.JsonInclude; -@JsonInclude(JsonInclude.Include.NON_NULL) -public class AllocateTnNssi { +import lombok.Data; +import java.io.Serializable; +import java.util.List; - public final static String URL = "/api/rest/provMns/v1/tn/NSS" + "/SliceProfiles"; +@Data +public class AllocateTnNssi implements Serializable { - private String nsstId; + private static final long serialVersionUID = -7069801712339914746L; - private String flavorId; + private List<NetworkSliceInfo> networkSliceInfos; - private String nssiId; - - private String nssiName; - - private TnSliceProfile sliceProfile; - - private String scriptName; - - private Object extension; - - private NsiInfo nsiInfo; - - public String getNsstId() { - return nsstId; - } - - public void setNsstId(String nsstId) { - this.nsstId = nsstId; - } - - public String getFlavorId() { - return flavorId; - } - - public void setFlavorId(String flavorId) { - this.flavorId = flavorId; - } - - public String getNssiId() { - return nssiId; - } - - public void setNssiId(String nssiId) { - this.nssiId = nssiId; - } - - public String getNssiName() { - return nssiName; - } - - public void setNssiName(String nssiName) { - this.nssiName = nssiName; - } - - public TnSliceProfile getSliceProfile() { - return sliceProfile; - } - - public void setSliceProfile(TnSliceProfile sliceProfile) { - this.sliceProfile = sliceProfile; - } - - public String getScriptName() { - return scriptName; - } - - public void setScriptName(String scriptName) { - this.scriptName = scriptName; - } - - public Object getExtension() { - return extension; - } - - public void setExtension(Object extension) { - this.extension = extension; - } - - public NsiInfo getNsiInfo() { - return nsiInfo; - } - - public void setNsiInfo(NsiInfo nsiInfo) { - this.nsiInfo = nsiInfo; - } + private List<TransportSliceNetwork> transportSliceNetworks; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java index 3d60949385..653f9ac495 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java @@ -22,40 +22,31 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) +@Data public class AnSliceProfile { - @JsonProperty("5QI") - private String qi; + private List<String> sNSSAIList; + + private String sliceProfileId; private List<String> coverageAreaTAList; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int latency; - public String getQi() { - return qi; - } + private List<String> pLMNIdList; - public void setQi(String qi) { - this.qi = qi; - } + private PerfReq perfReq; - public List<String> getCoverageAreaTAList() { - return coverageAreaTAList; - } + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int maxNumberofUEs; - public void setCoverageAreaTAList(List<String> coverageAreaTAList) { - this.coverageAreaTAList = coverageAreaTAList; - } + private UeMobilityLevel uEMobilityLevel; - public int getLatency() { - return latency; - } + private ResourceSharingLevel resourceSharingLevel; - public void setLatency(int latency) { - this.latency = latency; - } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java new file mode 100644 index 0000000000..ca0c684779 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java @@ -0,0 +1,33 @@ +package org.onap.so.beans.nsmf; + + +import java.io.Serializable; + + +public class ConnectionLink implements Serializable { + private static final long serialVersionUID = -1834584960407180427L; + + private String transportEndpointA; + + private String transportEndpointB; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getTransportEndpointA() { + return transportEndpointA; + } + + public void setTransportEndpointA(String transportEndpointA) { + this.transportEndpointA = transportEndpointA; + } + + public String getTransportEndpointB() { + return transportEndpointB; + } + + public void setTransportEndpointB(String transportEndpointB) { + this.transportEndpointB = transportEndpointB; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java index 648fd4985f..1ee83c7db0 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java @@ -26,6 +26,7 @@ import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) public class DeAllocateNssi { + @Deprecated public final static String URL = "/api/rest/provMns/v1/NSS" + "/SliceProfiles/%s"; private String nsiId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java new file mode 100644 index 0000000000..a55672f37f --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java @@ -0,0 +1,17 @@ +package org.onap.so.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class EndPoint implements Serializable { + + private static final long serialVersionUID = 2479795890807020491L; + + private String nodeId; + + private Map<String, Object> additionalInfo; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java index d720399293..f8ff5be70e 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java @@ -26,6 +26,7 @@ import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) public class EsrInfo implements Serializable { + private static final long serialVersionUID = -7696600990607396263L; private String vendor; private NetworkType networkType; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java b/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java new file mode 100644 index 0000000000..8206b527cd --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java @@ -0,0 +1,5 @@ +package org.onap.so.beans.nsmf; + +public enum ModifyAction { + allocate, deallocate +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java new file mode 100644 index 0000000000..67701a1922 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java @@ -0,0 +1,16 @@ +package org.onap.so.beans.nsmf; + + +import lombok.Data; +import java.io.Serializable; + +@Data +public class NetworkSliceInfo implements Serializable { + private static final long serialVersionUID = 4401921718259398587L; + + private String snssai; + + private String customer; + + private String serviceType; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java index 0ff554d10d..d1679c6dfa 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java @@ -37,11 +37,11 @@ public class NsiInfo { this.nsiName = nsiName; } - public void setNsiId(String nsiId) { - this.nsiId = nsiId; - } - public String getNsiId() { return nsiId; } + + public void setNsiId(String nsiId) { + this.nsiId = nsiId; + } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java index f72a74a063..9a25d6fea3 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java @@ -21,10 +21,15 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import javax.validation.constraints.NotNull; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class NssiAllocateRequest { +public class NssiAllocateRequest implements Serializable { + private static final long serialVersionUID = -454145891489457960L; + + @NotNull private EsrInfo esrInfo; private AllocateCnNssi allocateCnNssi; @@ -33,6 +38,8 @@ public class NssiAllocateRequest { private AllocateAnNssi allocateAnNssi; + private ServiceInfo serviceInfo; + public EsrInfo getEsrInfo() { return esrInfo; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java new file mode 100644 index 0000000000..e421df456b --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java @@ -0,0 +1,32 @@ +package org.onap.so.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; + + +@Data +public class NssmfAdapterNBIRequest implements Serializable { + + private static final long serialVersionUID = -454145891489457960L; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private EsrInfo esrInfo; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private ServiceInfo serviceInfo; + + private AllocateCnNssi allocateCnNssi; + + private AllocateTnNssi allocateTnNssi; + + private AllocateAnNssi allocateAnNssi; + + private ActDeActNssi actDeActNssi; + + private DeAllocateNssi deAllocateNssi; + + private String subnetCapabilityQuery; + + private String responseId; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java new file mode 100644 index 0000000000..5a1393376f --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java @@ -0,0 +1,54 @@ +package org.onap.so.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class NssmfRequest implements Serializable { + + private static final long serialVersionUID = 3313218757241310655L; + + private String name; + + private String modelInvariantUuid; + + private String modelUuid; + + private String globalSubscriberId; + + private String serviceInstanceId; + + private String subscriptionServiceType; + + private NetworkType networkType; + + private Object additionalProperties; + + public NssmfRequest() {} + + public NssmfRequest(ServiceInfo serviceInfo, NetworkType networkType, Object additionalProperties) { + this.modelInvariantUuid = serviceInfo.getServiceInvariantUuid(); + this.modelUuid = serviceInfo.getServiceUuid(); + this.globalSubscriberId = serviceInfo.getGlobalSubscriberId(); + this.subscriptionServiceType = serviceInfo.getSubscriptionServiceType(); + this.networkType = networkType; + this.additionalProperties = additionalProperties; + this.serviceInstanceId = serviceInfo.getNssiId(); + this.name = serviceInfo.getNssiName(); + } + +} + + +/** + * { "name": "eMBB-001", "modelInvariantUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX", "modelUuid": + * "NSST-C-001-HDBNJ-NSSMF-01-A-ZX-UUID", "globalSubscriberId": "5GCustomer", "subscriptionServiceType": "5G", + * "networkType": "AN/CN/TN", "additionalProperties": { "sliceProfile": { "snssaiList": [ "001-100001" ], + * "sliceProfileId": "ab9af40f13f721b5f13539d87484098", "plmnIdList": [ "460-00", "460-01" ], "perfReq": { + * "perfReqEmbbList ": [ { "activityFactor": 50 } ] }, "maxNumberofUEs": 200, "coverageAreaTAList": [ "1", "2", "3", "4" + * ], "latency": 2, "resourceSharingLevel": "non-shared" }, "endPoints": [ { "nodeId": "", "additionalInfo": { "xxx": + * "xxx" } }, { "nodeId": "", "additionalInfo": { "xxx": "xxx" } } ], "nsiInfo": { "nsiId": + * "NSI-M-001-HDBNJ-NSMF-01-A-ZX", "nsiName": "eMBB-001" }, "scriptName": "AN1" } } + */ diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java new file mode 100644 index 0000000000..f87c032096 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java @@ -0,0 +1,31 @@ +package org.onap.so.beans.nsmf; + +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@Data +public class ServiceInfo implements Serializable { + + private static final long serialVersionUID = 7895110339097615695L; + + private String serviceInvariantUuid; + + private String serviceUuid; + + private String globalSubscriberId; + + private String subscriptionServiceType; + + private String serviceType; + + private String nsiId; + + private String nssiId; + + private String sST; + + private String nssiName; + + private String pLMNIdList; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java index 6c5d9c6909..cc6c9bbb82 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java @@ -21,7 +21,11 @@ package org.onap.so.beans.nsmf; import java.io.Serializable; +import java.util.HashMap; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java new file mode 100644 index 0000000000..62077050ce --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java @@ -0,0 +1,30 @@ +package org.onap.so.beans.nsmf; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class SliceProfile implements Serializable { + + private static final long serialVersionUID = 7924389625656716814L; + + private List<String> snssaiList; + + private String sliceProfileId; + + private List<String> plmnIdList; + + private PerfReq perfReq; + + private Integer maxNumberofUEs; + + private List<String> coverageAreaTAList; + + private Integer latency; + + private String resourceSharingLevel; + +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java new file mode 100644 index 0000000000..bfbbbd3bda --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java @@ -0,0 +1,12 @@ +package org.onap.so.beans.nsmf; + +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@Data +public class TransportSliceNetwork implements Serializable { + private static final long serialVersionUID = 809947462399806990L; + + private List<ConnectionLink> connectionLinks; +} 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 8d342b673d..ef90dd6984 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 @@ -20,6 +20,7 @@ package org.onap.so.db.catalog.client; +import com.google.common.base.Strings; import java.net.URI; import java.util.ArrayList; import java.util.Iterator; @@ -83,7 +84,6 @@ import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; -import com.google.common.base.Strings; import uk.co.blackpepper.bowman.Client; import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; @@ -162,6 +162,7 @@ public class CatalogDbClient { protected static final String SOURCE = "source"; protected static final String RESOURCE_TARGET = "resourceTarget"; protected static final String FLAG = "flag"; + protected static final String OPERATION_NAME = "operationName"; private static final String TARGET_ENTITY = "SO:CatalogDB"; private static final String ASTERISK = "*"; @@ -215,6 +216,7 @@ public class CatalogDbClient { "/findBBNameSelectionReferenceByControllerActorAndScopeAndAction"; private String findWorkflowByResourceTarget = "/findByResourceTarget"; private String findProcessingFlagsByFlag = "/findByFlag"; + private String findWorkflowByOperationName = "/findByOperationName"; private String serviceURI; private String vfModuleURI; @@ -365,6 +367,7 @@ public class CatalogDbClient { + findBBNameSelectionReferenceByControllerActorAndScopeAndAction; findProcessingFlagsByFlag = endpoint + PROCESSING_FLAGS + SEARCH + findProcessingFlagsByFlag; + findWorkflowByOperationName = endpoint + WORKFLOW + SEARCH + findWorkflowByOperationName; serviceURI = endpoint + SERVICE + URI_SEPARATOR; vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR; @@ -1106,6 +1109,11 @@ public class CatalogDbClient { .queryParam(RESOURCE_TARGET, resourceTarget).build().toString())); } + public List<Workflow> findWorkflowByOperationName(String operationName) { + return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByOperationName) + .queryParam(OPERATION_NAME, operationName).build().toString())); + } + public ProcessingFlags findProcessingFlagsByFlag(String flag) { return this.getSingleResource(processingFlagsClient, getUri(UriBuilder.fromUri(findProcessingFlagsByFlag).queryParam(FLAG, flag).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 93ec54a2eb..74843e5531 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 @@ -35,6 +35,8 @@ public interface WorkflowRepository extends JpaRepository<Workflow, Integer> { List<Workflow> findByResourceTarget(String resourceTarget); + List<Workflow> findByOperationName(String operationName); + /** * 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 79e3cbcc08..6a5daa601a 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 @@ -204,4 +204,15 @@ public class CatalogDbClientTest { .queryParam(CatalogDbClient.RESOURCE_TARGET, pnf_resource).build())); } + @Test + public final void testFindWorkFlowByOperationName() { + final String operationName = "PNFSoftwareUpgrade"; + doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any()); + catalogDbClient.findWorkflowByOperationName(operationName); + + // verify + verify(catalogDbClient).getMultipleResources(any(Client.class), eq(UriBuilder.fromUri("/findByOperationName") + .queryParam(CatalogDbClient.OPERATION_NAME, operationName).build())); + } + } |