diff options
Diffstat (limited to 'bpmn')
56 files changed, 4037 insertions, 44 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index ebced8e933..51b1a218c8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -58,7 +58,7 @@ public class AbstractCDSProcessingBBUtils { private static final String FAILED = "Failed"; private static final String PROCESSING = "Processing"; private static final String RESPONSE_PAYLOAD = "CDSResponsePayload"; - private static final String CDS_STATUS = "CDSStatus"; + private static final String CDS_STATUS = "ControllerStatus"; private static final String EXEC_INPUT = "executionServiceInput"; private static final String EXECUTION_OBJECT = "executionObject"; private static final String EXCEPTION = "Exception"; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java new file mode 100644 index 0000000000..eb2567d47c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.restproperties; + +import java.net.MalformedURLException; +import java.net.URL; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.SDNCLcmProperties; + +public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { + + public static final String SDNC_HOST = "sdnc.host"; + public static final String SDNC_AUTH = "sdnc.auth"; + public static final String LCM_PATH = "sdnc.lcm.path"; + + public static final String DMAAP_HOST = "sdnc.dmaap.host"; + public static final String DMAAP_AUTH = "sdnc.dmaap.auth"; + public static final String DMAAP_PARTITION = "sdnc.dmaap.partition"; + public static final String DMAAP_TIMEOUT = "sdnc.dmaap.timeout"; + public static final String DMAAP_ENVIRONMENT = "sdnc.dmaap.environment"; + public static final String LCM_DMAAP_READ_TOPIC = "sdnc.lcm.dmapp.readTopic"; + public static final String LCM_DMAAP_WRITE_TOPIC = "sdnc.lcm.dmaap.writeTopic"; + + public static final String MSO_KEY = "mso.msoKey"; + + public SDNCLcmPropertiesImpl() {} + + @Override + public String getHost() { + return UrnPropertiesReader.getVariable(SDNC_HOST); + } + + @Override + public String getPath() { + String path = UrnPropertiesReader.getVariable(LCM_PATH); + return (path != null) ? path : SDNCConstants.LCM_API_BASE_PATH; + } + + @Override + public String getBasicAuth() { + return UrnPropertiesReader.getVariable(SDNC_AUTH); + } + + @Override + public String getDmaapHost() { + return UrnPropertiesReader.getVariable(DMAAP_HOST); + } + + @Override + public String getDmaapAuth() { + return UrnPropertiesReader.getVariable(DMAAP_AUTH); + } + + @Override + public String getDmaapPartition() { + String partition = UrnPropertiesReader.getVariable(DMAAP_PARTITION); + return (partition != null) ? partition : SDNCConstants.LCM_DMAAP_PARTITION; + } + + @Override + public String getDmaapTimeout() { + String timeout = UrnPropertiesReader.getVariable(DMAAP_TIMEOUT); + return (timeout != null) ? timeout : SDNCConstants.LCM_DMAAP_TIMEOUT; + } + + @Override + public String getDmaapEnvironment() { + String environment = UrnPropertiesReader.getVariable(DMAAP_ENVIRONMENT); + return (environment != null) ? environment : SDNCConstants.LCM_DMAAP_ENVIRONMENT; + } + + @Override + public String getDmaaPLcmReadTopic() { + String readTopic = UrnPropertiesReader.getVariable(LCM_DMAAP_READ_TOPIC); + return (readTopic != null) ? readTopic : SDNCConstants.LCM_DMAAP_READ_TOPIC; + } + + @Override + public String getDmaaPLcmWriteTopic() { + String writeTopic = UrnPropertiesReader.getVariable(LCM_DMAAP_WRITE_TOPIC); + return (writeTopic != null) ? writeTopic : SDNCConstants.LCM_DMAAP_WRITE_TOPIC; + } + + @Override + public String getKey() { + return UrnPropertiesReader.getVariable(MSO_KEY); + } + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(getHost()); + } + + @Override + public String getSystemName() { + return SDNCConstants.SYSTEM_NAME; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java new file mode 100644 index 0000000000..fd9412e70e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.common; + +public interface SDNCConstants { + String SYSTEM_NAME = "MSO"; + + String LCM_API_VER = "2.00"; + + String LCM_FLAGS_MODE_NORMAL = "NORMAL"; + String LCM_FLAGS_MODE_EXCLUSIVE = "EXCLUSIVE"; + + String LCM_FLAGS_FORCE_TRUE = "TRUE"; + String LCM_FLAGS_FORCE_FALSE = "FALSE"; + + int LCM_FLAGS_TTL = 65000; + + String LCM_API_BASE_PATH = "/restconf/operations/LCM:"; + + String LCM_DMAAP_MSG_VER = "1.0"; + String LCM_DMAAP_MSG_TYPE_REQUEST = "request"; + String LCM_DMAAP_MSG_TYPE_RESPONSE = "response"; + + String LCM_DMAAP_PARTITION = "MSOLCM"; + String LCM_DMAAP_TIMEOUT = "20000"; + String LCM_DMAAP_ENVIRONMENT = "TEST"; + String LCM_DMAAP_READ_TOPIC = "SDNC-LCM-WRITE"; + String LCM_DMAAP_WRITE_TOPIC = "SDNC-LCM-READ"; + + int LCM_TIMEOUT = 300; +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java new file mode 100644 index 0000000000..5616db3577 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +import java.net.URI; +import org.onap.so.client.RestPropertiesLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SDNCLcmClientBuilder { + + private static Logger logger = LoggerFactory.getLogger(SDNCLcmClientBuilder.class); + + private final SDNCLcmProperties sdncLcmProperties; + + public SDNCLcmClientBuilder() { + sdncLcmProperties = RestPropertiesLoader.getInstance().getNewImpl(SDNCLcmProperties.class); + } + + public SDNCLcmClientBuilder(SDNCLcmProperties pros) { + sdncLcmProperties = pros; + } + + public SDNCLcmRestClient newSDNCLcmRestClient(String operation) throws SDNCLcmClientBuilderException { + URI pathUri; + try { + String path = sdncLcmProperties.getPath() + operation; + pathUri = new URI(path); + logger.debug("SDNC host: " + sdncLcmProperties.getHost()); + logger.debug("SDNC API path: " + pathUri.getPath()); + } catch (Exception e) { + String msg = "Error API path syntax: "; + logger.error(msg, e); + throw new SDNCLcmClientBuilderException(msg + e.toString()); + } + + try { + SDNCLcmRestClient sdncLcmRestClient = new SDNCLcmRestClient(sdncLcmProperties, pathUri); + logger.debug("Create SDNCLcmRestClient success"); + return sdncLcmRestClient; + } catch (Exception e) { + String msg = "Create SDNCLcmRestClient failure: "; + logger.error(msg, e); + throw new SDNCLcmClientBuilderException(msg + e.toString()); + } + } + + public SDNCLcmDmaapClient newSDNCLcmDmaapClient() throws SDNCLcmClientBuilderException { + try { + SDNCLcmDmaapClient sdncLcmDmaapClient = new SDNCLcmDmaapClient(sdncLcmProperties); + logger.debug("Create SDNCLcmDmaapClient success"); + return sdncLcmDmaapClient; + } catch (Exception e) { + String msg = "Create SDNCLcmDmaapClient failure: "; + logger.error(msg, e); + throw new SDNCLcmClientBuilderException(msg + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilderException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilderException.java new file mode 100644 index 0000000000..9160d4e352 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilderException.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +public class SDNCLcmClientBuilderException extends Exception { + + private static final long serialVersionUID = -1525705272349747712L; + + public SDNCLcmClientBuilderException(String message) { + super(message); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java new file mode 100644 index 0000000000..f6e4ffce59 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.onap.so.client.sdnc.lcm.beans.LcmDmaapRequest; +import org.onap.so.client.sdnc.lcm.beans.LcmDmaapResponse; +import org.onap.so.client.dmaap.rest.RestPublisher; +import org.onap.so.client.dmaap.rest.RestConsumer; + +public class SDNCLcmDmaapClient { + + private static Logger logger = LoggerFactory.getLogger(SDNCLcmDmaapClient.class); + + private RestPublisher dmaapPublisher; + private RestConsumer dmaapConsumer; + + public SDNCLcmDmaapClient(SDNCLcmProperties sdncLcmProperties) { + Properties properties = new Properties(); + + properties.put("host", sdncLcmProperties.getDmaapHost()); + if (sdncLcmProperties.getDmaapAuth() != null && sdncLcmProperties.getKey() != null) { + properties.put("auth", sdncLcmProperties.getDmaapAuth()); + properties.put("key", sdncLcmProperties.getKey()); + } + properties.put("partition", sdncLcmProperties.getDmaapPartition()); + properties.put("timeout", sdncLcmProperties.getDmaapTimeout()); + properties.put("environment", sdncLcmProperties.getDmaapEnvironment()); + + properties.put("topic", sdncLcmProperties.getDmaaPLcmWriteTopic()); + dmaapPublisher = new RestPublisher(properties); + + properties.put("topic", sdncLcmProperties.getDmaaPLcmReadTopic()); + dmaapConsumer = new RestConsumer(properties); + } + + public void sendRequest(LcmDmaapRequest lcmDmaapRequest) throws Exception { + ObjectMapper mapper = new ObjectMapper(); + String lcmRestRequestString = mapper.writeValueAsString(lcmDmaapRequest); + + dmaapPublisher.send(lcmRestRequestString); + } + + public Iterable<String> fetch() { + return dmaapConsumer.fetch(); + } + + public List<LcmDmaapResponse> getResponse() { + List<LcmDmaapResponse> responseList = new ArrayList<>(); + + ObjectMapper mapper = new ObjectMapper(); + Iterable<String> itrString = dmaapConsumer.fetch(); + for (String message : itrString) { + LcmDmaapResponse lcmDmaapResponse; + try { + lcmDmaapResponse = mapper.readValue(message, LcmDmaapResponse.class); + } catch (Exception e) { + logger.warn("Invalid SDNC LCM DMaaP response: " + message); + continue; + } + + responseList.add(lcmDmaapResponse); + } + + return responseList; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java new file mode 100644 index 0000000000..bf1229a310 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +import java.time.Instant; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.beans.*; + +public class SDNCLcmMessageBuilder { + + public static LcmFlags getSDNCFlags() { + LcmFlags lcmFlags = new LcmFlags(); + + lcmFlags.setMode(SDNCConstants.LCM_FLAGS_MODE_NORMAL); + lcmFlags.setForce(SDNCConstants.LCM_FLAGS_FORCE_FALSE); + lcmFlags.setTtl(SDNCConstants.LCM_FLAGS_TTL); + + return lcmFlags; + } + + public static LcmCommonHeader buildLcmCommonHeader(String requestId, String subRequestId) { + LcmCommonHeader lcmCommonHeader = new LcmCommonHeader(); + + lcmCommonHeader.setApiVer(SDNCConstants.LCM_API_VER); + lcmCommonHeader.setOriginatorId(SDNCConstants.SYSTEM_NAME); + lcmCommonHeader.setRequestId(requestId); + lcmCommonHeader.setSubRequestId(subRequestId); + lcmCommonHeader.setFlags(getSDNCFlags()); + lcmCommonHeader.setTimestamp(Instant.now().toString()); + + return lcmCommonHeader; + } + + public static LcmInput buildLcmInputForPnf(String requestId, String subRequestId, String pnfName, String action, + String payload) { + LcmInput lcmInput = new LcmInput(); + + LcmCommonHeader lcmCommonHeader = buildLcmCommonHeader(requestId, subRequestId); + + LcmActionIdentifiers sdncActionIdentifiers = new LcmActionIdentifiers(); + sdncActionIdentifiers.setPnfName(pnfName); + + lcmInput.setCommonHeader(lcmCommonHeader); + lcmInput.setAction(action); + lcmInput.setActionIdentifiers(sdncActionIdentifiers); + lcmInput.setPayload(payload); + + return lcmInput; + } + + public static LcmDmaapRequest buildLcmDmaapRequest(String operation, LcmInput lcmInput) { + LcmDmaapRequest lcmDmaapRequest = new LcmDmaapRequest(); + + LcmRestRequest lcmRestRequest = new LcmRestRequest(); + lcmRestRequest.setInput(lcmInput); + + String correlationId = + lcmInput.getCommonHeader().getRequestId() + "-" + lcmInput.getCommonHeader().getSubRequestId(); + + lcmDmaapRequest.setVersion(SDNCConstants.LCM_DMAAP_MSG_VER); + lcmDmaapRequest.setType(SDNCConstants.LCM_DMAAP_MSG_TYPE_REQUEST); + lcmDmaapRequest.setCambriaPartition(SDNCConstants.SYSTEM_NAME); + lcmDmaapRequest.setCorrelationId(correlationId); + lcmDmaapRequest.setRpcName(operation); + lcmDmaapRequest.setBody(lcmRestRequest); + + return lcmDmaapRequest; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java new file mode 100644 index 0000000000..df5fb3be0b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +import org.onap.so.client.RestProperties; + +public interface SDNCLcmProperties extends RestProperties { + String getHost(); + + String getPath(); + + String getBasicAuth(); + + String getDmaapHost(); + + String getDmaapAuth(); + + String getDmaapPartition(); + + String getDmaapTimeout(); + + String getDmaapEnvironment(); + + String getDmaaPLcmReadTopic(); + + String getDmaaPLcmWriteTopic(); + + String getKey(); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java new file mode 100644 index 0000000000..3faf58ec28 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +import java.net.URI; +import java.util.Map; +import java.util.Optional; +import org.onap.so.client.RestClient; +import org.onap.logging.filter.base.ONAPComponents; +import org.onap.so.client.sdnc.lcm.beans.LcmInput; +import org.onap.so.client.sdnc.lcm.beans.LcmOutput; +import org.onap.so.client.sdnc.lcm.beans.LcmRestRequest; +import org.onap.so.client.sdnc.lcm.beans.LcmRestResponse; + +public class SDNCLcmRestClient extends RestClient { + + private final SDNCLcmProperties sdncLcmProperties; + + public SDNCLcmRestClient(SDNCLcmProperties props, URI path) { + this(props, path, "application/json", "application/json"); + } + + public SDNCLcmRestClient(SDNCLcmProperties props, URI path, String accept, String contentType) { + super(props, Optional.of(path), accept, contentType); + this.sdncLcmProperties = props; + } + + @Override + protected void initializeHeaderMap(Map<String, String> headerMap) { + headerMap.put("Authorization", sdncLcmProperties.getBasicAuth()); + } + + @Override + public ONAPComponents getTargetEntity() { + return ONAPComponents.SDNC; + } + + public LcmRestResponse sendRequest(LcmRestRequest lcmRestRequest) { + return post(lcmRestRequest, LcmRestResponse.class); + } + + public LcmOutput sendRequest(LcmInput lcmInput) { + LcmRestRequest lcmRestRequest = new LcmRestRequest(); + lcmRestRequest.setInput(lcmInput); + + LcmRestResponse lcmRestResponse = sendRequest(lcmRestRequest); + return lcmRestResponse.getOutput(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmActionIdentifiers.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmActionIdentifiers.java new file mode 100644 index 0000000000..883fd02c78 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmActionIdentifiers.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"serviceInstanceId", "vnfId", "vfModuleId", "vnfcName", "vserverId", "pnfName"}) +public class LcmActionIdentifiers { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("vf-module-id") + private String vfModuleId; + + @JsonProperty("vnfc-name") + private String vnfcName; + + @JsonProperty("vserver-id") + private String vserverId; + + @JsonProperty("pnf-name") + private String pnfName; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String value) { + this.serviceInstanceId = value; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String value) { + this.vnfId = value; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String value) { + this.vfModuleId = value; + } + + public String getVnfcName() { + return vnfcName; + } + + public void setVnfcName(String value) { + this.vnfcName = value; + } + + public String getVserverId() { + return vserverId; + } + + public void setVserverId(String value) { + this.vserverId = value; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String value) { + this.pnfName = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmCommonHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmCommonHeader.java new file mode 100644 index 0000000000..f3fd2ca11d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmCommonHeader.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"apiVer", "flags", "originatorId", "requestId", "subRequestId", "timestamp"}) +public class LcmCommonHeader { + + @JsonProperty(value = "api-ver", required = true) + private String apiVer; + + @JsonProperty(value = "flags") + private LcmFlags flags; + + @JsonProperty(value = "originator-id", required = true) + private String originatorId; + + @JsonProperty(value = "request-id", required = true) + private String requestId; + + @JsonProperty(value = "sub-request-id") + private String subRequestId; + + @JsonProperty(value = "timestamp", required = true) + private String timestamp; + + public String getApiVer() { + return apiVer; + } + + public void setApiVer(String value) { + this.apiVer = value; + } + + public String getOriginatorId() { + return originatorId; + } + + public void setOriginatorId(String value) { + this.originatorId = value; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String value) { + this.requestId = value; + } + + public String getSubRequestId() { + return subRequestId; + } + + public void setSubRequestId(String value) { + this.subRequestId = value; + } + + public LcmFlags getFlags() { + return flags; + } + + public void setFlags(LcmFlags value) { + this.flags = value; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String value) { + this.timestamp = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequest.java new file mode 100644 index 0000000000..db62e8b20b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequest.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"version", "type", "cambriaPartition", "correlationId", "rpcName", "body"}) +public class LcmDmaapRequest { + + @JsonProperty(value = "version", required = true) + private String version; + + @JsonProperty(value = "type", required = true) + private String type; + + @JsonProperty(value = "cambria.partition", required = true) + private String cambriaPartition; + + @JsonProperty(value = "correlation-id", required = true) + private String correlationId; + + @JsonProperty(value = "rpc-name", required = true) + private String rpcName; + + @JsonProperty(value = "body") + private LcmRestRequest body; + + public String getVersion() { + return version; + } + + public void setVersion(String value) { + this.version = value; + } + + public String getType() { + return type; + } + + public void setType(String value) { + this.type = value; + } + + public String getCambriaPartition() { + return cambriaPartition; + } + + public void setCambriaPartition(String value) { + this.cambriaPartition = value; + } + + public String getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(String value) { + this.correlationId = value; + } + + public String getRpcName() { + return rpcName; + } + + public void setRpcName(String value) { + this.rpcName = value; + } + + public LcmRestRequest getBody() { + return body; + } + + public void setBody(LcmRestRequest value) { + this.body = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponse.java new file mode 100644 index 0000000000..35f4a26b17 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponse.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"version", "type", "cambriaPartition", "correlationId", "rpcName", "body"}) +public class LcmDmaapResponse { + + @JsonProperty(value = "version", required = true) + private String version; + + @JsonProperty(value = "type", required = true) + private String type; + + @JsonProperty(value = "cambria.partition", required = true) + private String cambriaPartition; + + @JsonProperty(value = "correlation-id", required = true) + private String correlationId; + + @JsonProperty(value = "rpc-name", required = true) + private String rpcName; + + @JsonProperty(value = "body") + private LcmRestResponse body; + + public String getVersion() { + return version; + } + + public void setVersion(String value) { + this.version = value; + } + + public String getType() { + return type; + } + + public void setType(String value) { + this.type = value; + } + + public String getCambriaPartition() { + return cambriaPartition; + } + + public void setCambriaPartition(String value) { + this.cambriaPartition = value; + } + + public String getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(String value) { + this.correlationId = value; + } + + public String getRpcName() { + return rpcName; + } + + public void setRpcName(String value) { + this.rpcName = value; + } + + public LcmRestResponse getBody() { + return body; + } + + public void setBody(LcmRestResponse value) { + this.body = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java new file mode 100644 index 0000000000..36527ec887 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"mode", "force", "ttl"}) +public class LcmFlags { + + @JsonProperty("mode") + private String mode; + + @JsonProperty("force") + private String force; + + @JsonProperty("ttl") + private int ttl; + + public String getMode() { + return mode; + } + + public void setMode(String value) { + this.mode = value; + } + + public String getForce() { + return force; + } + + public void setForce(String value) { + this.force = value; + } + + public Integer getTtl() { + return ttl; + } + + public void setTtl(Integer value) { + this.ttl = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmInput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmInput.java new file mode 100644 index 0000000000..6634430bed --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmInput.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"commonHeader", "action", "actionIdentifiers", "payload"}) +public class LcmInput { + + @JsonProperty(value = "common-header", required = true) + private LcmCommonHeader commonHeader; + + @JsonProperty(value = "action", required = true) + private String action; + + @JsonProperty(value = "action-identifiers", required = true) + private LcmActionIdentifiers actionIdentifiers; + + @JsonProperty(value = "payload") + private String payload; + + public LcmCommonHeader getCommonHeader() { + return commonHeader; + } + + public void setCommonHeader(LcmCommonHeader value) { + this.commonHeader = value; + } + + public String getAction() { + return action; + } + + public void setAction(String value) { + this.action = value; + } + + public LcmActionIdentifiers getActionIdentifiers() { + return actionIdentifiers; + } + + public void setActionIdentifiers(LcmActionIdentifiers value) { + this.actionIdentifiers = value; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String value) { + this.payload = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmOutput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmOutput.java new file mode 100644 index 0000000000..3741786671 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmOutput.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"commonHeader", "status", "payload"}) +public class LcmOutput { + + @JsonProperty(value = "common-header", required = true) + private LcmCommonHeader commonHeader; + + @JsonProperty(value = "status", required = true) + private LcmStatus status; + + @JsonProperty(value = "payload") + private String payload; + + public LcmCommonHeader getCommonHeader() { + return commonHeader; + } + + public void setCommonHeader(LcmCommonHeader value) { + this.commonHeader = value; + } + + public LcmStatus getStatus() { + return status; + } + + public void setStatus(LcmStatus value) { + this.status = value; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String value) { + this.payload = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequest.java new file mode 100644 index 0000000000..146eb8a4f6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"input"}) +public class LcmRestRequest { + + @JsonProperty(value = "input", required = true) + private LcmInput input; + + public LcmInput getInput() { + return input; + } + + public void setInput(LcmInput value) { + this.input = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponse.java new file mode 100644 index 0000000000..6920f95ce2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponse.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"output"}) +public class LcmRestResponse { + + @JsonProperty(value = "output", required = true) + private LcmOutput output; + + public LcmOutput getOutput() { + return output; + } + + public void setOutput(LcmOutput value) { + this.output = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java new file mode 100644 index 0000000000..8a2a142792 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"code", "message"}) +public class LcmStatus { + + @JsonProperty(value = "code", required = true) + private int code; + + @JsonProperty(value = "message", required = true) + private String message; + + public int getCode() { + return code; + } + + public void setCode(int value) { + this.code = value; + } + + public String getMessage() { + return message; + } + + public void setMessage(String value) { + this.message = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.onap.so.client.RestProperties index 27da189456..147bc2ee95 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.onap.so.client.RestProperties +++ b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.onap.so.client.RestProperties @@ -1,3 +1,4 @@ org.onap.so.client.restproperties.AAIPropertiesImpl org.onap.so.client.restproperties.CDSPropertiesImpl -org.onap.so.client.restproperties.PolicyRestPropertiesImpl
\ No newline at end of file +org.onap.so.client.restproperties.PolicyRestPropertiesImpl +org.onap.so.client.restproperties.SDNCLcmPropertiesImpl diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java index 24962a0c14..998976589c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java @@ -55,7 +55,7 @@ public class GeneratePayloadForCdsTest { private static final String VF_SCOPE = "vfModule"; private static final String ASSIGN_ACTION = "configAssign"; private static final String DEPLOY_ACTION = "configDeploy"; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; private static final String MSO_REQUEST_ID = "1234"; private static final String BUILDING_BLOCK = "buildingBlock"; private static final String PUBLIC_NET_ID = "public-net-id"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java index e5cbc9a369..88559280b6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java @@ -40,8 +40,8 @@ public class PnfCDSRequestProviderTest { @InjectMocks private PnfCDSRequestProvider pnfCDSRequestProvider; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28"; private static final String TEST_SERVICE_INSTANCE_ID = "test_service_id"; private static final String TEST_PROCESS_KEY = "processKey1"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java new file mode 100644 index 0000000000..5483792a84 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +import java.util.List; +import org.apache.http.HttpStatus; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import org.onap.so.BaseTest; +import org.onap.so.client.restproperties.SDNCLcmPropertiesImpl; +import org.onap.so.client.sdnc.lcm.beans.*; + +public class SDNCLcmDmaapClientTest extends BaseTest { + + protected SDNCLcmMessageBuilderTest sdncLcmMessageBuilderTest = new SDNCLcmMessageBuilderTest(); + + protected static final String DMAAP_HOST_PROP = SDNCLcmPropertiesImpl.DMAAP_HOST; + protected static final String DMAAP_WRITE_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_WRITE_TOPIC; + protected static final String DMAAP_READ_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_READ_TOPIC; + protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.DMAAP_PARTITION; + + protected String testWriteTopic = "TEST-WRITE-TOPIC"; + protected String testReadTopic = "TEST-READ-TOPIC"; + protected String testPartition = "TESTMSO"; + protected final String defaultConsumerName = "consumer1"; + + private void clearSystemProperty() { + System.clearProperty(DMAAP_HOST_PROP); + System.clearProperty(DMAAP_WRITE_TOPIC_PROP); + System.clearProperty(DMAAP_READ_TOPIC_PROP); + System.clearProperty(DMAAP_PARTITION_PROP); + } + + public SDNCLcmDmaapClient buildSDNCLcmDmaapClient() { + String testHost = "http://localhost:" + wireMockPort; + + System.setProperty(DMAAP_HOST_PROP, testHost); + System.setProperty(DMAAP_WRITE_TOPIC_PROP, testWriteTopic); + System.setProperty(DMAAP_READ_TOPIC_PROP, testReadTopic); + System.setProperty(DMAAP_PARTITION_PROP, testPartition); + + SDNCLcmProperties sdncLcmProperties = new SDNCLcmPropertiesImpl(); + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(sdncLcmProperties); + + try { + return sdncLcmClientBuilder.newSDNCLcmDmaapClient(); + } catch (Exception e) { + clearSystemProperty(); + fail("Create SDNCLcmDmaapClient error: " + e.toString()); + return null; + } + } + + @Test + public final void testSDNCLcmDmaapClientSendRequest() { + SDNCLcmDmaapClient sdncLcmDmaapClient = buildSDNCLcmDmaapClient(); + + assertNotEquals(null, sdncLcmDmaapClient); + + String testDmaapWritePath = "/events/" + testWriteTopic; + String expectedWriteResponse = "{\"serverTimeMs\":2,\"count\":1}"; + wireMockServer.stubFor(post(urlPathEqualTo(testDmaapWritePath)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(expectedWriteResponse) + .withStatus(HttpStatus.SC_OK))); + + LcmInput lcmInput = sdncLcmMessageBuilderTest.buildLcmInputForPnf(); + LcmDmaapRequest lcmDmaapRequest = + SDNCLcmMessageBuilder.buildLcmDmaapRequest(sdncLcmMessageBuilderTest.getOperation(), lcmInput); + + try { + sdncLcmDmaapClient.sendRequest(lcmDmaapRequest); + } catch (Exception e) { + clearSystemProperty(); + fail("SDNCLcmDmaapClient sends request error: " + e.toString()); + return; + } + + String testDmaapReadPath = "/events/" + testReadTopic + "/" + testPartition + "/" + defaultConsumerName; + + String expectedLcmDmaapResponse = LcmDmaapResponseTest.getExpectedLcmDmaapResponse(); + String expectedResponseListItem; + try { + expectedResponseListItem = sdncLcmMessageBuilderTest.convertToSting(expectedLcmDmaapResponse); + } catch (JsonProcessingException e) { + clearSystemProperty(); + fail("Convert LcmDmaapResponse String to List item error: " + e.toString()); + return; + } + String expectedReadResponse = "[" + expectedResponseListItem + "]"; + wireMockServer.stubFor(get(urlPathEqualTo(testDmaapReadPath)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(expectedReadResponse) + .withStatus(HttpStatus.SC_OK))); + + List<LcmDmaapResponse> LcmDmaapResponseList = sdncLcmDmaapClient.getResponse(); + + clearSystemProperty(); + + if (LcmDmaapResponseList.size() < 1) { + clearSystemProperty(); + fail("Can not get LcmDmaapResponse list"); + return; + } + + LcmOutput lcmOutput = LcmDmaapResponseList.get(0).getBody().getOutput(); + + String expectedLcmOutput = LcmOutputTest.getExpectedLcmOutput(); + try { + String lcmOutputString = sdncLcmMessageBuilderTest.convertToSting(lcmOutput); + assertEquals(expectedLcmOutput, lcmOutputString); + } catch (Exception e) { + fail("Convert LcmOutput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilderTest.java new file mode 100644 index 0000000000..d930c6728c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilderTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import org.onap.so.client.sdnc.lcm.beans.LcmBeanTest; +import org.onap.so.client.sdnc.lcm.beans.LcmInput; +import org.onap.so.client.sdnc.lcm.beans.LcmInputTest; + +public class SDNCLcmMessageBuilderTest extends LcmBeanTest { + + public LcmInput buildLcmInputForPnf() { + LcmInput lcmInput = + SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, action, inputPayload); + + lcmInput.getCommonHeader().setTimestamp(timestamp); + + return lcmInput; + } + + @Test + public final void testBuildLcmRestRequestForPnf() { + LcmInput lcmInput = buildLcmInputForPnf(); + + String expectedLcmInput = LcmInputTest.getExpectedLcmInput(); + try { + String lcmInputString = convertToSting(lcmInput); + assertEquals(expectedLcmInput, lcmInputString); + } catch (Exception e) { + fail("Convert LcmInput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClientTest.java new file mode 100644 index 0000000000..04cfc6e3c8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClientTest.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm; + +import org.apache.http.HttpStatus; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import org.onap.logging.filter.base.ONAPComponents; +import org.onap.so.BaseTest; +import org.onap.so.client.restproperties.SDNCLcmPropertiesImpl; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.beans.*; + +public class SDNCLcmRestClientTest extends BaseTest { + + protected SDNCLcmMessageBuilderTest sdncLcmMessageBuilderTest = new SDNCLcmMessageBuilderTest(); + + protected static final String SDNC_HOST_PROP = SDNCLcmPropertiesImpl.SDNC_HOST; + protected static final String SDNC_PATH_PROP = SDNCLcmPropertiesImpl.LCM_PATH; + + private void clearSystemProperty() { + System.clearProperty(SDNC_HOST_PROP); + System.clearProperty(SDNC_PATH_PROP); + } + + public SDNCLcmRestClient buildSDNCLcmRestClient() { + String testHost = "http://localhost:" + wireMockPort; + + System.setProperty(SDNC_HOST_PROP, testHost); + System.setProperty(SDNC_PATH_PROP, SDNCConstants.LCM_API_BASE_PATH); + + SDNCLcmProperties sdncLcmProperties = new SDNCLcmPropertiesImpl(); + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(sdncLcmProperties); + + try { + return sdncLcmClientBuilder.newSDNCLcmRestClient(sdncLcmMessageBuilderTest.getOperation()); + } catch (Exception e) { + clearSystemProperty(); + fail("Create SDNCLcmRestClient error: " + e.toString()); + return null; + } + } + + @Test + public final void testSDNCLcmRestClientSendRequest() { + SDNCLcmRestClient sdncLcmRestClient = buildSDNCLcmRestClient(); + + assertNotEquals(null, sdncLcmRestClient); + assertEquals(ONAPComponents.SDNC, sdncLcmRestClient.getTargetEntity()); + + String testLcmApiPath = SDNCConstants.LCM_API_BASE_PATH + sdncLcmMessageBuilderTest.getOperation(); + String expectedLcmRestResponse = LcmRestResponseTest.getExpectedLcmRestResponse(); + wireMockServer.stubFor(post(urlPathEqualTo(testLcmApiPath)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(expectedLcmRestResponse) + .withStatus(HttpStatus.SC_OK))); + + LcmInput lcmInput = sdncLcmMessageBuilderTest.buildLcmInputForPnf(); + LcmOutput lcmOutput = sdncLcmRestClient.sendRequest(lcmInput); + + clearSystemProperty(); + + String expectedLcmOutput = LcmOutputTest.getExpectedLcmOutput(); + try { + String lcmOutputString = sdncLcmMessageBuilderTest.convertToSting(lcmOutput); + assertEquals(expectedLcmOutput, lcmOutputString); + } catch (Exception e) { + fail("Convert LcmOutput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmBeanTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmBeanTest.java new file mode 100644 index 0000000000..5562444a46 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmBeanTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.onap.so.client.sdnc.common.SDNCConstants; + +public class LcmBeanTest { + private static Logger logger = LoggerFactory.getLogger(LcmBeanTest.class); + + protected String requestId = "9f77f437-1515-44bd-a420-0aaf8a3c31a0"; + protected String subRequestId = "c197a4b5-18d9-48a2-ad2d-a3b56858501c"; + protected String timestamp = "2020-02-25T10:20:28.116Z"; + + protected String pnfName = "testpnf"; + protected String action = "TestAction"; + protected String operation = "test-operation"; + + protected String inputPayload = "{\"testPayload\": \"input test\"}"; + protected String outputPayload = "{\"testPayload\": \"output test\"}"; + + public String getOperation() { + return operation; + } + + public LcmFlags buildSDNCFlags() { + LcmFlags lcmFlags = new LcmFlags(); + + lcmFlags.setMode(SDNCConstants.LCM_FLAGS_MODE_NORMAL); + lcmFlags.setForce(SDNCConstants.LCM_FLAGS_FORCE_FALSE); + lcmFlags.setTtl(SDNCConstants.LCM_FLAGS_TTL); + + return lcmFlags; + } + + public LcmCommonHeader buildLcmCommonHeader() { + LcmCommonHeader lcmCommonHeader = new LcmCommonHeader(); + + lcmCommonHeader.setApiVer(SDNCConstants.LCM_API_VER); + lcmCommonHeader.setFlags(buildSDNCFlags()); + lcmCommonHeader.setOriginatorId(SDNCConstants.SYSTEM_NAME); + lcmCommonHeader.setRequestId(requestId); + lcmCommonHeader.setSubRequestId(subRequestId); + lcmCommonHeader.setTimestamp(timestamp); + + return lcmCommonHeader; + } + + public String convertToSting(Object msgObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + + String msgString = mapper.writeValueAsString(msgObject); + logger.debug(msgObject.getClass().getSimpleName() + "\n" + msgString); + + return msgString; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequestTest.java new file mode 100644 index 0000000000..709a557937 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequestTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import org.junit.Test; +import org.onap.so.client.sdnc.common.SDNCConstants; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmDmaapRequestTest extends LcmBeanTest { + private static String expectedLcmDmaapRequest = "{" + "\"version\":\"1.0\"," + "\"type\":\"request\"," + + "\"cambria.partition\":\"MSO\"," + + "\"correlation-id\":\"9f77f437-1515-44bd-a420-0aaf8a3c31a0-c197a4b5-18d9-48a2-ad2d-a3b56858501c\"," + + "\"rpc-name\":\"test-operation\"," + "\"body\":" + LcmRestRequestTest.getExpectedLcmRestRequest() + "}"; + + public LcmDmaapRequest buildLcmDmaapRequest() { + LcmDmaapRequest lcmDmaapRequest = new LcmDmaapRequest(); + + LcmRestRequestTest lcmRestRequestTest = new LcmRestRequestTest(); + LcmRestRequest lcmRestRequest = lcmRestRequestTest.buildLcmRestRequest(); + LcmCommonHeader lcmCommonHeader = lcmRestRequest.getInput().getCommonHeader(); + String correlationId = lcmCommonHeader.getRequestId() + "-" + lcmCommonHeader.getSubRequestId(); + + lcmDmaapRequest.setVersion(SDNCConstants.LCM_DMAAP_MSG_VER); + lcmDmaapRequest.setType(SDNCConstants.LCM_DMAAP_MSG_TYPE_REQUEST); + lcmDmaapRequest.setCambriaPartition(SDNCConstants.SYSTEM_NAME); + lcmDmaapRequest.setCorrelationId(correlationId); + lcmDmaapRequest.setRpcName(operation); + lcmDmaapRequest.setBody(lcmRestRequest); + + return lcmDmaapRequest; + } + + public static String getExpectedLcmDmaapRequest() { + return expectedLcmDmaapRequest; + } + + @Test + public final void testLcmDmaapRequest() { + LcmDmaapRequest lcmDmaapRequest = buildLcmDmaapRequest(); + + try { + String lcmDmaapRequestString = convertToSting(lcmDmaapRequest); + assertEquals(expectedLcmDmaapRequest, lcmDmaapRequestString); + } catch (Exception e) { + fail("Convert LcmDmaapRequest to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponseTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponseTest.java new file mode 100644 index 0000000000..0cdbeebb27 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponseTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import org.junit.Test; +import org.onap.so.client.sdnc.common.SDNCConstants; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmDmaapResponseTest extends LcmBeanTest { + private static String expectedLcmDmaapResponse = "{" + "\"version\":\"1.0\"," + "\"type\":\"response\"," + + "\"cambria.partition\":\"MSO\"," + + "\"correlation-id\":\"9f77f437-1515-44bd-a420-0aaf8a3c31a0-c197a4b5-18d9-48a2-ad2d-a3b56858501c\"," + + "\"rpc-name\":\"test-operation\"," + "\"body\":" + LcmRestResponseTest.getExpectedLcmRestResponse() + "}"; + + public LcmDmaapResponse buildLcmDmaapResponse() { + LcmDmaapResponse lcmDmaapResponse = new LcmDmaapResponse(); + + LcmRestResponseTest lcmRestResponseTest = new LcmRestResponseTest(); + LcmRestResponse lcmRestResponse = lcmRestResponseTest.buildLcmRestResponse(); + LcmCommonHeader lcmCommonHeader = lcmRestResponse.getOutput().getCommonHeader(); + String correlationId = lcmCommonHeader.getRequestId() + "-" + lcmCommonHeader.getSubRequestId(); + + lcmDmaapResponse.setVersion(SDNCConstants.LCM_DMAAP_MSG_VER); + lcmDmaapResponse.setType(SDNCConstants.LCM_DMAAP_MSG_TYPE_RESPONSE); + lcmDmaapResponse.setCambriaPartition(SDNCConstants.SYSTEM_NAME); + lcmDmaapResponse.setCorrelationId(correlationId); + lcmDmaapResponse.setRpcName(operation); + lcmDmaapResponse.setBody(lcmRestResponse); + + return lcmDmaapResponse; + } + + public static String getExpectedLcmDmaapResponse() { + return expectedLcmDmaapResponse; + } + + @Test + public final void testLcmDmaapResponse() { + LcmDmaapResponse lcmDmaapResponse = buildLcmDmaapResponse(); + + try { + String lcmDmaapResponseString = convertToSting(lcmDmaapResponse); + assertEquals(expectedLcmDmaapResponse, lcmDmaapResponseString); + } catch (Exception e) { + fail("Convert LcmDmaapResponse to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmInputTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmInputTest.java new file mode 100644 index 0000000000..b8c34fcbc7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmInputTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmInputTest extends LcmBeanTest { + private static String expectedLcmInput = "{" + "\"common-header\":{" + "\"api-ver\":\"2.00\"," + + "\"flags\":{\"mode\":\"NORMAL\",\"force\":\"FALSE\",\"ttl\":65000}," + "\"originator-id\":\"MSO\"," + + "\"request-id\":\"9f77f437-1515-44bd-a420-0aaf8a3c31a0\"," + + "\"sub-request-id\":\"c197a4b5-18d9-48a2-ad2d-a3b56858501c\"," + + "\"timestamp\":\"2020-02-25T10:20:28.116Z\"" + "}," + "\"action\":\"TestAction\"," + + "\"action-identifiers\":{\"pnf-name\":\"testpnf\"}," + + "\"payload\":\"{\\\"testPayload\\\": \\\"input test\\\"}\"}"; + + public LcmInput buildLcmInput() { + LcmInput lcmInput = new LcmInput(); + + LcmCommonHeader lcmCommonHeader = buildLcmCommonHeader(); + + LcmActionIdentifiers lcmActionIdentifiers = new LcmActionIdentifiers(); + lcmActionIdentifiers.setPnfName(pnfName); + + lcmInput.setCommonHeader(lcmCommonHeader); + lcmInput.setAction(action); + lcmInput.setActionIdentifiers(lcmActionIdentifiers); + lcmInput.setPayload(inputPayload); + + return lcmInput; + } + + public static String getExpectedLcmInput() { + return expectedLcmInput; + } + + @Test + public final void testLcmInput() { + LcmInput lcmInput = buildLcmInput(); + + try { + String lcmInputString = convertToSting(lcmInput); + assertEquals(expectedLcmInput, lcmInputString); + } catch (Exception e) { + fail("Convert LcmInput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmOutputTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmOutputTest.java new file mode 100644 index 0000000000..1530be38a7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmOutputTest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import org.onap.so.client.sdnc.common.SDNCConstants; + +public class LcmOutputTest extends LcmBeanTest { + private static String expectedLcmOutput = "{" + "\"common-header\":{" + "\"api-ver\":\"2.00\"," + + "\"originator-id\":\"MSO\"," + "\"request-id\":\"9f77f437-1515-44bd-a420-0aaf8a3c31a0\"," + + "\"sub-request-id\":\"c197a4b5-18d9-48a2-ad2d-a3b56858501c\"" + "}," + + "\"status\":{\"code\":400,\"message\":\"Test output message\"}," + + "\"payload\":\"{\\\"testPayload\\\": \\\"output test\\\"}\"}"; + + @Override + public LcmCommonHeader buildLcmCommonHeader() { + LcmCommonHeader lcmCommonHeader = new LcmCommonHeader(); + + lcmCommonHeader.setApiVer(SDNCConstants.LCM_API_VER); + lcmCommonHeader.setOriginatorId(SDNCConstants.SYSTEM_NAME); + lcmCommonHeader.setRequestId(requestId); + lcmCommonHeader.setSubRequestId(subRequestId); + + return lcmCommonHeader; + } + + public LcmStatus buildLcmStatus() { + LcmStatus lcmStatus = new LcmStatus(); + + lcmStatus.setCode(400); + lcmStatus.setMessage("Test output message"); + + return lcmStatus; + } + + public LcmOutput buildLcmOutput() { + LcmOutput lcmOutput = new LcmOutput(); + + LcmCommonHeader lcmCommonHeader = buildLcmCommonHeader(); + LcmStatus lcmStatus = buildLcmStatus(); + + lcmOutput.setCommonHeader(lcmCommonHeader); + lcmOutput.setStatus(lcmStatus); + lcmOutput.setPayload(outputPayload); + + return lcmOutput; + } + + public static String getExpectedLcmOutput() { + return expectedLcmOutput; + } + + @Test + public final void testLcmOutput() { + LcmOutput lcmOutput = buildLcmOutput(); + + try { + String lcmOutputString = convertToSting(lcmOutput); + assertEquals(expectedLcmOutput, lcmOutputString); + } catch (Exception e) { + fail("Convert LcmOutput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequestTest.java new file mode 100644 index 0000000000..c078326c82 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequestTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmRestRequestTest extends LcmBeanTest { + private static String expectedLcmRestRequest = "{" + "\"input\":" + LcmInputTest.getExpectedLcmInput() + "}"; + + public LcmRestRequest buildLcmRestRequest() { + LcmRestRequest lcmRestRequest = new LcmRestRequest(); + + LcmInputTest lcmInputTest = new LcmInputTest(); + lcmRestRequest.setInput(lcmInputTest.buildLcmInput()); + + return lcmRestRequest; + } + + public static String getExpectedLcmRestRequest() { + return expectedLcmRestRequest; + } + + @Test + public final void testLcmRestRequest() { + LcmRestRequest lcmRestRequest = buildLcmRestRequest(); + + try { + String lcmRestRequestString = convertToSting(lcmRestRequest); + assertEquals(expectedLcmRestRequest, lcmRestRequestString); + } catch (Exception e) { + fail("Convert LcmRestRequest to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponseTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponseTest.java new file mode 100644 index 0000000000..5867acb421 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponseTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.sdnc.lcm.beans; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmRestResponseTest extends LcmBeanTest { + private static String expectedLcmRestResponse = "{" + "\"output\":" + LcmOutputTest.getExpectedLcmOutput() + "}"; + + public LcmRestResponse buildLcmRestResponse() { + LcmRestResponse lcmRestResponse = new LcmRestResponse(); + + LcmOutputTest lcmOutputTest = new LcmOutputTest(); + lcmRestResponse.setOutput(lcmOutputTest.buildLcmOutput()); + + return lcmRestResponse; + } + + public static String getExpectedLcmRestResponse() { + return expectedLcmRestResponse; + } + + @Test + public final void testLcmRestResponse() { + LcmRestResponse lcmRestResponse = buildLcmRestResponse(); + + try { + String lcmRestResponseString = convertToSting(lcmRestResponse); + assertEquals(expectedLcmRestResponse, lcmRestResponseString); + } catch (Exception e) { + fail("Convert LcmRestResponse to String error: " + e.toString()); + } + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index f9db93e3f7..80fd3eede4 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -58,6 +58,12 @@ public class PnfManagementTestImpl implements PnfManagement { serviceAndPnfRelationMap.put(serviceInstanceId, pnfName); } + @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) { + created.put(pnfCorrelationId, entry); + } + + public Map<String, Pnf> getCreated() { return created; } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn index 11d77bf97a..88e5eadef2 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn @@ -12,7 +12,7 @@ <bpmn:callActivity id="CallActivity_1gfzi2g" name="Abstract CDS (CDS Call) " calledElement="AbstractCDSProcessingBB"> <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> <camunda:in source="executionObject" target="executionObject" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_05qembo</bpmn:incoming> @@ -34,7 +34,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0cvsnuu" sourceRef="CallActivity_1gfzi2g" targetRef="ExclusiveGateway_13q340y" /> <bpmn:sequenceFlow id="SequenceFlow_07tqu82" name="success" sourceRef="ExclusiveGateway_13q340y" targetRef="Task_1hs1mn0"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("CDSStatus").equals("Success")}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("ControllerStatus").equals("Success")}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="EndEvent_0mnaj50"> <bpmn:incoming>SequenceFlow_15gxql1</bpmn:incoming> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn index 92ac5f9f5b..3993eca467 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn @@ -18,7 +18,7 @@ <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="executionObject" target="executionObject" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0kruy8t</bpmn:incoming> <bpmn:outgoing>SequenceFlow_03xbj4e</bpmn:outgoing> @@ -39,7 +39,7 @@ <bpmn:outgoing>SequenceFlow_0o50k2d</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1tb7fs1" name="success" sourceRef="ExclusiveGateway_0duh80v" targetRef="UpdateAAIConfigured"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0o50k2d" sourceRef="ExclusiveGateway_0duh80v" targetRef="EndEvent_0wwnq4u" /> <bpmn:endEvent id="EndEvent_0wwnq4u"> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn index 32d3bce469..279fdc0983 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn @@ -13,7 +13,7 @@ <bpmn:callActivity id="CallActivity_1gfzi2g" name="Abstract CDS (CDS Call) " calledElement="AbstractCDSProcessingBB"> <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> <camunda:in source="executionObject" target="executionObject" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_05qembo</bpmn:incoming> @@ -35,7 +35,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0cvsnuu" sourceRef="CallActivity_1gfzi2g" targetRef="ExclusiveGateway_13q340y" /> <bpmn:sequenceFlow id="SequenceFlow_07tqu82" name="success" sourceRef="ExclusiveGateway_13q340y" targetRef="Task_1hs1mn0"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="EndEvent_0mnaj50"> <bpmn:incoming>SequenceFlow_15gxql1</bpmn:incoming> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java new file mode 100644 index 0000000000..4482d2a327 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java @@ -0,0 +1,165 @@ +/*- + * ============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.pnf.delegate; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; + +/** + * This implementation of {@link JavaDelegate} is used to populate the execution object for pnf software upgrade + */ +@Component +public class NfSoftwareUpgradeDispatcher implements JavaDelegate { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; + private static final String BPMN_REQUEST = "bpmnRequest"; + private static final String RESOURCE_CUSTOMIZATION_UUID_PARAM = "resource_customization_uuid"; + private static final String PNF_NAME = "pnfName"; + + // ERROR CODE for variable not found in the delegation Context + private static final int ERROR_CODE = 601; + + @Autowired + private PnfManagement pnfManagement; + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private ObjectMapper mapper; + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); + + final String serviceInstanceName = bpmnRequestDetails.getRequestInfo().getInstanceName(); + final String pnfName = bpmnRequestDetails.getRequestParameters().getUserParamValue(PNF_NAME); + final String serviceModelUuid = bpmnRequestDetails.getModelInfo().getModelUuid(); + final List<Map<String, Object>> userParams = bpmnRequestDetails.getRequestParameters().getUserParams(); + final Pnf pnf = getPnfByPnfName(delegateExecution, pnfName); + final List<PnfResourceCustomization> pnfCustomizations = + getPnfResourceCustomizations(delegateExecution, serviceModelUuid); + final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + + populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName, + pnfName, serviceModelUuid, userParams); + + logger.trace("Completed preProcessRequest PnfSoftwareUpgradeServiceRequest Request "); + } + + private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException { + RequestDetails bpmnRequestDetails = mapper.readValue( + JsonUtils.getJsonValue(String.valueOf(delegateExecution.getVariable(BPMN_REQUEST)), "requestDetails"), + RequestDetails.class); + + throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams"); + + return bpmnRequestDetails; + } + + private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails, + PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName, + String serviceModelUuid, List<Map<String, Object>> userParams) { + + delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo()); + delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName); + delegateExecution.setVariable(PNF_CORRELATION_ID, pnfName); + delegateExecution.setVariable(MODEL_UUID, serviceModelUuid); + delegateExecution.setVariable(PNF_UUID, pnf.getPnfId()); + delegateExecution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); + delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(RESOURCE_CUSTOMIZATION_UUID_PARAM, + pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName()); + delegateExecution.setVariable(PRC_CONTROLLER_ACTOR, pnfResourceCustomization.getControllerActor()); + + for (Map<String, Object> param : userParams) { + if (param.containsKey("name") && param.containsKey("value")) { + delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString()); + } + } + } + + private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) { + Optional<Pnf> pnfOptional = null; + try { + pnfOptional = pnfManagement.getEntryFor(pnfName); + } catch (IOException e) { + logger.warn(e.getMessage(), e); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to fetch from AAI" + e.getMessage()); + } + if (pnfOptional == null || !pnfOptional.isPresent()) { + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "AAI entry for PNF: " + pnfName + " does not exist"); + } + return pnfOptional.get(); + } + + private List<PnfResourceCustomization> getPnfResourceCustomizations(DelegateExecution delegateExecution, + String serviceModelUuid) { + List<PnfResourceCustomization> pnfCustomizations = + catalogDbClient.getPnfResourceCustomizationByModelUuid(serviceModelUuid); + + if (pnfCustomizations == null || pnfCustomizations.isEmpty()) { + logger.warn("Unable to find the PNF resource customizations of model service UUID: {}", serviceModelUuid); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find the PNF resource customizations of model service UUID: " + serviceModelUuid); + } + return pnfCustomizations; + } + + private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) { + if (obj == null) { + logger.warn("Unable to find the parameter: {} in the execution context", param); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find parameter " + param); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java new file mode 100644 index 0000000000..f85be8aab7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java @@ -0,0 +1,65 @@ +/*- + * ============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.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + + +@Component +public class UpdatePnfEntryInAai implements JavaDelegate { + + private final Logger logger = LoggerFactory.getLogger(UpdatePnfEntryInAai.class); + + @Autowired + private PnfManagement pnfManagement; + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Override + public void execute(DelegateExecution execution) throws Exception { + String pnfCorrelationId = String.valueOf(execution.getVariable(PNF_CORRELATION_ID)); + Optional<Pnf> pnfAaiEntry = pnfManagement.getEntryFor(pnfCorrelationId); + + if (!pnfAaiEntry.isPresent()) { + exceptionUtil.buildAndThrowWorkflowException(execution, 404, + "AAI entry for PNF: " + PNF_CORRELATION_ID + " does not exist"); + } + + Pnf pnf = pnfAaiEntry.get(); + String pnfSoftwareVersion = String.valueOf(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION)); + pnf.setSwVersion(pnfSoftwareVersion); + + pnfManagement.updateEntry(pnfCorrelationId, pnf); + logger.debug("AAI entry is updated for pnf correlation id: {}, pnf uuid: {} with swVersion: {}", + pnf.getPnfName(), pnfCorrelationId, pnfSoftwareVersion); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java index 9e720fe0a4..46937d0d8c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java @@ -30,5 +30,7 @@ public interface PnfManagement { void createEntry(String pnfCorrelationId, Pnf entry) throws IOException; + void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException; + void createRelation(String serviceInstanceId, String pnfName) throws IOException; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java index b1af8b1e0b..e6df8070a3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java @@ -44,6 +44,11 @@ public class PnfManagementImpl implements PnfManagement { restClient.createPnf(pnfCorrelationId, entry); } + public void updateEntry(String pnfCorrelationId, Pnf entry) { + AAIRestClientImpl restClient = new AAIRestClientImpl(); + restClient.updatePnf(pnfCorrelationId, entry); + } + @Override public void createRelation(String serviceInstanceId, String pnfName) { AAIResourceUri serviceInstanceURI = diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy new file mode 100644 index 0000000000..f066f9e878 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy @@ -0,0 +1,344 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertEquals +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class CheckServiceProcessStatusTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("CheckServiceProcessStatus") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + + @Test + void testPreProcessRequest () { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture()) + } + + + @Test + void testPreCheckServiceStatusReq() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.preCheckServiceStatusReq(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("getOperationStatus"), captor.capture()) + String res = captor.getValue() + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:getServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + </ns:getServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + + + @Test + void testHandlerServiceStatusRespSuccess() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("finished")) + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("finished") + expect.add("operationContent") + expect.add("communication service create operation finished success") + expect.add("orchestrationStatus") + expect.add("deactivated") + expect.add("isAllFinished") + expect.add("true") + + assertEquals(expect, resultSuccess) + } + + + @Test + void testHandlerServiceStatusRespError() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("error")) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("error") + expect.add("operationContent") + expect.add("communication service create operation finished with error") + expect.add("orchestrationStatus") + expect.add("error") + expect.add("isAllFinished") + expect.add("true") + + assertEquals(expect, resultSuccess) + } + + + @Test + void testHandlerServiceStatusRespProcessingNo() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("processing")) + when(mockExecution.getVariable("progress")).thenReturn(50) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("isNeedUpdateDB") + expect.add("false") + expect.add("isAllFinished") + expect.add("false") + + assertEquals(expect as String, resultSuccess as String) + } + + + @Test + void testHandlerServiceStatusRespProcessingYes() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("processing")) + when(mockExecution.getVariable("progress")).thenReturn(60) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("progress") + expect.add("50") + expect.add("isNeedUpdateDB") + expect.add("true") + expect.add("isAllFinished") + expect.add("false") + + assertEquals(expect as String, resultSuccess as String) + } + + + @Test + void testTimeWaitDelayNo() { + mockData() + when(mockExecution.getVariable("startTime")).thenReturn(System.currentTimeMillis()) + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.timeWaitDelay(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("isTimeOut"), captor.capture()) + def res = captor.getValue() + + assertEquals("NO", res) + } + + + @Test + void testTimeWaitDelayYes() { + mockData() + when(mockExecution.getVariable("startTime")).thenReturn(1000000) + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.timeWaitDelay(mockExecution) + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def res = captor.getAllValues() + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("error") + expect.add("operationContent") + expect.add("communication service create operation finished with timeout") + expect.add("orchestrationStatus") + expect.add("error") + expect.add("isTimeOut") + expect.add("YES") + + assertEquals(expect, res) + } + + + @Test + void testPreUpdateOperationProgress() { + mockData() + when(mockExecution.getVariable("progress")).thenReturn(50) + when(mockExecution.getVariable("initProgress")).thenReturn(20) + when(mockExecution.getVariable("endProgress")).thenReturn(90) + when(mockExecution.getVariable("operationType")).thenReturn("CREATE") + when(mockExecution.getVariable("processServiceType")).thenReturn("communication service") + when(mockExecution.getVariable("parentServiceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("parentOperationId")).thenReturn("54321") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.preUpdateOperationProgress(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("55", + "communication service CREATE operation processing 55") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + + + } + + + private static String getExpectPayload(String progress, String operationContent) { + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:updateServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>CREATE</operationType> + <userId>11111</userId> + <result>processing</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:updateServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + + private static String getDBResponse(String result) { + String response = + """<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <ns2:getServiceOperationStatusResponse xmlns:ns2="http://org.onap.so/requestsdb"> + <return><operation>CREATE</operation> + <operationContent>Prepare service creation</operationContent> + <operationId>077995e3-eb32-44ae-b35d-491fc6983a44</operationId> + <progress>50</progress> + <reason></reason> + <result>${result}</result> + <serviceId>3324f117-696d-4518-b8b5-b01fcc127a03</serviceId> + <userId>5GCustomer</userId> + </return></ns2:getServiceOperationStatusResponse> + </soap:Body> + </soap:Envelope> + """ + return response + } + + + private mockData() { + when(mockExecution.getVariable("processServiceType")).thenReturn("communication service") + when(mockExecution.getVariable("operationType")).thenReturn("create") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java new file mode 100644 index 0000000000..3c568ffc83 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java @@ -0,0 +1,182 @@ +/*- + * ============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.pnf.delegate; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.RequestParameters; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.io.IOException; +import java.util.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + + +@RunWith(SpringJUnit4ClassRunner.class) +public class NfSoftwareUpgradeDispatcherTest { + + private static final String TEST_PROCESS_KEY = "processKey1"; + private static final String PROCESS_KEY = "testProcessKey"; + private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource"; + private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap"; + private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1"; + private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144"; + private static final String TEST_PNF_CORRELATION_ID = "PNFDemo"; + private static final String TEST_PNF_UUID = "FakeID"; + private static final String TEST_PRC_CONTROLLER_ACTOR = "cds"; + private static final String TEST_TARGET_SOFTWARE_VERSION = "demo-sw-ver2.0.0"; + + private static final String TEST_BPMN_REQUEST = "{\"requestDetails\":{" + "\"requestInfo\":{" + + "\"source\":\"VID\"," + "\"suppressRollback\":false," + "\"requestorId\":\"demo\"," + + "\"productFamilyId\":\"SWUPid\"}," + "\"modelInfo\":{" + + "\"modelType\":\"service\",\"modelInvariantUuid\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\"," + + "\"modelInvariantId\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\"," + + "\"modelUuid\":\"42daaac6-5017-4e1e-96c8-6a27dfbe1421\",\"modelName\":\"PNF_int_service_2\"," + + "\"modelVersion\":\"1.0\"},\"requestParameters\":{\"userParams\":[{\"name\":\"aic_zone\"," + + "\"value\":\"nova\"},{\"name\":\"pnfId\",\"value\":\"PNFDemo\"},{\"name\":\"targetSoftwareVersion\",\"value\":\"demo-sw-ver2.0.0\"}]," + + "\"subscriptionServiceType\":\"SWUP\",\"aLaCarte\":false,\"pnfCorrelationId\":\"PNFDemo\"}," + + "\"cloudConfiguration\":{\"lcpCloudRegionId\":\"regionOne\",\"tenantId\":\"09a63533072f4a579d5c99c3b8fe94c6\"}," + + "\"subscriberInfo\":{\"globalSubscriberId\":\"ADemoCustomerInEric\"},\"project\":{\"projectName\":\"Project-Demonstration\"}," + + "\"owningEntity\":{\"owningEntityId\":\"5eae949c-1c50-4780-b8b5-7cbeb08856b4\",\"owningEntityName\":\"OE-Demonstration\"}}}"; + /** + * Testing model UUID, should be the same as specified in the TEST_SERVICE_MODEL_INFO. + */ + private static final String TEST_MODEL_UUID = "42daaac6-5017-4e1e-96c8-6a27dfbe1421"; + + @InjectMocks + private NfSoftwareUpgradeDispatcher nfSoftwareUpgradeDispatcher; + + @Mock + private PnfManagement pnfManagement; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private ObjectMapper mapper; + + private DelegateExecution execution = new DelegateExecutionFake(); + + @Before + public void setUp() throws IOException { + List<PnfResourceCustomization> pnfResourceCustomizations = new ArrayList<>(); + pnfResourceCustomizations.add(buildPnfResourceCustomization()); + given(catalogDbClient.getPnfResourceCustomizationByModelUuid(TEST_MODEL_UUID)) + .willReturn(pnfResourceCustomizations); + execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY); + execution.setVariable("bpmnRequest", TEST_BPMN_REQUEST); + mockMapper(); + mockAai(); + + } + + + @Test + public void testExecution_validCatalogDb_skipVariableSet() { + try { + nfSoftwareUpgradeDispatcher.execute(execution); + assertThat(execution.getVariable(MODEL_UUID)).isEqualTo(TEST_MODEL_UUID); + assertThat(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION)).isEqualTo(TEST_TARGET_SOFTWARE_VERSION); + assertThat(execution.getVariable(PRC_BLUEPRINT_NAME)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME); + assertThat(execution.getVariable(PRC_BLUEPRINT_VERSION)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION); + assertThat(execution.getVariable(PRC_CUSTOMIZATION_UUID)).isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID); + assertThat(execution.getVariable(PRC_INSTANCE_NAME)).isEqualTo(TEST_PNF_RESOURCE_INSTANCE_NAME); + assertThat(execution.getVariable(PNF_CORRELATION_ID)).isEqualTo(TEST_PNF_CORRELATION_ID); + assertThat(execution.getVariable(PNF_UUID)).isEqualTo(TEST_PNF_UUID); + assertThat(execution.getVariable(PRC_CONTROLLER_ACTOR)).isEqualTo(TEST_PRC_CONTROLLER_ACTOR); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception thrown" + e.getMessage()); + } + } + + private void mockAai() throws IOException { + Pnf pnf = new Pnf(); + pnf.setPnfId(TEST_PNF_UUID); + when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.of(pnf)); + } + + private PnfResourceCustomization buildPnfResourceCustomization() { + PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); + pnfResourceCustomization.setSkipPostInstConf(true); + pnfResourceCustomization.setBlueprintName(TEST_PNF_RESOURCE_BLUEPRINT_NAME); + pnfResourceCustomization.setBlueprintVersion(TEST_PNF_RESOURCE_BLUEPRINT_VERSION); + pnfResourceCustomization.setModelInstanceName(TEST_PNF_RESOURCE_INSTANCE_NAME); + pnfResourceCustomization.setModelCustomizationUUID(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID); + pnfResourceCustomization.setControllerActor(TEST_PRC_CONTROLLER_ACTOR); + return pnfResourceCustomization; + } + + private void mockMapper() throws IOException { + RequestDetails bpmnRequestDetails = new RequestDetails(); + + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("demo"); + bpmnRequestDetails.setRequestInfo(requestInfo); + + RequestParameters requestParameters = new RequestParameters(); + List<Map<String, Object>> userParams = new ArrayList<>(); + Map<String, Object> map = new HashMap<>(); + map.put("name", "targetSoftwareVersion"); + map.put("value", TEST_TARGET_SOFTWARE_VERSION); + userParams.add(map); + map = new HashMap<>(); + map.put("name", "pnfName"); + map.put("value", "PNFDemo"); + userParams.add(map); + requestParameters.setUserParams(userParams); + + bpmnRequestDetails.setRequestParameters(requestParameters); + + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantUuid("439b7a2f-9524-4dbf-9eee-f2e05521df3f"); + modelInfo.setModelInvariantId("439b7a2f-9524-4dbf-9eee-f2e05521df3f"); + modelInfo.setModelUuid("42daaac6-5017-4e1e-96c8-6a27dfbe1421"); + modelInfo.setModelName("PNF_int_service_2"); + modelInfo.setModelVersion("1.0"); + + bpmnRequestDetails.setModelInfo(modelInfo); + + + doReturn(bpmnRequestDetails).when(mapper).readValue( + JsonUtils.getJsonValue(String.valueOf(execution.getVariable("bpmnRequest")), "requestDetails"), + RequestDetails.class); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index 8577d9555b..b93902d9f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -50,6 +50,11 @@ public class PnfManagementTestImpl implements PnfManagement { } @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException { + created.put(pnfCorrelationId, entry); + } + + @Override public void createRelation(String serviceInstanceId, String pnfName) {} public Map<String, Pnf> getCreated() { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java index f9b467c650..77377db9d9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java @@ -38,6 +38,11 @@ public class PnfManagementThrowingException implements PnfManagement { } @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException { + throw new IOException(); + } + + @Override public void createRelation(String serviceInstanceId, String pnfName) throws IOException { throw new IOException(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java new file mode 100644 index 0000000000..bddfe5b180 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java @@ -0,0 +1,91 @@ +/*- + * ============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.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.*; +import java.io.IOException; +import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + +@RunWith(SpringJUnit4ClassRunner.class) +public class UpdatePnfEntryInAaiTest { + + @InjectMocks + private UpdatePnfEntryInAai updatePnfEntryInAai; + + @Mock + private PnfManagement pnfManagementTest; + + private DelegateExecution execution; + + + + @Test + public void shouldSetSwVersion() throws Exception { + // given + setupPnf(); + setupExecution(); + + // when + updatePnfEntryInAai.execute(execution); + + // verify + Optional<Pnf> modifiedEntry = pnfManagementTest.getEntryFor("testPnfCorrelationId"); + assertNotNull(modifiedEntry.get()); + assertThat(modifiedEntry.get().getPnfId()).isEqualTo("testtest"); + assertThat(modifiedEntry.get().getPnfName()).isEqualTo("testPnfCorrelationId"); + assertThat(modifiedEntry.get().getSwVersion()).isEqualTo("demo-1.2"); + verify(pnfManagementTest, times(2)).getEntryFor(anyString()); + } + + private void setupPnf() { + try { + Pnf pnf = new Pnf(); + pnf.setSwVersion("1"); + pnf.setPnfId("testtest"); + pnf.setPnfName("testPnfCorrelationId"); + doReturn(Optional.of(pnf)).when(pnfManagementTest).getEntryFor(anyString()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void setupExecution() { + execution = mock(DelegateExecution.class); + given(execution.getVariable(eq(PNF_CORRELATION_ID))).willReturn("testPnfCorrelationId"); + given(execution.getVariable(eq(PNF_UUID))).willReturn("testtest"); + given(execution.getVariable(eq(PRC_TARGET_SOFTWARE_VERSION))).willReturn("demo-1.2"); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn index 693dd922e2..234c744e4a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn @@ -22,7 +22,7 @@ <bpmn:outgoing>SequenceFlow_1w4p9f7</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1owbpsy" name="Success" sourceRef="ExclusiveGateway_0vtv1wi" targetRef="Task_14cwhgk"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:exclusiveGateway id="ExclusiveGateway_01jwwmc" default="SequenceFlow_0d24h26"> <bpmn:incoming>SequenceFlow_02919fh</bpmn:incoming> @@ -30,7 +30,7 @@ <bpmn:outgoing>SequenceFlow_0d24h26</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1n080up" name="Success" sourceRef="ExclusiveGateway_01jwwmc" targetRef="EndEvent_0xky46v"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1w4p9f7" name="Failure" sourceRef="ExclusiveGateway_0vtv1wi" targetRef="EndEvent_16620h9" /> <bpmn:endEvent id="EndEvent_16620h9"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn new file mode 100644 index 0000000000..24ca7104a7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0474hns" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.4"> + <bpmn:process id="PNFSWUPDownload" name="PNFSWUPDownload" isExecutable="true"> + <bpmn:startEvent id="download_StartEvent" name="Start Flow"> + <bpmn:outgoing>SequenceFlow_1fdclh0</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_1mpt2eq" name="NF Download Dispatcher" camunda:delegateExpression="${NfSoftwareUpgradeDispatcher}"> + <bpmn:incoming>SequenceFlow_1fdclh0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_12155q6</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="download_EndEvent" name="End"> + <bpmn:incoming>SequenceFlow_1d2rfyx</bpmn:incoming> + <bpmn:terminateEventDefinition id="TerminateEventDefinition_1kiurmf" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_1ja7grm" default="SequenceFlow_078xmlz"> + <bpmn:incoming>SequenceFlow_0o6b6a8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_078xmlz</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0qznt4u</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1j64ij1"> + <bpmn:incoming>SequenceFlow_078xmlz</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0b3kbjs" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_1rj84ne" default="SequenceFlow_1tfbzn1"> + <bpmn:incoming>SequenceFlow_1ccldpp</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0s6i4o9</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1tfbzn1</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1ubpef4"> + <bpmn:incoming>SequenceFlow_1tfbzn1</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0wevx6s" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_08lusga" default="SequenceFlow_1gawssm"> + <bpmn:incoming>SequenceFlow_1kaikh5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1d2rfyx</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1gawssm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_11hee4g"> + <bpmn:incoming>SequenceFlow_1gawssm</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_12tyzwb" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:serviceTask id="ServiceTask_0yavde3" name="Download" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">downloadNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0s6i4o9</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0o6b6a8</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ServiceTask_1wxo7xz" name="Post check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">postCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0qznt4u</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1kaikh5</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ServiceTask_1nl90ao" name="Pre check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">preCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_12155q6</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ccldpp</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1fdclh0" sourceRef="download_StartEvent" targetRef="ServiceTask_1mpt2eq" /> + <bpmn:sequenceFlow id="SequenceFlow_12155q6" sourceRef="ServiceTask_1mpt2eq" targetRef="ServiceTask_1nl90ao" /> + <bpmn:sequenceFlow id="SequenceFlow_1d2rfyx" name="Success" sourceRef="ExclusiveGateway_08lusga" targetRef="download_EndEvent"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0o6b6a8" sourceRef="ServiceTask_0yavde3" targetRef="ExclusiveGateway_1ja7grm" /> + <bpmn:sequenceFlow id="SequenceFlow_078xmlz" name="Failure" sourceRef="ExclusiveGateway_1ja7grm" targetRef="EndEvent_1j64ij1" /> + <bpmn:sequenceFlow id="SequenceFlow_1ccldpp" sourceRef="ServiceTask_1nl90ao" targetRef="ExclusiveGateway_1rj84ne" /> + <bpmn:sequenceFlow id="SequenceFlow_0s6i4o9" name="Success" sourceRef="ExclusiveGateway_1rj84ne" targetRef="ServiceTask_0yavde3"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1tfbzn1" name="Failure" sourceRef="ExclusiveGateway_1rj84ne" targetRef="EndEvent_1ubpef4" /> + <bpmn:sequenceFlow id="SequenceFlow_1kaikh5" sourceRef="ServiceTask_1wxo7xz" targetRef="ExclusiveGateway_08lusga" /> + <bpmn:sequenceFlow id="SequenceFlow_1gawssm" name="Failure" sourceRef="ExclusiveGateway_08lusga" targetRef="EndEvent_11hee4g" /> + <bpmn:sequenceFlow id="SequenceFlow_0qznt4u" name="Success" sourceRef="ExclusiveGateway_1ja7grm" targetRef="ServiceTask_1wxo7xz"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmn:error id="Error_1q14dnd" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSWUPDownload"> + <bpmndi:BPMNShape id="StartEvent_1k8gssq_di" bpmnElement="download_StartEvent"> + <dc:Bounds x="162" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="157" y="145" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1mpt2eq_di" bpmnElement="ServiceTask_1mpt2eq"> + <dc:Bounds x="280" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1e4dq7w_di" bpmnElement="download_EndEvent"> + <dc:Bounds x="1312" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1321" y="145" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1ja7grm_di" bpmnElement="ExclusiveGateway_1ja7grm" isMarkerVisible="true"> + <dc:Bounds x="895" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1j64ij1_di" bpmnElement="EndEvent_1j64ij1"> + <dc:Bounds x="902" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1rj84ne_di" bpmnElement="ExclusiveGateway_1rj84ne" isMarkerVisible="true"> + <dc:Bounds x="635" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ubpef4_di" bpmnElement="EndEvent_1ubpef4"> + <dc:Bounds x="642" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_08lusga_di" bpmnElement="ExclusiveGateway_08lusga" isMarkerVisible="true"> + <dc:Bounds x="1155" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_11hee4g_di" bpmnElement="EndEvent_11hee4g"> + <dc:Bounds x="1162" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0yavde3_di" bpmnElement="ServiceTask_0yavde3"> + <dc:Bounds x="760" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1wxo7xz_di" bpmnElement="ServiceTask_1wxo7xz"> + <dc:Bounds x="1000" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1nl90ao_di" bpmnElement="ServiceTask_1nl90ao"> + <dc:Bounds x="480" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1fdclh0_di" bpmnElement="SequenceFlow_1fdclh0"> + <di:waypoint x="198" y="120" /> + <di:waypoint x="280" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12155q6_di" bpmnElement="SequenceFlow_12155q6"> + <di:waypoint x="380" y="120" /> + <di:waypoint x="480" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1d2rfyx_di" bpmnElement="SequenceFlow_1d2rfyx"> + <di:waypoint x="1205" y="120" /> + <di:waypoint x="1312" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1214" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0o6b6a8_di" bpmnElement="SequenceFlow_0o6b6a8"> + <di:waypoint x="860" y="120" /> + <di:waypoint x="895" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_078xmlz_di" bpmnElement="SequenceFlow_078xmlz"> + <di:waypoint x="920" y="145" /> + <di:waypoint x="920" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="918" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ccldpp_di" bpmnElement="SequenceFlow_1ccldpp"> + <di:waypoint x="580" y="120" /> + <di:waypoint x="635" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0s6i4o9_di" bpmnElement="SequenceFlow_0s6i4o9"> + <di:waypoint x="685" y="120" /> + <di:waypoint x="760" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="678" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1tfbzn1_di" bpmnElement="SequenceFlow_1tfbzn1"> + <di:waypoint x="660" y="145" /> + <di:waypoint x="660" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="658" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1kaikh5_di" bpmnElement="SequenceFlow_1kaikh5"> + <di:waypoint x="1100" y="120" /> + <di:waypoint x="1155" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1gawssm_di" bpmnElement="SequenceFlow_1gawssm"> + <di:waypoint x="1180" y="145" /> + <di:waypoint x="1180" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1178" y="172" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qznt4u_di" bpmnElement="SequenceFlow_0qznt4u"> + <di:waypoint x="945" y="120" /> + <di:waypoint x="1000" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="951" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn new file mode 100644 index 0000000000..8d59dac8ac --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn @@ -0,0 +1,273 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1yd8m0g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.4"> + <bpmn:process id="PNFSoftwareUpgrade" name="PNFSoftwareUpgrade" isExecutable="true"> + <bpmn:startEvent id="softwareUpgrade_startEvent" name="Start Flow"> + <bpmn:outgoing>SequenceFlow_1ng4b6l</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_042uz7n" name="NF Upgrade Dispatcher" camunda:delegateExpression="${NfSoftwareUpgradeDispatcher}"> + <bpmn:incoming>SequenceFlow_1ng4b6l</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_12ejx4m</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_12ejx4m" sourceRef="ServiceTask_042uz7n" targetRef="ServiceTask_0slpahe" /> + <bpmn:endEvent id="softwareUpgrade_endEvent" name="End"> + <bpmn:incoming>SequenceFlow_1atiydu</bpmn:incoming> + <bpmn:terminateEventDefinition /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1ng4b6l" sourceRef="softwareUpgrade_startEvent" targetRef="ServiceTask_042uz7n" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0v3l3wv" default="SequenceFlow_1lr7vgu"> + <bpmn:incoming>SequenceFlow_0cchgih</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1lr7vgu</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1eljvek</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_0bnbfds"> + <bpmn:incoming>SequenceFlow_1lr7vgu</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1sjbsm2" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_0x6h0ni" default="SequenceFlow_0piri91"> + <bpmn:incoming>SequenceFlow_0j26xlx</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1nsmyr5</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0piri91</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1nsmyr5" name="Success" sourceRef="ExclusiveGateway_0x6h0ni" targetRef="ServiceTask_0x5cje8"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="EndEvent_180lm4y"> + <bpmn:incoming>SequenceFlow_0piri91</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0fm5he7" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0piri91" name="Failure" sourceRef="ExclusiveGateway_0x6h0ni" targetRef="EndEvent_180lm4y" /> + <bpmn:sequenceFlow id="SequenceFlow_1lr7vgu" name="Failure" sourceRef="ExclusiveGateway_0v3l3wv" targetRef="EndEvent_0bnbfds" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0ch3fef" default="SequenceFlow_0dqnb6c"> + <bpmn:incoming>SequenceFlow_015y785</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0dqnb6c</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0eiif6e</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1ms4wdz"> + <bpmn:incoming>SequenceFlow_0dqnb6c</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_15s8fgk" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0dqnb6c" name="Failure" sourceRef="ExclusiveGateway_0ch3fef" targetRef="EndEvent_1ms4wdz" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1ny9b1z" default="SequenceFlow_1p0axph"> + <bpmn:incoming>SequenceFlow_0g3qcd0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1p0axph</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1atiydu</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_0l6n6x5"> + <bpmn:incoming>SequenceFlow_1p0axph</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1l0gsy0" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1p0axph" name="Failure" sourceRef="ExclusiveGateway_1ny9b1z" targetRef="EndEvent_0l6n6x5" /> + <bpmn:sequenceFlow id="SequenceFlow_1eljvek" name="Success" sourceRef="ExclusiveGateway_0v3l3wv" targetRef="ServiceTask_02lxf48"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1atiydu" name="Success" sourceRef="ExclusiveGateway_1ny9b1z" targetRef="softwareUpgrade_endEvent"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0eiif6e" name="Success" sourceRef="ExclusiveGateway_0ch3fef" targetRef="ServiceTask_1jo8vn7"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="ServiceTask_0x5cje8" name="Download" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">downloadNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1nsmyr5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0cchgih</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0cchgih" sourceRef="ServiceTask_0x5cje8" targetRef="ExclusiveGateway_0v3l3wv" /> + <bpmn:serviceTask id="ServiceTask_02lxf48" name="Activate" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">activateNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1eljvek</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_015y785</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_015y785" sourceRef="ServiceTask_02lxf48" targetRef="ExclusiveGateway_0ch3fef" /> + <bpmn:serviceTask id="ServiceTask_0y2uysu" name="Post check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">postCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_084orr1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0g3qcd0</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0g3qcd0" sourceRef="ServiceTask_0y2uysu" targetRef="ExclusiveGateway_1ny9b1z" /> + <bpmn:serviceTask id="ServiceTask_0slpahe" name="Pre check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">preCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_12ejx4m</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0j26xlx</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0j26xlx" sourceRef="ServiceTask_0slpahe" targetRef="ExclusiveGateway_0x6h0ni" /> + <bpmn:serviceTask id="ServiceTask_1jo8vn7" name="Update Pnf in AAI" camunda:delegateExpression="${UpdatePnfEntryInAai}"> + <bpmn:incoming>SequenceFlow_0eiif6e</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_084orr1</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_084orr1" sourceRef="ServiceTask_1jo8vn7" targetRef="ServiceTask_0y2uysu" /> + </bpmn:process> + <bpmn:error id="Error_12cpov5" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0nmskzh" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSoftwareUpgrade"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="softwareUpgrade_startEvent"> + <dc:Bounds x="162" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="157" y="145" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_042uz7n_di" bpmnElement="ServiceTask_042uz7n"> + <dc:Bounds x="280" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_12ejx4m_di" bpmnElement="SequenceFlow_12ejx4m"> + <di:waypoint x="380" y="120" /> + <di:waypoint x="480" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1w3jv30_di" bpmnElement="softwareUpgrade_endEvent"> + <dc:Bounds x="1662" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1671" y="145" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ng4b6l_di" bpmnElement="SequenceFlow_1ng4b6l"> + <di:waypoint x="198" y="120" /> + <di:waypoint x="280" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0v3l3wv_di" bpmnElement="ExclusiveGateway_0v3l3wv" isMarkerVisible="true"> + <dc:Bounds x="895" y="95" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1040" y="65" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0bnbfds_di" bpmnElement="EndEvent_0bnbfds"> + <dc:Bounds x="902" y="252" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1044" y="295" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0x6h0ni_di" bpmnElement="ExclusiveGateway_0x6h0ni" isMarkerVisible="true"> + <dc:Bounds x="635" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1nsmyr5_di" bpmnElement="SequenceFlow_1nsmyr5"> + <di:waypoint x="685" y="120" /> + <di:waypoint x="760" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="678" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_180lm4y_di" bpmnElement="EndEvent_180lm4y"> + <dc:Bounds x="642" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0piri91_di" bpmnElement="SequenceFlow_0piri91"> + <di:waypoint x="660" y="145" /> + <di:waypoint x="660" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="658" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1lr7vgu_di" bpmnElement="SequenceFlow_1lr7vgu"> + <di:waypoint x="920" y="145" /> + <di:waypoint x="920" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="918" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0ch3fef_di" bpmnElement="ExclusiveGateway_0ch3fef" isMarkerVisible="true"> + <dc:Bounds x="1125" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ms4wdz_di" bpmnElement="EndEvent_1ms4wdz"> + <dc:Bounds x="1132" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0dqnb6c_di" bpmnElement="SequenceFlow_0dqnb6c"> + <di:waypoint x="1150" y="145" /> + <di:waypoint x="1150" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1148" y="230" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1ny9b1z_di" bpmnElement="ExclusiveGateway_1ny9b1z" isMarkerVisible="true"> + <dc:Bounds x="1505" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0l6n6x5_di" bpmnElement="EndEvent_0l6n6x5"> + <dc:Bounds x="1512" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1p0axph_di" bpmnElement="SequenceFlow_1p0axph"> + <di:waypoint x="1530" y="145" /> + <di:waypoint x="1530" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1528" y="172" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1eljvek_di" bpmnElement="SequenceFlow_1eljvek"> + <di:waypoint x="945" y="120" /> + <di:waypoint x="1010" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="938" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1atiydu_di" bpmnElement="SequenceFlow_1atiydu"> + <di:waypoint x="1555" y="120" /> + <di:waypoint x="1662" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1564" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0eiif6e_di" bpmnElement="SequenceFlow_0eiif6e"> + <di:waypoint x="1175" y="120" /> + <di:waypoint x="1210" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1169" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0x5cje8_di" bpmnElement="ServiceTask_0x5cje8"> + <dc:Bounds x="760" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0cchgih_di" bpmnElement="SequenceFlow_0cchgih"> + <di:waypoint x="860" y="120" /> + <di:waypoint x="895" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_02lxf48_di" bpmnElement="ServiceTask_02lxf48"> + <dc:Bounds x="1010" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_015y785_di" bpmnElement="SequenceFlow_015y785"> + <di:waypoint x="1110" y="120" /> + <di:waypoint x="1125" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0y2uysu_di" bpmnElement="ServiceTask_0y2uysu"> + <dc:Bounds x="1370" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0g3qcd0_di" bpmnElement="SequenceFlow_0g3qcd0"> + <di:waypoint x="1470" y="120" /> + <di:waypoint x="1505" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0slpahe_di" bpmnElement="ServiceTask_0slpahe"> + <dc:Bounds x="480" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0j26xlx_di" bpmnElement="SequenceFlow_0j26xlx"> + <di:waypoint x="580" y="120" /> + <di:waypoint x="635" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1jo8vn7_di" bpmnElement="ServiceTask_1jo8vn7"> + <dc:Bounds x="1210" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_084orr1_di" bpmnElement="SequenceFlow_084orr1"> + <di:waypoint x="1310" y="120" /> + <di:waypoint x="1370" y="120" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index aea06b5fc9..d426dc3f66 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -20,22 +20,9 @@ package org.onap.so.bpmn.infrastructure.process; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -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 com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; -import java.io.IOException; -import java.util.List; -import java.util.UUID; +import com.google.protobuf.Struct; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -47,7 +34,21 @@ import org.onap.so.client.aai.AAIVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -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 static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** @@ -62,10 +63,10 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { private static final String TEST_PROCESSINSTANCE_KEY = "CreateVcpeResCustService_simplified"; private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); private String testBusinessKey; private String requestObject; private String responseObject; - private String msoRequestId; @Autowired private GrpcNettyServer grpcNettyServer; @@ -76,25 +77,25 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); - variables.put("bpmnRequest", requestObject); + executionVariables.clear(); + + executionVariables.put("bpmnRequest", requestObject); /** * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. */ - variables.put("isAsyncProcess", "true"); + executionVariables.put("isAsyncProcess", "true"); /** * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api * handler and then convert to CamudaInput */ - variables.put("pnfCorrelationId", "PNFDemo"); + executionVariables.put("pnfCorrelationId", "PNFDemo"); /** * Create mso-request-id. */ - msoRequestId = UUID.randomUUID().toString(); - variables.put("mso-request-id", msoRequestId); /** * Create Business key for the process instance @@ -113,8 +114,11 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { mockAai(); mockDmaapForPnf(); + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put("mso-request-id", msoRequestId); + ProcessInstance pi = - runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, variables); + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); int waitCount = 10; while (!isProcessInstanceEnded() && waitCount >= 0) { @@ -129,14 +133,24 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { "callCompleteMsoProcess_CallActivity", "ScriptTask_2", "CreateVCPE_EndEvent"); List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); - assertThat(detailedMessages).hasSize(2); + assertThat(detailedMessages.size() == 2); + int count = 0; try { - checkConfigAssign(detailedMessages.get(0)); - checkConfigDeploy(detailedMessages.get(1)); + for (ExecutionServiceInput eSI : detailedMessages) { + if ("config-assign".equals(eSI.getActionIdentifiers().getActionName())) { + checkConfigAssign(eSI, msoRequestId); + count++; + } + if ("config-deploy".equals(eSI.getActionIdentifiers().getActionName())) { + checkConfigDeploy(eSI, msoRequestId); + count++; + } + } } catch (Exception e) { e.printStackTrace(); fail("ConfigAssign/deploy request exception", e); } + assertThat(count == 2); } private boolean isProcessInstanceEnded() { @@ -144,7 +158,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { .singleResult() == null; } - private void checkConfigAssign(ExecutionServiceInput executionServiceInput) { + private void checkConfigAssign(ExecutionServiceInput executionServiceInput, String msoRequestId) { logger.info("Checking the configAssign request"); ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); @@ -175,7 +189,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { .isEqualTo("68dc9a92-214c-11e7-93ae-92361f002680"); } - private void checkConfigDeploy(ExecutionServiceInput executionServiceInput) { + private void checkConfigDeploy(ExecutionServiceInput executionServiceInput, String msoRequestId) { logger.info("Checking the configDeploy request"); ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java new file mode 100644 index 0000000000..065d2a54a8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java @@ -0,0 +1,230 @@ +/*- + * ============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.process; + +import com.google.protobuf.Struct; +import org.assertj.core.api.Assertions; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.so.client.aai.AAIVersion; +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.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +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; + +/** + * Basic Integration test for PNFSWUPDownloadTest.bpmn workflow. + */ +public class PNFSWUPDownloadTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "PNFSWUPDownload"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); + private final String[] actionNames = new String[3]; + private String responseObject; + private String requestObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + + actionNames[0] = "preCheck"; + actionNames[1] = "downloadNESw"; + actionNames[2] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/PNFSoftwareUpgradeTest.json"); + responseObject = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest.json"); + + executionVariables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("download_StartEvent", "ServiceTask_1mpt2eq", "ServiceTask_1nl90ao", + "ExclusiveGateway_1rj84ne", "ServiceTask_0yavde3", "ExclusiveGateway_1ja7grm", "ServiceTask_1wxo7xz", + "ExclusiveGateway_08lusga", "download_EndEvent"); + + List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 3); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action, msoRequestId); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("PNFSWUPDownload request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action, String msoRequestId) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + */ + Assertions.assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + Assertions.assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + Assertions.assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + Assertions.assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + Assertions.assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + Assertions.assertThat(commonHeader.getRequestId()).isEqualTo(msoRequestId); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + Assertions.assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) + .isEqualTo("demo-sw-ver2.0.0"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java new file mode 100644 index 0000000000..a9bf4352bf --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java @@ -0,0 +1,236 @@ +/*- + * ============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.process; + +import com.google.protobuf.Struct; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.so.client.aai.AAIVersion; +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.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +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; + +/** + * Basic Integration test for PNFSoftwareUpgrade.bpmn workflow. + */ +public class PNFSoftwareUpgradeTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "PNFSoftwareUpgrade"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); + private final String[] actionNames = new String[4]; + private String requestObject; + private String responseObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + actionNames[0] = "preCheck"; + actionNames[1] = "downloadNESw"; + actionNames[2] = "activateNESw"; + actionNames[3] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); + responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); + + executionVariables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("softwareUpgrade_startEvent", "ServiceTask_042uz7n", + "ServiceTask_0slpahe", "ExclusiveGateway_0x6h0ni", "ServiceTask_0x5cje8", "ExclusiveGateway_0v3l3wv", + "ServiceTask_02lxf48", "ExclusiveGateway_0ch3fef", "ServiceTask_0y2uysu", "ExclusiveGateway_1ny9b1z", + "softwareUpgrade_endEvent"); + + List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 4); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("PNFSoftwareUpgrade request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + */ + assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) + .isEqualTo("demo-sw-ver2.0.0"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + + /* + * Post the pnf to AAI + */ + wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = + FileUtil.readResourceFile("response/" + getClass().getSimpleName() + "_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json new file mode 100644 index 0000000000..a101118623 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json @@ -0,0 +1,54 @@ +{ + "requestDetails":{ + "requestInfo":{ + "source":"VID", + "suppressRollback":false, + "requestorId":"demo", + "productFamilyId":"SWUPid" + }, + "modelInfo":{ + "modelType":"service", + "modelInvariantUuid":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelInvariantId":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"32daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "requestParameters":{ + "userParams":[ + { + "name":"aic_zone", + "value":"nova" + }, + { + "name":"pnfId", + "value":"PNFDemo" + }, + { + "name":"targetSoftwareVersion", + "value":"demo-sw-ver2.0.0" + }, + { + "name":"pnfName", + "value":"PNFDemo" + } + ], + "subscriptionServiceType":"SWUP", + "aLaCarte":false + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"regionOne", + "tenantId":"09a63533072f4a579d5c99c3b8fe94c6" + }, + "subscriberInfo":{ + "globalSubscriberId":"ADemoCustomerInEric" + }, + "project":{ + "projectName":"Project-Demonstration" + }, + "owningEntity":{ + "owningEntityId":"5eae949c-1c50-4780-b8b5-7cbeb08856b4", + "owningEntityName":"OE-Demonstration" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json new file mode 100644 index 0000000000..32539844ba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json @@ -0,0 +1,26 @@ +{ + "serviceResources":{ + "modelInfo":{ + "modelInvariantId":"439b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"42daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "serviceType":"NA", + "environmentContext":"Luna", + "serviceRole":"NA", + "workloadContext":"Oxygen", + "serviceVnfs":[ + + ], + "serviceNetworks":[ + + ], + "serviceAllottedResources":[ + + ], + "configResource":[ + + ] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json new file mode 100644 index 0000000000..faec947fec --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json @@ -0,0 +1,39 @@ +{ + "_embedded": { + "pnfResourceCustomization": [ + { + "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680", + "modelInstanceName": "PNF routing", + "created": "2019-03-08 12:00:29.000", + "nfFunction": "routing", + "nfType": "routing", + "nfRole": "routing", + "nfNamingCode": "routing", + "multiStageDesign": null, + "resourceInput": null, + "blueprintName": "test_pnf_software_upgrade_restconf", + "blueprintVersion": "1.0.0", + "skipPostInstConf": false, + "softwareVersion": "1.0.0", + "creationTimestamp": "2019-03-08T12:00:29.000+0000", + "controllerActor": "cds", + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResourceCustomization": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResources": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java index 275cd18f0b..d2f52dac4c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java @@ -56,8 +56,8 @@ public class ControllerExecutionDETestIT extends BaseIntegrationTest { @Rule public final SpringMethodRule smr = new SpringMethodRule(); - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String PRECHECK_ACTION = "precheck"; private static final String POSTCHECK_ACTION = "postcheck"; private static final String ASSIGN_ACTION = "config-assign"; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java index c69adeec50..583e139edd 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java @@ -66,8 +66,8 @@ public class GenericPnfCDSProcessingDETest extends BaseTaskTest { private AbstractCDSProcessingBBUtils cdsDispather; private static final String PRECHECK_ACTION = "precheck"; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String POSTCHECK_ACTION = "postcheck"; private String description; |