diff options
author | Steve Smokowski <ss835w@att.com> | 2019-03-22 12:11:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-22 12:11:00 +0000 |
commit | c56619f68d3621177759a8a426343e6bf00270c8 (patch) | |
tree | 25ad9e5337f7c88795035fea6fb31c4bcfc47758 /bpmn | |
parent | 2061d60c2d380af5b9276ff4f86b3c95fbb7a5c1 (diff) | |
parent | 5fa9d2fe6b48a87a8063e674f9f0b92978fde8b1 (diff) |
Merge "Config Assign"
Diffstat (limited to 'bpmn')
26 files changed, 1727 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java index ba3ab7f315..c6e7668f22 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java @@ -143,8 +143,28 @@ public class GenericVnf implements Serializable, ShallowCopy<GenericVnf> { private String nfFunction; @JsonProperty("nf-role") private String nfRole; + @JsonProperty("CDS_BLUEPRINT_NAME") + private String blueprintName; + @JsonProperty("CDS_BLUEPRINT_VERSION") + private String blueprintVersion; + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getBlueprintVersion() { + return blueprintVersion; + } + + public void setBlueprintVersion(String blueprintVersion) { + this.blueprintVersion = blueprintVersion; + } + public String getNfFunction() { return nfFunction; } 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 new file mode 100644 index 0000000000..29abe4413b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -0,0 +1,192 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 TechMahindra + * ================================================================================ + * 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.cds; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType; +import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.so.client.PreconditionFailedException; +import org.onap.so.client.RestPropertiesLoader; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +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 com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.Struct; +import com.google.protobuf.Struct.Builder; +import com.google.protobuf.util.JsonFormat; + +import io.grpc.Status; + +/** + * Util class to support Call to CDS client + * + */ +@Component +public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { + + private static final Logger logger = LoggerFactory.getLogger(AbstractCDSProcessingBBUtils.class); + + private static final String SUCCESS = "Success"; + private static final String FAILED = "Failed"; + private static final String PROCESSING = "Processing"; + + private final AtomicReference<String> cdsResponse = new AtomicReference<>(); + + @Autowired + private ExceptionBuilder exceptionUtil; + + /** + * Extracting data from execution object and building the ExecutionServiceInput + * Object + * + * @param execution + * DelegateExecution object + */ + public void constructExecutionServiceInputObject(DelegateExecution execution) { + logger.trace("Start AbstractCDSProcessingBBUtils.preProcessRequest "); + + try { + AbstractCDSPropertiesBean executionObject = (AbstractCDSPropertiesBean) execution + .getVariable("executionObject"); + + String payload = executionObject.getRequestObject(); + + CommonHeader commonHeader = CommonHeader.newBuilder().setOriginatorId(executionObject.getOriginatorId()) + .setRequestId(executionObject.getRequestId()).setSubRequestId(executionObject.getSubRequestId()) + .build(); + ActionIdentifiers actionIdentifiers = ActionIdentifiers.newBuilder() + .setBlueprintName(executionObject.getBlueprintName()) + .setBlueprintVersion(executionObject.getBlueprintVersion()) + .setActionName(executionObject.getActionName()).setMode(executionObject.getMode()).build(); + + Builder struct = Struct.newBuilder(); + try { + JsonFormat.parser().merge(payload, struct); + } catch (InvalidProtocolBufferException e) { + logger.error("Failed to parse received message. blueprint({}:{}) for action({}). {}", + executionObject.getBlueprintVersion(), executionObject.getBlueprintName(), + executionObject.getActionName(), e); + } + + ExecutionServiceInput executionServiceInput = ExecutionServiceInput.newBuilder() + .setCommonHeader(commonHeader).setActionIdentifiers(actionIdentifiers).setPayload(struct.build()) + .build(); + + execution.setVariable("executionServiceInput", executionServiceInput); + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * get the executionServiceInput object from execution and send a request to CDS + * Client and wait for TIMEOUT period + * + * @param execution + * DelegateExecution object + */ + public void sendRequestToCDSClient(DelegateExecution execution) { + + logger.trace("Start AbstractCDSProcessingBBUtils.sendRequestToCDSClient "); + try { + CDSProperties props = RestPropertiesLoader.getInstance().getNewImpl(CDSProperties.class); + if (props == null) { + throw new PreconditionFailedException( + "No RestProperty.CDSProperties implementation found on classpath, can't create client."); + } + + ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution + .getVariable("executionServiceInput"); + + CDSProcessingListener cdsProcessingListener = new AbstractCDSProcessingBBUtils(); + + CDSProcessingClient cdsClient = new CDSProcessingClient(cdsProcessingListener); + CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput); + + try { + countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS); + } catch (InterruptedException ex) { + logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex); + } finally { + cdsClient.close(); + } + + if (cdsResponse != null) { + execution.setVariable("CDSStatus", cdsResponse.get()); + } + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * Get Response from CDS Client + * + */ + @Override + public void onMessage(ExecutionServiceOutput message) { + logger.info("Received notification from CDS: {}", message); + EventType eventType = message.getStatus().getEventType(); + + switch (eventType) { + + case EVENT_COMPONENT_FAILURE: + // failed processing with failure + cdsResponse.set(FAILED); + break; + case EVENT_COMPONENT_PROCESSING: + // still processing + cdsResponse.set(PROCESSING); + break; + case EVENT_COMPONENT_EXECUTED: + // done with async processing + cdsResponse.set(SUCCESS); + break; + default: + cdsResponse.set(FAILED); + break; + } + + } + + /** + * On error at CDS, log the error + */ + @Override + public void onError(Throwable t) { + Status status = Status.fromThrowable(t); + logger.error("Failed processing blueprint {}", status, t); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/AbstractCDSPropertiesBean.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/AbstractCDSPropertiesBean.java new file mode 100644 index 0000000000..4b645984cf --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/AbstractCDSPropertiesBean.java @@ -0,0 +1,89 @@ +package org.onap.so.client.cds.beans; + +import java.io.Serializable; + +public class AbstractCDSPropertiesBean implements Serializable { + + private static final long serialVersionUID = -4800522372460352963L; + + private String blueprintName; + + private String blueprintVersion; + + private String requestObject; + + private String originatorId; + + private String requestId; + + private String subRequestId; + + private String actionName; + + private String mode; + + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getBlueprintVersion() { + return blueprintVersion; + } + + public void setBlueprintVersion(String blueprintVersion) { + this.blueprintVersion = blueprintVersion; + } + + public String getRequestObject() { + return requestObject; + } + + public void setRequestObject(String requestObject) { + this.requestObject = requestObject; + } + + public String getOriginatorId() { + return originatorId; + } + + public void setOriginatorId(String originatorId) { + this.originatorId = originatorId; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getSubRequestId() { + return subRequestId; + } + + public void setSubRequestId(String subRequestId) { + this.subRequestId = subRequestId; + } + + public String getActionName() { + return actionName; + } + + public void setActionName(String actionName) { + this.actionName = actionName; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnf.java new file mode 100644 index 0000000000..bdb9161735 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnf.java @@ -0,0 +1,112 @@ +package org.onap.so.client.cds.beans; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"service-instance-id", +"pnf-id", +"pnf-name", +"service-model-uuid", +"pnf-customization-uuid" +}) + +public class ConfigAssignPropertiesForPnf { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("pnf-id") + private String pnfId; + + @JsonProperty("pnf-name") + private String pnfName; + + @JsonProperty("service-model-uuid") + private String serviceModelUuid; + + @JsonProperty("pnf-customization-uuid") + private String pnfCustomizationUuid; + + @JsonIgnore + private Map<String, Object> userParam = new HashMap<String, Object>(); + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getServiceModelUuid() { + return serviceModelUuid; + } + + public void setServiceModelUuid(String serviceModelUuid) { + this.serviceModelUuid = serviceModelUuid; + } + + public String getPnfCustomizationUuid() { + return pnfCustomizationUuid; + } + + public void setPnfCustomizationUuid(String pnfCustomizationUuid) { + this.pnfCustomizationUuid = pnfCustomizationUuid; + } + + public Map<String, Object> getUserParam() { + return this.userParam; + } + + public void setUserParam(String name, Object value) { + this.userParam.put(name, value); + } + + @Override + public String toString() { + + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"pnf-id\":").append("\"").append(pnfId).append("\""); + sb.append(", \"pnf-name\":").append("\"").append(pnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"pnf-customization-uuid\":").append("\"").append(pnfCustomizationUuid).append("\""); + for (Map.Entry<String, Object> entry : userParam.entrySet()) { + sb.append(","); + sb.append("\""); + sb.append(entry.getKey()); + sb.append("\""); + sb.append(":"); + sb.append("\""); + sb.append(entry.getValue()); + sb.append("\""); + } + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnf.java new file mode 100644 index 0000000000..1ce26d8585 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnf.java @@ -0,0 +1,112 @@ +package org.onap.so.client.cds.beans; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"service-instance-id", +"vnf-id", +"vnf-name", +"service-model-uuid", +"vnf-customization-uuid" +}) + +public class ConfigAssignPropertiesForVnf { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("vnf-name") + private String vnfName; + + @JsonProperty("service-model-uuid") + private String serviceModelUuid; + + @JsonProperty("vnf-customization-uuid") + private String vnfCustomizationUuid; + + @JsonIgnore + private Map<String, Object> userParam = new HashMap<String, Object>(); + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getServiceModelUuid() { + return serviceModelUuid; + } + + public void setServiceModelUuid(String serviceModelUuid) { + this.serviceModelUuid = serviceModelUuid; + } + + public String getVnfCustomizationUuid() { + return vnfCustomizationUuid; + } + + public void setVnfCustomizationUuid(String vnfCustomizationUuid) { + this.vnfCustomizationUuid = vnfCustomizationUuid; + } + + public Map<String, Object> getUserParam() { + return this.userParam; + } + + public void setUserParam(String name, Object value) { + this.userParam.put(name, value); + } + + @Override + public String toString() { + + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"vnf-id\":").append("\"").append(vnfId).append("\""); + sb.append(", \"vnf-name\":").append("\"").append(vnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"vnf-customization-uuid\":").append("\"").append(vnfCustomizationUuid).append("\""); + for (Map.Entry<String, Object> entry : userParam.entrySet()) { + sb.append(","); + sb.append("\""); + sb.append(entry.getKey()); + sb.append("\""); + sb.append(":"); + sb.append("\""); + sb.append(entry.getValue()); + sb.append("\""); + } + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnf.java new file mode 100644 index 0000000000..b96847f422 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnf.java @@ -0,0 +1,46 @@ +package org.onap.so.client.cds.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({ +"config-assign-properties", +"resolution-key" +}) + +public class ConfigAssignRequestPnf { + @JsonProperty("resolution-key") + private String resolutionKey; + @JsonProperty("config-assign-properties") + private ConfigAssignPropertiesForPnf configAssignPropertiesForPnf; + + public String getResolutionKey() { + return resolutionKey; + } + + public void setResolutionKey(String resolutionKey) { + this.resolutionKey = resolutionKey; + } + + public ConfigAssignPropertiesForPnf getConfigAssignPropertiesForPnf() { + return configAssignPropertiesForPnf; + } + + public void setConfigAssignPropertiesForPnf(ConfigAssignPropertiesForPnf configAssignPropertiesForPnf) { + this.configAssignPropertiesForPnf = configAssignPropertiesForPnf; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{\"config-assign-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-assign-properties\":").append(configAssignPropertiesForPnf.toString()); + sb.append('}'); + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnf.java new file mode 100644 index 0000000000..b3a9601e2e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnf.java @@ -0,0 +1,45 @@ + +package org.onap.so.client.cds.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({ +"config-assign-properties", +"resolution-key" +}) +public class ConfigAssignRequestVnf { + @JsonProperty("resolution-key") + private String resolutionKey; + @JsonProperty("config-assign-properties") + private ConfigAssignPropertiesForVnf configAssignPropertiesForVnf; + + public String getResolutionKey() { + return resolutionKey; + } + + public void setResolutionKey(String resolutionKey) { + this.resolutionKey = resolutionKey; + } + + public ConfigAssignPropertiesForVnf getConfigAssignPropertiesForVnf() { + return configAssignPropertiesForVnf; + } + + public void setConfigAssignPropertiesForVnf(ConfigAssignPropertiesForVnf configAssignPropertiesForVnf) { + this.configAssignPropertiesForVnf = configAssignPropertiesForVnf; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{\"config-assign-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-assign-properties\":").append(configAssignPropertiesForVnf.toString()); + sb.append('}'); + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java new file mode 100644 index 0000000000..b8fb5b96bd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java @@ -0,0 +1,88 @@ +package org.onap.so.client.cds.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({ +"service-instance-id", +"pnf-id", +"pnf-name", +"service-model-uuid", +"pnf-customization-uuid" +}) + +public class ConfigDeployPropertiesForPnf { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("pnf-id") + private String pnfId; + + @JsonProperty("pnf-name") + private String pnfName; + + @JsonProperty("service-model-uuid") + private String serviceModelUuid; + + @JsonProperty("pnf-customization-uuid") + private String pnfCustomizationUuid; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getServiceModelUuid() { + return serviceModelUuid; + } + + public void setServiceModelUuid(String serviceModelUuid) { + this.serviceModelUuid = serviceModelUuid; + } + + public String getPnfCustomizationUuid() { + return pnfCustomizationUuid; + } + + public void setPnfCustomizationUuid(String pnfCustomizationUuid) { + this.pnfCustomizationUuid = pnfCustomizationUuid; + } + + @Override + public String toString() { + + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"pnf-id\":").append("\"").append(pnfId).append("\""); + sb.append(", \"pnf-name\":").append("\"").append(pnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"pnf-customization-uuid\":").append("\"").append(pnfCustomizationUuid).append("\""); + + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnf.java new file mode 100644 index 0000000000..ca2530b541 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnf.java @@ -0,0 +1,87 @@ +package org.onap.so.client.cds.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({ +"service-instance-id", +"vnf-id", +"vnf-name", +"service-model-uuid", +"vnf-customization-uuid" +}) +public class ConfigDeployPropertiesForVnf { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("vnf-name") + private String vnfName; + + @JsonProperty("service-model-uuid") + private String serviceModelUuid; + + @JsonProperty("vnf-customization-uuid") + private String vnfCustomizationUuid; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getServiceModelUuid() { + return serviceModelUuid; + } + + public void setServiceModelUuid(String serviceModelUuid) { + this.serviceModelUuid = serviceModelUuid; + } + + public String getVnfCustomizationUuid() { + return vnfCustomizationUuid; + } + + public void setVnfCustomizationUuid(String vnfCustomizationUuid) { + this.vnfCustomizationUuid = vnfCustomizationUuid; + } + + @Override + public String toString() { + + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"vnf-id\":").append("\"").append(vnfId).append("\""); + sb.append(", \"vnf-name\":").append("\"").append(vnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"vnf-customization-uuid\":").append("\"").append(vnfCustomizationUuid).append("\""); + + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnf.java new file mode 100644 index 0000000000..4635008d3f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnf.java @@ -0,0 +1,46 @@ +package org.onap.so.client.cds.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({ +"config-deploy-properties", +"resolution-key" +}) +public class ConfigDeployRequestPnf { + @JsonProperty("resolution-key") + private String resolutionKey; + + @JsonProperty("config-deploy-properties") + private ConfigDeployPropertiesForPnf configDeployPropertiesForPnf; + + public String getResolutionKey() { + return resolutionKey; + } + + public void setResolutionKey(String resolutionKey) { + this.resolutionKey = resolutionKey; + } + + public ConfigDeployPropertiesForPnf getConfigDeployPropertiesForPnf() { + return configDeployPropertiesForPnf; + } + + public void setConfigDeployPropertiesForPnf(ConfigDeployPropertiesForPnf configDeployPropertiesForPnf) { + this.configDeployPropertiesForPnf = configDeployPropertiesForPnf; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{\"config-deploy-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-deploy-properties\":").append(configDeployPropertiesForPnf.toString()); + sb.append('}'); + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnf.java new file mode 100644 index 0000000000..53b956d3c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnf.java @@ -0,0 +1,46 @@ +package org.onap.so.client.cds.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({ +"config-deploy-properties", +"resolution-key" +}) +public class ConfigDeployRequestVnf { + @JsonProperty("resolution-key") + private String resolutionKey; + + @JsonProperty("config-deploy-properties") + private ConfigDeployPropertiesForVnf configDeployPropertiesForVnf; + + public String getResolutionKey() { + return resolutionKey; + } + + public void setResolutionKey(String resolutionKey) { + this.resolutionKey = resolutionKey; + } + + public ConfigDeployPropertiesForVnf getConfigDeployPropertiesForVnf() { + return configDeployPropertiesForVnf; + } + + public void setConfigDeployPropertiesForVnf(ConfigDeployPropertiesForVnf configDeployPropertiesForVnf) { + this.configDeployPropertiesForVnf = configDeployPropertiesForVnf; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{\"config-deploy-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-deploy-properties\":").append(configDeployPropertiesForVnf.toString()); + sb.append('}'); + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java index 1967e5a1ce..d1888b17df 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java @@ -30,6 +30,7 @@ public class CDSPropertiesImpl implements CDSProperties { private static final String ENDPOINT = "cds.endpoint"; private static final String PORT = "cds.port"; private static final String AUTH = "cds.auth"; + private static final String TIMEOUT = "cds.timeout"; public CDSPropertiesImpl() { // Needed for service loader @@ -74,4 +75,9 @@ public class CDSPropertiesImpl implements CDSProperties { public boolean mapNotFoundToEmpty() { return false; } + + @Override + public int getTimeout() { + return Integer.parseInt(Objects.requireNonNull(UrnPropertiesReader.getVariable(TIMEOUT))); + } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java new file mode 100644 index 0000000000..b2812d9bfb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 TechMahindra. + * ================================================================================ + * 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.cds; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.mockito.InjectMocks; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; + +@RunWith(JUnit4.class) +public class AbstractCDSProcessingBBUtilsTest { + @InjectMocks + private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils = new AbstractCDSProcessingBBUtils(); + @InjectMocks + AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean(); + + @Test + public void preProcessRequestTest() throws Exception { + String requestObject = "{\"config-assign-request\":{\"resolution-key\":\"resolutionKey\", \"config-assign-properties\":{\"service-instance-id\":\"serviceInstanceId\", \"vnf-id\":\"vnfId\", \"vnf-name\":\"vnfName\", \"service-model-uuid\":\"serviceModelUuid\", \"vnf-customization-uuid\":\"vnfCustomizationUuid\",\"Instance1\":\"Instance1Value\",\"Instance2\":\"Instance2Value\",\"Param3\":\"Param3Value\"}}}"; + String blueprintName = "blueprintName"; + String blueprintVersion = "blueprintVersion"; + String actionName = "actionName"; + String mode = "mode"; + String requestId = "123456"; + String originatorId = "originatorId"; + String subRequestId = UUID.randomUUID().toString(); + + abstractCDSPropertiesBean.setActionName(actionName); + abstractCDSPropertiesBean.setBlueprintName(blueprintName); + abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion); + abstractCDSPropertiesBean.setMode(mode); + abstractCDSPropertiesBean.setOriginatorId(originatorId); + abstractCDSPropertiesBean.setRequestId(requestId); + abstractCDSPropertiesBean.setRequestObject(requestObject); + abstractCDSPropertiesBean.setSubRequestId(subRequestId); + + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable("executionObject")).thenReturn(abstractCDSPropertiesBean); + + abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution); + assertTrue(true); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnfTest.java new file mode 100644 index 0000000000..c294124e69 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnfTest.java @@ -0,0 +1,70 @@ +package org.onap.so.client.cds.beans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class ConfigAssignPropertiesForPnfTest { + ConfigAssignPropertiesForPnf configAssignPropertiesForPnf = new ConfigAssignPropertiesForPnf(); + private Map<String, Object> userParam = new HashMap<String, Object>(); + private String serviceInstanceId; + private String pnfId; + private String pnfName; + private String serviceModelUuid; + private String pnfCustomizationUuid; + + @Test + public final void testConfigDeployPropertiesForPnfTest() { + userParam.put("Instance1", "instance1value"); + userParam.put("Instance2", "instance2value"); + configAssignPropertiesForPnf.setPnfCustomizationUuid("pnf-customization-uuid"); + configAssignPropertiesForPnf.setPnfId("pnf-id"); + configAssignPropertiesForPnf.setPnfName("pnf-name"); + configAssignPropertiesForPnf.setServiceInstanceId("service-instance-id"); + configAssignPropertiesForPnf.setServiceModelUuid("service-model-uuid"); + configAssignPropertiesForPnf.setUserParam("Instance1", "instance1value"); + configAssignPropertiesForPnf.setUserParam("Instance2", "instance2value"); + + assertNotNull(configAssignPropertiesForPnf.getPnfCustomizationUuid()); + assertNotNull(configAssignPropertiesForPnf.getPnfId()); + assertNotNull(configAssignPropertiesForPnf.getPnfName()); + assertNotNull(configAssignPropertiesForPnf.getServiceInstanceId()); + assertNotNull(configAssignPropertiesForPnf.getServiceModelUuid()); + assertNotNull(configAssignPropertiesForPnf.getUserParam()); + + assertEquals("service-instance-id", configAssignPropertiesForPnf.getServiceInstanceId()); + assertEquals("service-model-uuid", configAssignPropertiesForPnf.getServiceModelUuid()); + assertEquals("pnf-customization-uuid", configAssignPropertiesForPnf.getPnfCustomizationUuid()); + assertEquals("pnf-id", configAssignPropertiesForPnf.getPnfId()); + assertEquals("pnf-name", configAssignPropertiesForPnf.getPnfName()); + assertEquals(userParam, configAssignPropertiesForPnf.getUserParam()); + } + + @Test + public void testtoString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"pnf-id\":").append("\"").append(pnfId).append("\""); + sb.append(", \"pnf-name\":").append("\"").append(pnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"pnf-customization-uuid\":").append("\"").append(pnfCustomizationUuid).append("\""); + for (Map.Entry<String, Object> entry : userParam.entrySet()) { + sb.append(","); + sb.append("\""); + sb.append(entry.getKey()); + sb.append("\""); + sb.append(":"); + sb.append("\""); + sb.append(entry.getValue()); + sb.append("\""); + } + sb.append('}'); + String Expexted = sb.toString(); + assertEquals(Expexted, configAssignPropertiesForPnf.toString()); + + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnfTest.java new file mode 100644 index 0000000000..8b732af6d0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnfTest.java @@ -0,0 +1,68 @@ +package org.onap.so.client.cds.beans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class ConfigAssignPropertiesForVnfTest { + ConfigAssignPropertiesForVnf configAssignPropertiesForVnf = new ConfigAssignPropertiesForVnf(); + private Map<String, Object> userParam = new HashMap<String, Object>(); + private String serviceInstanceId; + private String vnfId; + private String vnfName; + private String serviceModelUuid; + private String vnfCustomizationUuid; + + @Test + public final void testConfigAssignPropertiesForVnfTest() { + userParam.put("Instance1", "instance1value"); + configAssignPropertiesForVnf.setServiceInstanceId("service-instance-id"); + configAssignPropertiesForVnf.setServiceModelUuid("service-model-uuid"); + configAssignPropertiesForVnf.setVnfCustomizationUuid("vnf-customization-uuid"); + configAssignPropertiesForVnf.setVnfId("vnf-id"); + configAssignPropertiesForVnf.setVnfName("vnf-name"); + configAssignPropertiesForVnf.setUserParam("Instance1", "instance1value"); + + assertNotNull(configAssignPropertiesForVnf.getServiceInstanceId()); + assertNotNull(configAssignPropertiesForVnf.getServiceModelUuid()); + assertNotNull(configAssignPropertiesForVnf.getVnfCustomizationUuid()); + assertNotNull(configAssignPropertiesForVnf.getVnfId()); + assertNotNull(configAssignPropertiesForVnf.getVnfName()); + assertNotNull(configAssignPropertiesForVnf.getUserParam()); + + assertEquals("service-instance-id", configAssignPropertiesForVnf.getServiceInstanceId()); + assertEquals("service-model-uuid", configAssignPropertiesForVnf.getServiceModelUuid()); + assertEquals("vnf-customization-uuid", configAssignPropertiesForVnf.getVnfCustomizationUuid()); + assertEquals("vnf-id", configAssignPropertiesForVnf.getVnfId()); + assertEquals("vnf-name", configAssignPropertiesForVnf.getVnfName()); + assertEquals(userParam, configAssignPropertiesForVnf.getUserParam()); + + } + + @Test + public void testtoString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"vnf-id\":").append("\"").append(vnfId).append("\""); + sb.append(", \"vnf-name\":").append("\"").append(vnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"vnf-customization-uuid\":").append("\"").append(vnfCustomizationUuid).append("\""); + for (Map.Entry<String, Object> entry : userParam.entrySet()) { + sb.append(","); + sb.append("\""); + sb.append(entry.getKey()); + sb.append("\""); + sb.append(":"); + sb.append("\""); + sb.append(entry.getValue()); + sb.append("\""); + } + sb.append('}'); + String Expexted = sb.toString(); + assertEquals(Expexted, configAssignPropertiesForVnf.toString()); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnfTest.java new file mode 100644 index 0000000000..e4f062ad05 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnfTest.java @@ -0,0 +1,48 @@ +package org.onap.so.client.cds.beans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class ConfigAssignRequestPnfTest { + ConfigAssignRequestPnf configAssignRequestPnf = new ConfigAssignRequestPnf(); + ConfigAssignPropertiesForPnf configAssignPropertiesForPnf = new ConfigAssignPropertiesForPnf(); + private Map<String, Object> userParam = new HashMap<String, Object>(); + private String resolutionKey; + + @Test + public final void testConfigAssignRequestPnfTest() { + configAssignRequestPnf.setResolutionKey("resolution-key"); + configAssignRequestPnf.setConfigAssignPropertiesForPnf(configAssignPropertiesForPnf); + assertNotNull(configAssignRequestPnf.getResolutionKey()); + assertNotNull(configAssignRequestPnf.getConfigAssignPropertiesForPnf()); + + assertEquals("resolution-key", configAssignRequestPnf.getResolutionKey()); + assertEquals(configAssignPropertiesForPnf, configAssignRequestPnf.getConfigAssignPropertiesForPnf()); + } + + @Test + public void testtoString() { + userParam.put("Instance1", "instance1value"); + configAssignPropertiesForPnf.setPnfCustomizationUuid("pnf-customization-uuid"); + configAssignPropertiesForPnf.setPnfId("pnf-id"); + configAssignPropertiesForPnf.setPnfName("pnf-name"); + configAssignPropertiesForPnf.setServiceInstanceId("service-instance-id"); + configAssignPropertiesForPnf.setServiceModelUuid("service-model-uuid"); + configAssignPropertiesForPnf.setUserParam("user_params", userParam); + configAssignRequestPnf.setConfigAssignPropertiesForPnf(configAssignPropertiesForPnf); + final StringBuilder sb = new StringBuilder("{\"config-assign-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-assign-properties\":").append(configAssignPropertiesForPnf.toString()); + sb.append('}'); + sb.append('}'); + String Expexted = sb.toString(); + + assertEquals(Expexted, configAssignRequestPnf.toString()); + + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnfTest.java new file mode 100644 index 0000000000..ad3af47453 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnfTest.java @@ -0,0 +1,51 @@ +package org.onap.so.client.cds.beans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class ConfigAssignRequestVnfTest { + ConfigAssignRequestVnf configAssignRequestVnf = new ConfigAssignRequestVnf(); + ConfigAssignPropertiesForVnf configAssignPropertiesForVnf = new ConfigAssignPropertiesForVnf(); + private Map<String, Object> userParam = new HashMap<String, Object>(); + + private String resolutionKey; + + @Test + public final void testConfigAssignRequestVnf() { + configAssignRequestVnf.setResolutionKey("resolution-key"); + configAssignRequestVnf.setConfigAssignPropertiesForVnf(configAssignPropertiesForVnf); + assertNotNull(configAssignRequestVnf.getResolutionKey()); + assertNotNull(configAssignRequestVnf.getConfigAssignPropertiesForVnf()); + + assertEquals("resolution-key", configAssignRequestVnf.getResolutionKey()); + assertEquals(configAssignPropertiesForVnf, configAssignRequestVnf.getConfigAssignPropertiesForVnf()); + + } + + @Test + public void testtoString() { + userParam.put("Instance1", "instance1value"); + configAssignPropertiesForVnf.setServiceInstanceId("service-instance-id"); + configAssignPropertiesForVnf.setServiceModelUuid("service-model-uuid"); + configAssignPropertiesForVnf.setUserParam("user_params", userParam); + configAssignPropertiesForVnf.setVnfCustomizationUuid("vnf-customization-uuid"); + configAssignPropertiesForVnf.setVnfId("vnf-id"); + configAssignPropertiesForVnf.setVnfName("vnf-name"); + configAssignRequestVnf.setConfigAssignPropertiesForVnf(configAssignPropertiesForVnf); + + final StringBuilder sb = new StringBuilder("{\"config-assign-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-assign-properties\":").append(configAssignPropertiesForVnf.toString()); + sb.append('}'); + sb.append('}'); + + String Expexted = sb.toString(); + + assertEquals(Expexted, configAssignRequestVnf.toString()); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java new file mode 100644 index 0000000000..1d771c86d5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java @@ -0,0 +1,50 @@ +package org.onap.so.client.cds.beans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class ConfigDeployPropertiesForPnfTest { + ConfigDeployPropertiesForPnf configDeployPropertiesForPnf = new ConfigDeployPropertiesForPnf(); + private String serviceInstanceId; + private String pnfId; + private String pnfName; + private String serviceModelUuid; + private String pnfCustomizationUuid; + + @Test + public final void testConfigDeployPropertiesForPnfTest() { + configDeployPropertiesForPnf.setServiceInstanceId("service-instance-id"); + configDeployPropertiesForPnf.setServiceModelUuid("service-model-uuid"); + configDeployPropertiesForPnf.setPnfCustomizationUuid("pnf-customization-uuid"); + configDeployPropertiesForPnf.setPnfId("pnf-id"); + configDeployPropertiesForPnf.setPnfName("pnf-name"); + assertNotNull(configDeployPropertiesForPnf.getServiceInstanceId()); + assertNotNull(configDeployPropertiesForPnf.getServiceModelUuid()); + assertNotNull(configDeployPropertiesForPnf.getPnfCustomizationUuid()); + assertNotNull(configDeployPropertiesForPnf.getPnfId()); + assertNotNull(configDeployPropertiesForPnf.getPnfName()); + + assertEquals("service-instance-id", configDeployPropertiesForPnf.getServiceInstanceId()); + assertEquals("service-model-uuid", configDeployPropertiesForPnf.getServiceModelUuid()); + assertEquals("pnf-customization-uuid", configDeployPropertiesForPnf.getPnfCustomizationUuid()); + assertEquals("pnf-id", configDeployPropertiesForPnf.getPnfId()); + assertEquals("pnf-name", configDeployPropertiesForPnf.getPnfName()); + + } + + @Test + public void testtoString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"pnf-id\":").append("\"").append(pnfId).append("\""); + sb.append(", \"pnf-name\":").append("\"").append(pnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"pnf-customization-uuid\":").append("\"").append(pnfCustomizationUuid).append("\""); + sb.append('}'); + String Expexted = sb.toString(); + assertEquals(Expexted, configDeployPropertiesForPnf.toString()); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnfTest.java new file mode 100644 index 0000000000..47c59b93e9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnfTest.java @@ -0,0 +1,49 @@ +package org.onap.so.client.cds.beans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class ConfigDeployPropertiesForVnfTest { + ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf(); + private String serviceInstanceId; + private String vnfId; + private String vnfName; + private String serviceModelUuid; + private String vnfCustomizationUuid; + + @Test + public final void testConfigDeployPropertiesForVnf() { + configDeployPropertiesForVnf.setServiceInstanceId("service-instance-id"); + configDeployPropertiesForVnf.setServiceModelUuid("service-model-uuid"); + configDeployPropertiesForVnf.setVnfCustomizationUuid("vnf-customization-uuid"); + configDeployPropertiesForVnf.setVnfId("vnf-id"); + configDeployPropertiesForVnf.setVnfName("vnf-name"); + assertNotNull(configDeployPropertiesForVnf.getServiceInstanceId()); + assertNotNull(configDeployPropertiesForVnf.getServiceModelUuid()); + assertNotNull(configDeployPropertiesForVnf.getVnfCustomizationUuid()); + assertNotNull(configDeployPropertiesForVnf.getVnfId()); + assertNotNull(configDeployPropertiesForVnf.getVnfName()); + + assertEquals("service-instance-id", configDeployPropertiesForVnf.getServiceInstanceId()); + assertEquals("service-model-uuid", configDeployPropertiesForVnf.getServiceModelUuid()); + assertEquals("vnf-customization-uuid", configDeployPropertiesForVnf.getVnfCustomizationUuid()); + assertEquals("vnf-id", configDeployPropertiesForVnf.getVnfId()); + assertEquals("vnf-name", configDeployPropertiesForVnf.getVnfName()); + } + + @Test + public void testtoString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"vnf-id\":").append("\"").append(vnfId).append("\""); + sb.append(", \"vnf-name\":").append("\"").append(vnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"vnf-customization-uuid\":").append("\"").append(vnfCustomizationUuid).append("\""); + sb.append('}'); + String Expexted = sb.toString(); + assertEquals(Expexted, configDeployPropertiesForVnf.toString()); + + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnfTest.java new file mode 100644 index 0000000000..df41bf23b8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnfTest.java @@ -0,0 +1,41 @@ +package org.onap.so.client.cds.beans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class ConfigDeployRequestPnfTest { + ConfigDeployRequestPnf configDeployRequestPnf = new ConfigDeployRequestPnf(); + private String resolutionKey; + ConfigDeployPropertiesForPnf configDeployPropertiesForPnf = new ConfigDeployPropertiesForPnf(); + + @Test + public final void testConfigDeployRequestVnf() { + configDeployRequestPnf.setResolutionKey("resolution-key"); + configDeployRequestPnf.setConfigDeployPropertiesForPnf(configDeployPropertiesForPnf); + assertNotNull(configDeployRequestPnf.getResolutionKey()); + assertNotNull(configDeployRequestPnf.getConfigDeployPropertiesForPnf()); + assertEquals("resolution-key", configDeployRequestPnf.getResolutionKey()); + assertEquals(configDeployPropertiesForPnf, configDeployRequestPnf.getConfigDeployPropertiesForPnf()); + } + + @Test + public void testtoString() { + configDeployPropertiesForPnf.setServiceInstanceId("service-instance-id"); + configDeployPropertiesForPnf.setServiceModelUuid("service-model-uuid"); + configDeployPropertiesForPnf.setPnfCustomizationUuid("pnf-customization-uuid"); + configDeployPropertiesForPnf.setPnfId("pnf-id"); + configDeployPropertiesForPnf.setPnfName("pnf-name"); + configDeployRequestPnf.setConfigDeployPropertiesForPnf(configDeployPropertiesForPnf); + final StringBuilder sb = new StringBuilder("{\"config-deploy-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-deploy-properties\":").append(configDeployPropertiesForPnf.toString()); + sb.append('}'); + sb.append('}'); + String Expexted = sb.toString(); + + assertEquals(Expexted, configDeployRequestPnf.toString()); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnfTest.java new file mode 100644 index 0000000000..f771710f8b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnfTest.java @@ -0,0 +1,42 @@ +package org.onap.so.client.cds.beans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class ConfigDeployRequestVnfTest { + + ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf(); + private String resolutionKey; + ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf(); + + @Test + public final void testConfigDeployRequestVnf() { + configDeployRequestVnf.setResolutionKey("resolution-key"); + configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf); + assertNotNull(configDeployRequestVnf.getResolutionKey()); + assertNotNull(configDeployRequestVnf.getConfigDeployPropertiesForVnf()); + assertEquals("resolution-key", configDeployRequestVnf.getResolutionKey()); + assertEquals(configDeployPropertiesForVnf, configDeployRequestVnf.getConfigDeployPropertiesForVnf()); + } + + @Test + public void testtoString() { + configDeployPropertiesForVnf.setServiceInstanceId("service-instance-id"); + configDeployPropertiesForVnf.setServiceModelUuid("service-model-uuid"); + configDeployPropertiesForVnf.setVnfCustomizationUuid("vnf-customization-uuid"); + configDeployPropertiesForVnf.setVnfId("vnf-id"); + configDeployPropertiesForVnf.setVnfName("vnf-name"); + configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf); + final StringBuilder sb = new StringBuilder("{\"config-deploy-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-deploy-properties\":").append(configDeployPropertiesForVnf.toString()); + sb.append('}'); + sb.append('}'); + String Expexted = sb.toString(); + + assertEquals(Expexted, configDeployRequestVnf.toString()); + } + +} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AbstractCDSProcessingBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AbstractCDSProcessingBB.bpmn new file mode 100644 index 0000000000..4fcf13d98d --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AbstractCDSProcessingBB.bpmn @@ -0,0 +1,50 @@ +<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1l7m222" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.1"> + <bpmn:process id="AbstractCDSProcessingBB" name="Abstract CDS Processing BB" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>SequenceFlow_02v5z4h</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_02v5z4h" sourceRef="StartEvent_1" targetRef="Task_06n9c9v" /> + <bpmn:sequenceFlow id="SequenceFlow_0gksy4i" sourceRef="Task_06n9c9v" targetRef="Task_0kjfr5o" /> + <bpmn:sequenceFlow id="SequenceFlow_161g9uz" sourceRef="Task_0kjfr5o" targetRef="EndEvent_1h3epjc" /> + <bpmn:endEvent id="EndEvent_1h3epjc"> + <bpmn:incoming>SequenceFlow_161g9uz</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="Task_06n9c9v" name="Get Required data to call CDS Client" camunda:expression="${AbstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution)}"> + <bpmn:incoming>SequenceFlow_02v5z4h</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0gksy4i</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="Task_0kjfr5o" name="CDS (Call SelfServiceAPI) " camunda:expression="${AbstractCDSProcessingBBUtils.sendRequestToCDSClient(execution)}"> + <bpmn:incoming>SequenceFlow_0gksy4i</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_161g9uz</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AbstractCDSProcessingBB"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="124" y="264" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_02v5z4h_di" bpmnElement="SequenceFlow_02v5z4h"> + <di:waypoint x="160" y="282" /> + <di:waypoint x="223" y="282" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0gksy4i_di" bpmnElement="SequenceFlow_0gksy4i"> + <di:waypoint x="323" y="282" /> + <di:waypoint x="385" y="282" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_161g9uz_di" bpmnElement="SequenceFlow_161g9uz"> + <di:waypoint x="485" y="282" /> + <di:waypoint x="578" y="282" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1h3epjc_di" bpmnElement="EndEvent_1h3epjc"> + <dc:Bounds x="578" y="264" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_16es7z5_di" bpmnElement="Task_06n9c9v"> + <dc:Bounds x="223" y="242" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_18soa9e_di" bpmnElement="Task_0kjfr5o"> + <dc:Bounds x="385" y="242" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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 new file mode 100644 index 0000000000..9892fbdd91 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn @@ -0,0 +1,98 @@ +<?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:di="http://www.omg.org/spec/DD/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" id="Definitions_1ahlzqg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.1"> + <bpmn:process id="ConfigAssignVnfBB" name="ConfigAssignVnfBB" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>SequenceFlow_0gmfit3</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_0gmfit3" sourceRef="StartEvent_1" targetRef="Task_0bhf6tp" /> + <bpmn:endEvent id="EndEvent_0lgvk82"> + <bpmn:incoming>SequenceFlow_1mkhog2</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1mkhog2" sourceRef="Task_1hs1mn0" targetRef="EndEvent_0lgvk82" /> + <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:in source="executionObject" target="executionObject" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_05qembo</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0cvsnuu</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:serviceTask id="Task_1hs1mn0" name="Update AAI (VNF) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusConfigAssignedVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_07tqu82</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1mkhog2</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_05qembo" sourceRef="Task_0bhf6tp" targetRef="CallActivity_1gfzi2g" /> + <bpmn:serviceTask id="Task_0bhf6tp" name="PreProcess Abstract CDS Processing" camunda:expression="${ConfigAssignVnf.PreProcessAbstractCDSProcessing(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0gmfit3</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_05qembo</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_13q340y" default="SequenceFlow_15gxql1"> + <bpmn:incoming>SequenceFlow_0cvsnuu</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07tqu82</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_15gxql1</bpmn:outgoing> + </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:sequenceFlow> + <bpmn:endEvent id="EndEvent_0mnaj50"> + <bpmn:incoming>SequenceFlow_15gxql1</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1s1hqgm" errorRef="Error_0aovtfv" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_15gxql1" sourceRef="ExclusiveGateway_13q340y" targetRef="EndEvent_0mnaj50" /> + </bpmn:process> + <bpmn:error id="Error_0aovtfv" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ConfigAssignVnfBB"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="507" y="187" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0gmfit3_di" bpmnElement="SequenceFlow_0gmfit3"> + <di:waypoint x="543" y="205" /> + <di:waypoint x="614" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_0lgvk82_di" bpmnElement="EndEvent_0lgvk82"> + <dc:Bounds x="1307" y="187" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1mkhog2_di" bpmnElement="SequenceFlow_1mkhog2"> + <di:waypoint x="1218" y="205" /> + <di:waypoint x="1307" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_1gfzi2g_di" bpmnElement="CallActivity_1gfzi2g"> + <dc:Bounds x="788" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0404s6a_di" bpmnElement="Task_1hs1mn0"> + <dc:Bounds x="1118" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_05qembo_di" bpmnElement="SequenceFlow_05qembo"> + <di:waypoint x="714" y="205" /> + <di:waypoint x="788" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_01mv1si_di" bpmnElement="Task_0bhf6tp"> + <dc:Bounds x="614" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_13q340y_di" bpmnElement="ExclusiveGateway_13q340y" isMarkerVisible="true"> + <dc:Bounds x="978" y="180" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0cvsnuu_di" bpmnElement="SequenceFlow_0cvsnuu"> + <di:waypoint x="888" y="205" /> + <di:waypoint x="978" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07tqu82_di" bpmnElement="SequenceFlow_07tqu82"> + <di:waypoint x="1028" y="205" /> + <di:waypoint x="1118" y="205" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1053" y="187" width="41" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_0mnaj50_di" bpmnElement="EndEvent_0mnaj50"> + <dc:Bounds x="985" y="327" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_15gxql1_di" bpmnElement="SequenceFlow_15gxql1"> + <di:waypoint x="1003" y="230" /> + <di:waypoint x="1003" y="327" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index a618606d41..4237a50061 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -530,4 +530,12 @@ public class AAIUpdateTasks { } } + public void updateOrchestrationStatusConfigAssignedVnf(BuildingBlockExecution execution) { + try { + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGASSIGNED); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java new file mode 100644 index 0000000000..1304408309 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 TechMahindra. + * ================================================================================ + * 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.flowspecific.tasks; + +import java.util.Map; +import java.util.UUID; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.cds.beans.ConfigAssignPropertiesForVnf; +import org.onap.so.client.cds.beans.ConfigAssignRequestVnf; +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; + +/** + * + * Get vnf related data and config assign + * + */ +@Component +public class ConfigAssignVnf { + + private static final Logger logger = LoggerFactory.getLogger(ConfigAssignVnf.class); + private static final String ORIGINATOR_ID = "SO"; + private static final String ACTION_NAME = "config-assign"; + private static final String MODE = "sync"; + + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private ExtractPojosForBB extractPojosForBB; + + /** + * Getting the vnf data, blueprint name, blueprint version etc and setting them + * in execution object and calling the subprocess. + * + * @param execution + */ + public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) { + logger.info("Start preProcessAbstractCDSProcessing "); + try { + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, + execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, + execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + + Map<String, Object> userParams = execution.getGeneralBuildingBlock().getRequestContext().getUserParams(); + + ConfigAssignPropertiesForVnf configAssignPropertiesForVnf = new ConfigAssignPropertiesForVnf(); + configAssignPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + configAssignPropertiesForVnf + .setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid()); + configAssignPropertiesForVnf + .setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + configAssignPropertiesForVnf.setVnfId(vnf.getVnfId()); + configAssignPropertiesForVnf.setVnfName(vnf.getVnfName()); + + for (Map.Entry<String, Object> entry : userParams.entrySet()) { + configAssignPropertiesForVnf.setUserParam(entry.getKey(), entry.getValue()); + } + + ConfigAssignRequestVnf configAssignRequestVnf = new ConfigAssignRequestVnf(); + configAssignRequestVnf.setResolutionKey(vnf.getVnfName()); + configAssignRequestVnf.setConfigAssignPropertiesForVnf(configAssignPropertiesForVnf); + + String blueprintName = vnf.getBlueprintName(); + String blueprintVersion = vnf.getBlueprintVersion(); + + AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean(); + + abstractCDSPropertiesBean.setBlueprintName(blueprintName); + abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion); + abstractCDSPropertiesBean.setRequestObject(configAssignRequestVnf.toString()); + + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + + abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID); + abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId()); + abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString()); + abstractCDSPropertiesBean.setActionName(ACTION_NAME); + abstractCDSPropertiesBean.setMode(MODE); + execution.setVariable("executionObject", abstractCDSPropertiesBean); + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java new file mode 100644 index 0000000000..be94a968c2 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 TechMahindra. + * ================================================================================ + * 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.flowspecific.tasks; + +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.BBObjectNotFoundException; + +public class ConfigAssignVnfTest extends BaseTaskTest { + @InjectMocks + private ConfigAssignVnf configAssignVnf = new ConfigAssignVnf(); + + private GenericVnf genericVnf; + private ServiceInstance serviceInstance; + private RequestContext requestContext; + private String msoRequestId; + + @Before + public void before() throws BBObjectNotFoundException { + genericVnf = setGenericVnf(); + serviceInstance = setServiceInstance(); + msoRequestId = UUID.randomUUID().toString(); + requestContext = setRequestContext(); + requestContext.setMsoRequestId(msoRequestId); + gBBInput.setRequestContext(requestContext); + + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil) + .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())) + .thenReturn(genericVnf); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())) + .thenReturn(serviceInstance); + } + + @Test + public void preProcessAbstractCDSProcessingTest() throws Exception { + + configAssignVnf.preProcessAbstractCDSProcessing(execution); + + assertTrue(true); + } + +} |