diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
19 files changed, 817 insertions, 6 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 976ad1466d..e83e7e2ea2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -32,6 +32,7 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClientFactory import org.onap.so.client.aai.AAIResourcesClient import org.springframework.web.util.UriUtils import org.slf4j.Logger @@ -677,4 +678,8 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess public AAIResourcesClient getAAIClient(){ return new AAIResourcesClient(); } + + HttpClientFactory getHttpClientFactory(){ + return new HttpClientFactory() + } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index ce474fa713..b35042e3c0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -49,8 +49,8 @@ class RequestDBUtil { String operationType = operationStatus.getOperation() String result = operationStatus.getResult() String progress = operationStatus.getProgress() - String operationContent = operationStatus.getOperationContent() - String reason = operationStatus.getReason() + String operationContent = operationStatus.getOperationContent()?: "" + String reason = operationStatus.getReason()?: "" String payload = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 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 index eb2567d47c..9b46611468 100644 --- 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 @@ -31,12 +31,14 @@ 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 LCM_ACTION_TIMEOUT = "sdnc.lcm.actionTimeout"; 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_PARTITION = "sdnc.lcm.dmaap.partition"; public static final String LCM_DMAAP_READ_TOPIC = "sdnc.lcm.dmapp.readTopic"; public static final String LCM_DMAAP_WRITE_TOPIC = "sdnc.lcm.dmaap.writeTopic"; @@ -56,6 +58,12 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { } @Override + public long getActionTimeout() { + String actionTimeout = UrnPropertiesReader.getVariable(LCM_ACTION_TIMEOUT); + return (actionTimeout != null) ? Long.parseLong(actionTimeout) : SDNCConstants.LCM_ACTION_TIMEOUT; + } + + @Override public String getBasicAuth() { return UrnPropertiesReader.getVariable(SDNC_AUTH); } @@ -72,7 +80,7 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { @Override public String getDmaapPartition() { - String partition = UrnPropertiesReader.getVariable(DMAAP_PARTITION); + String partition = UrnPropertiesReader.getVariable(LCM_DMAAP_PARTITION); return (partition != null) ? partition : SDNCConstants.LCM_DMAAP_PARTITION; } 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 index fd9412e70e..dcbb120c69 100644 --- 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 @@ -45,5 +45,6 @@ public interface SDNCConstants { String LCM_DMAAP_READ_TOPIC = "SDNC-LCM-WRITE"; String LCM_DMAAP_WRITE_TOPIC = "SDNC-LCM-READ"; - int LCM_TIMEOUT = 300; + long LCM_ACTION_TIMEOUT = 300000; // Millisecond + int LCM_OUTPUT_SUCCESS_CODE = 400; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java new file mode 100644 index 0000000000..8ab40cb08d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java @@ -0,0 +1,28 @@ +/*- + * ============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 interface SDNCLcmActionConstants { + String ACTIVATE_N_E_SW = "ActivateNESw"; + String DOWNLOAD_N_E_SW = "DownloadNESw"; + String UPGRADE_POST_CHECK = "UpgradePostCheck"; + String UPGRADE_PRE_CHECK = "UpgradePreCheck"; +} 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 index 5616db3577..0f17c547b5 100644 --- 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 @@ -39,6 +39,10 @@ public class SDNCLcmClientBuilder { sdncLcmProperties = pros; } + public SDNCLcmProperties getSDNCLcmProperties() { + return sdncLcmProperties; + } + public SDNCLcmRestClient newSDNCLcmRestClient(String operation) throws SDNCLcmClientBuilderException { URI pathUri; try { 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 index df5fb3be0b..a21196e08f 100644 --- 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 @@ -27,6 +27,8 @@ public interface SDNCLcmProperties extends RestProperties { String getPath(); + long getActionTimeout(); + String getBasicAuth(); String getDmaapHost(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java new file mode 100644 index 0000000000..d86d114a9f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.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.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swVersionToBeActivated"}) +public class ActivateNESwPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "swVersionToBeActivated", required = true) + private String swVersionToBeActivated; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getSwVersionToBeActivated() { + return swVersionToBeActivated; + } + + public void setSwVersionToBeActivated(String value) { + this.swVersionToBeActivated = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java new file mode 100644 index 0000000000..5dc5cf503d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java @@ -0,0 +1,66 @@ +/*- + * ============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.payload; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swToBeDownloaded"}) +public class DownloadNESwPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "swToBeDownloaded", required = true) + private List<SwToBeDownloadedElement> swToBeDownloaded = new ArrayList<>(); + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public List<SwToBeDownloadedElement> getSwToBeDownloaded() { + return swToBeDownloaded; + } + + public void setSwToBeDownloaded(List<SwToBeDownloadedElement> value) { + this.swToBeDownloaded = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java new file mode 100644 index 0000000000..1a3529d7c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.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.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"swLocation", "swFileSize", "swFileCompression", "swFileFormat"}) +public class SwToBeDownloadedElement { + + @JsonProperty(value = "swLocation", required = true) + private String swLocation; + + @JsonProperty(value = "swFileSize") + private long swFileSize; + + @JsonProperty(value = "swFileCompression") + private String swFileCompression; + + @JsonProperty(value = "swFileFormat") + private String swFileFormat; + + public String getSwLocation() { + return swLocation; + } + + public void setSwLocation(String value) { + this.swLocation = value; + } + + public long getSwFileSize() { + return swFileSize; + } + + public void setSwFileSize(long value) { + this.swFileSize = value; + } + + public String getSwFileCompression() { + return swFileCompression; + } + + public void setSwFileCompression(String value) { + this.swFileCompression = value; + } + + public String getSwFileFormat() { + return swFileFormat; + } + + public void setSwFileFormat(String value) { + this.swFileFormat = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java new file mode 100644 index 0000000000..76937d262c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java @@ -0,0 +1,96 @@ +/*- + * ============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.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"}) +public class UpgradePostCheckPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "oldSwVersion", required = true) + private String oldSwVersion; + + @JsonProperty(value = "targetSwVersion", required = true) + private String targetSwVersion; + + @JsonProperty(value = "ruleName", required = true) + private String ruleName; + + @JsonProperty(value = "additionalData") + private String additionalData; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getOldSwVersion() { + return oldSwVersion; + } + + public void setOldSwVersion(String value) { + this.oldSwVersion = value; + } + + public String getTargetSwVersion() { + return targetSwVersion; + } + + public void setTargetSwVersion(String value) { + this.targetSwVersion = value; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String value) { + this.ruleName = value; + } + + public String getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(String value) { + this.additionalData = value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java new file mode 100644 index 0000000000..d1a95b8418 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java @@ -0,0 +1,96 @@ +/*- + * ============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.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"}) +public class UpgradePreCheckPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "oldSwVersion", required = true) + private String oldSwVersion; + + @JsonProperty(value = "targetSwVersion", required = true) + private String targetSwVersion; + + @JsonProperty(value = "ruleName", required = true) + private String ruleName; + + @JsonProperty(value = "additionalData") + private String additionalData; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getOldSwVersion() { + return oldSwVersion; + } + + public void setOldSwVersion(String value) { + this.oldSwVersion = value; + } + + public String getTargetSwVersion() { + return targetSwVersion; + } + + public void setTargetSwVersion(String value) { + this.targetSwVersion = value; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String value) { + this.ruleName = value; + } + + public String getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(String value) { + this.additionalData = value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy new file mode 100644 index 0000000000..6b63bbe56c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy @@ -0,0 +1,78 @@ +/*- + * ============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.common.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.db.request.beans.OperationStatus + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class RequestDBUtilTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("DoDeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void prepareUpdateOperationStatus(){ + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080") + OperationStatus operationStatus = new OperationStatus() + operationStatus.setServiceId("testServiceId") + operationStatus.setOperationId("testOperationId") + operationStatus.setUserId("testUserId") + operationStatus.setOperation("testOpertation") + operationStatus.setResult("testResult") + operationStatus.setProgress("testProgress") + operationStatus.setOperationContent("testOperationContent") + operationStatus.setReason("testReason") + + RequestDBUtil requestDBUtil = new RequestDBUtil() + requestDBUtil.prepareUpdateOperationStatus(mockExecution, operationStatus) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus = captor.getAllValues() + assertNotNull(updateOperationStatus) + } + + @Test + void testGetOperationStatus(){ + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080") + + RequestDBUtil requestDBUtil = new RequestDBUtil() + requestDBUtil.getOperationStatus(mockExecution, "testServiceId","testOperationId") + + Mockito.verify(mockExecution,times(1)).setVariable(eq("getOperationStatus"), captor.capture()) + String getOperationStatus = captor.getAllValues() + assertNotNull(getOperationStatus) + + } +} 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 index 5483792a84..3757769769 100644 --- 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 @@ -42,7 +42,7 @@ public class SDNCLcmDmaapClientTest extends BaseTest { 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 static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_PARTITION; protected String testWriteTopic = "TEST-WRITE-TOPIC"; protected String testReadTopic = "TEST-READ-TOPIC"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java new file mode 100644 index 0000000000..bee07f2022 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java @@ -0,0 +1,52 @@ +/*- + * ============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.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class ActivateNESwPayloadTest extends LcmBasePayloadTest { + private static String expectedActivateNESwPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}"; + + public ActivateNESwPayload buildActivateNESwPayload() { + ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload(); + + activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + activateNESwPayload.setPlaybookName(playbookName); + activateNESwPayload.setSwVersionToBeActivated("v2"); + + return activateNESwPayload; + } + + @Test + public final void testActivateNESwPayload() { + ActivateNESwPayload activateNESwPayload = buildActivateNESwPayload(); + + try { + String activateNESwPayloadString = convertToSting(activateNESwPayload); + assertEquals(expectedActivateNESwPayload, activateNESwPayloadString); + } catch (Exception e) { + fail("Convert ActivateNESwPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java new file mode 100644 index 0000000000..f9fa679790 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java @@ -0,0 +1,82 @@ +/*- + * ============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.payload; + +import java.util.Collections; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class DownloadNESwPayloadTest extends LcmBasePayloadTest { + private static String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\"," + + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}"; + + private static String expectedDownloadNESwPayload = + "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"test_playbook\"," + + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}"; + + public SwToBeDownloadedElement buildSwToBeDownloadedElement() { + SwToBeDownloadedElement swToBeDownloadedElement = new SwToBeDownloadedElement(); + + swToBeDownloadedElement.setSwLocation("http://192.168.1.20/test.zip"); + swToBeDownloadedElement.setSwFileSize(123456); + swToBeDownloadedElement.setSwFileCompression("ZIP"); + swToBeDownloadedElement.setSwFileFormat("binary"); + + return swToBeDownloadedElement; + } + + public DownloadNESwPayload buildDownloadNESwPayload() { + DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload(); + + downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + downloadNESwPayload.setPlaybookName(playbookName); + + SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement(); + downloadNESwPayload.setSwToBeDownloaded(Collections.singletonList(swToBeDownloadedElement)); + + return downloadNESwPayload; + } + + @Test + public final void testSwToBeDownloadedElement() { + SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement(); + + try { + String swToBeDownloadedElementString = convertToSting(swToBeDownloadedElement); + assertEquals(expectedSwToBeDownloadedElement, swToBeDownloadedElementString); + } catch (Exception e) { + fail("Convert SwToBeDownloadedElement to String error: " + e.toString()); + } + } + + @Test + public final void testDownloadNESwPayload() { + DownloadNESwPayload downloadNESwPayload = buildDownloadNESwPayload(); + + try { + String downloadNESwPayloadString = convertToSting(downloadNESwPayload); + assertEquals(expectedDownloadNESwPayload, downloadNESwPayloadString); + } catch (Exception e) { + fail("Convert DownloadNESwPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java new file mode 100644 index 0000000000..5452166d03 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.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.payload; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LcmBasePayloadTest { + private static Logger logger = LoggerFactory.getLogger(LcmBasePayloadTest.class); + + protected String ipaddressV4Oam = "192.168.1.10"; + protected String playbookName = "test_playbook"; + + 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/payload/UpgradePostCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java new file mode 100644 index 0000000000..acd447e890 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java @@ -0,0 +1,56 @@ +/*- + * ============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.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class UpgradePostCheckPayloadTest extends LcmBasePayloadTest { + private static String expectedUpgradePostCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\"," + + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}"; + + public UpgradePostCheckPayload buildUpgradePostCheckPayload() { + UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload(); + + upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + upgradePostCheckPayload.setPlaybookName(playbookName); + upgradePostCheckPayload.setOldSwVersion("v1"); + upgradePostCheckPayload.setTargetSwVersion("v2"); + upgradePostCheckPayload.setRuleName("r102"); + upgradePostCheckPayload.setAdditionalData("{}"); + + return upgradePostCheckPayload; + } + + @Test + public final void testUpgradePostCheckPayload() { + UpgradePostCheckPayload upgradePostCheckPayload = buildUpgradePostCheckPayload(); + + try { + String upgradePostCheckPayloadString = convertToSting(upgradePostCheckPayload); + assertEquals(expectedUpgradePostCheckPayload, upgradePostCheckPayloadString); + } catch (Exception e) { + fail("Convert UpgradePostCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java new file mode 100644 index 0000000000..8bc0714fff --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java @@ -0,0 +1,56 @@ +/*- + * ============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.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class UpgradePreCheckPayloadTest extends LcmBasePayloadTest { + private static String expectedUpgradePreCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\"," + + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}"; + + public UpgradePreCheckPayload buildUpgradePreCheckPayload() { + UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload(); + + upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + upgradePreCheckPayload.setPlaybookName(playbookName); + upgradePreCheckPayload.setOldSwVersion("v1"); + upgradePreCheckPayload.setTargetSwVersion("v2"); + upgradePreCheckPayload.setRuleName("r101"); + upgradePreCheckPayload.setAdditionalData("{}"); + + return upgradePreCheckPayload; + } + + @Test + public final void testUpgradePreCheckPayload() { + UpgradePreCheckPayload upgradePreCheckPayload = buildUpgradePreCheckPayload(); + + try { + String upgradePreCheckPayloadString = convertToSting(upgradePreCheckPayload); + assertEquals(expectedUpgradePreCheckPayload, upgradePreCheckPayloadString); + } catch (Exception e) { + fail("Convert UpgradePreCheckPayload to String error: " + e.toString()); + } + } +} |