summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rwxr-xr-xms/blueprintsprocessor/application/pom.xml2
-rwxr-xr-xms/blueprintsprocessor/distribution/pom.xml2
-rw-r--r--ms/blueprintsprocessor/functions/cli-executor/pom.xml2
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/pom.xml2
-rwxr-xr-xms/blueprintsprocessor/functions/pom.xml2
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/pom.xml2
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt120
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json23
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/pom.xml2
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml9
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt88
-rwxr-xr-xms/blueprintsprocessor/modules/commons/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt22
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml2
-rwxr-xr-xms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/outbounds/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt59
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt27
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt42
-rwxr-xr-xms/blueprintsprocessor/modules/services/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/pom.xml2
-rwxr-xr-xms/blueprintsprocessor/parent/pom.xml8
-rwxr-xr-xms/blueprintsprocessor/pom.xml2
-rwxr-xr-xms/command-executor/pom.xml5
-rw-r--r--ms/controllerblueprints/application/pom.xml2
-rwxr-xr-xms/controllerblueprints/distribution/pom.xml2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/pom.xml2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt33
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt169
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt515
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/pom.xml2
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/pom.xml2
-rw-r--r--ms/controllerblueprints/modules/db-resources/pom.xml2
-rw-r--r--ms/controllerblueprints/modules/pom.xml5
-rw-r--r--ms/controllerblueprints/modules/resource-dict/pom.xml2
-rw-r--r--ms/controllerblueprints/modules/service/pom.xml5
-rw-r--r--ms/controllerblueprints/parent/pom.xml2
-rw-r--r--ms/controllerblueprints/pom.xml4
-rw-r--r--ms/pom.xml7
-rw-r--r--ms/sdclistener/application/pom.xml20
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java36
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java1
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java1
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java10
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java2
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java84
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessage.java (renamed from ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/DistributionStatusMessage.java)24
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java65
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/BuilderUtil.java16
-rw-r--r--ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java30
-rw-r--r--ms/sdclistener/application/src/main/resources/application.yaml (renamed from ms/sdclistener/application/src/main/resources/application.yml)0
-rw-r--r--ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java46
-rw-r--r--ms/sdclistener/application/src/test/resources/service-ServicePnfTest-csar.csarbin0 -> 58715 bytes
-rw-r--r--ms/sdclistener/application/src/test/resources/service-Testsvc140.csarbin116298 -> 0 bytes
-rw-r--r--ms/sdclistener/application/src/test/resources/wrong_csar_pattern.csarbin0 -> 29302 bytes
-rwxr-xr-xms/sdclistener/distribution/pom.xml2
-rwxr-xr-xms/sdclistener/parent/pom.xml6
-rw-r--r--ms/sdclistener/pom.xml2
67 files changed, 1376 insertions, 172 deletions
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index c079ba990..a5d45277d 100755
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>application</artifactId>
diff --git a/ms/blueprintsprocessor/distribution/pom.xml b/ms/blueprintsprocessor/distribution/pom.xml
index 0a9e4a93e..91ead8d90 100755
--- a/ms/blueprintsprocessor/distribution/pom.xml
+++ b/ms/blueprintsprocessor/distribution/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>distribution</artifactId>
diff --git a/ms/blueprintsprocessor/functions/cli-executor/pom.xml b/ms/blueprintsprocessor/functions/cli-executor/pom.xml
index 77c45e76e..af76d128b 100644
--- a/ms/blueprintsprocessor/functions/cli-executor/pom.xml
+++ b/ms/blueprintsprocessor/functions/cli-executor/pom.xml
@@ -18,7 +18,7 @@
<parent>
<artifactId>functions</artifactId>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cli-executor</artifactId>
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
index 16ec6fbc1..a46e7433d 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
+++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
@@ -18,7 +18,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>functions</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml
index 3f948061f..a635c9f4c 100755
--- a/ms/blueprintsprocessor/functions/pom.xml
+++ b/ms/blueprintsprocessor/functions/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/ms/blueprintsprocessor/functions/python-executor/pom.xml b/ms/blueprintsprocessor/functions/python-executor/pom.xml
index af9d1987a..8e098bfef 100644
--- a/ms/blueprintsprocessor/functions/python-executor/pom.xml
+++ b/ms/blueprintsprocessor/functions/python-executor/pom.xml
@@ -18,7 +18,7 @@
<parent>
<artifactId>functions</artifactId>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
index 0c5a947f1..896d9a648 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
@@ -17,14 +17,22 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.ObjectMapper
import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.runBlocking
import org.junit.Test
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.PrepareRemoteEnvInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionOutput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StatusType
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.RemoteScriptExecutionService
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.putJsonElement
+import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import kotlin.test.assertEquals
@@ -58,7 +66,117 @@ class ComponentRemotePythonExecutorTest {
executionServiceInput.stepData = stepInputData
componentRemotePythonExecutor.applyNB(executionServiceInput)
}
+ }
+
+ /**
+ * Test cases for python executor to work with the process NB of remote
+ * executor.
+ */
+ @Test
+ fun testComponentRemotePythonExecutorProcessNB() {
+ runBlocking {
+ val remoteScriptExecutionService =
+ MockRemoteScriptExecutionService()
+ val componentRemotePythonExecutor = ComponentRemotePythonExecutor(
+ remoteScriptExecutionService)
+ val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>(
+ "123456-1000")
+ val input = getMockedOutput(bluePrintRuntime)
+ componentRemotePythonExecutor.bluePrintRuntimeService =
+ bluePrintRuntime
+ componentRemotePythonExecutor.applyNB(input)
+ }
+ }
+
+ /**
+ * Mocked input information for remote python executor.
+ */
+ fun getMockedOutput(svc: DefaultBluePrintRuntimeService):
+ ExecutionServiceInput {
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+
+ stepMetaData.putJsonElement(
+ BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
+ "execute-remote-python")
+ stepMetaData.putJsonElement(
+ BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
+ "ComponentRemotePythonExecutor")
+ stepMetaData.putJsonElement(
+ BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+
+ val mapper = ObjectMapper()
+ val rootNode = mapper.createObjectNode()
+ rootNode.put("ip-address", "0.0.0.0")
+ rootNode.put("type", "rest")
+
+ val operationalInputs: MutableMap<String, JsonNode> = hashMapOf()
+ operationalInputs.putJsonElement(
+ BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
+ "execute-remote-python")
+ operationalInputs.putJsonElement(
+ BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
+ "ComponentRemotePythonExecutor")
+ operationalInputs.putJsonElement(
+ BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ operationalInputs.putJsonElement("endpoint-selector", "aai")
+ operationalInputs.putJsonElement("dynamic-properties", rootNode)
+ operationalInputs.putJsonElement("command", "./run.sh")
+ operationalInputs.putJsonElement("packages", "py")
+
+ every {
+ svc.resolveNodeTemplateInterfaceOperationInputs(
+ "execute-remote-python",
+ "ComponentRemotePythonExecutor", "process")
+ } returns operationalInputs
+
+ val stepInputData = StepData().apply {
+ name = "execute-remote-python"
+ properties = stepMetaData
+ }
+ val executionServiceInput = JacksonUtils
+ .readValueFromClassPathFile(
+ "payload/requests/sample-remote-python-request.json",
+ ExecutionServiceInput::class.java)!!
+ executionServiceInput.stepData = stepInputData
+
+ val operationOutputs = hashMapOf<String, JsonNode>()
+ every {
+ svc.resolveNodeTemplateInterfaceOperationOutputs(
+ "execute-remote-python",
+ "ComponentRemotePythonExecutor", "process")
+ } returns operationOutputs
+ val bluePrintRuntimeService = BluePrintMetadataUtils
+ .getBluePrintRuntime("123456-1000",
+ "./../../../../components/model-" +
+ "catalog/blueprint-model/test-blueprint/" +
+ "remote_scripts")
+ every {
+ svc.resolveNodeTemplateArtifactDefinition(
+ "execute-remote-python", "component-script")
+ } returns bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(
+ "execute-remote-python", "component-script")
+ every {
+ svc.setNodeTemplateAttributeValue(
+ "execute-remote-python", "prepare-environment-logs",
+ "prepared successfully".asJsonPrimitive())
+ } returns Unit
+ every {
+ svc.setNodeTemplateAttributeValue(
+ "execute-remote-python",
+ "execute-command-logs", "N/A".asJsonPrimitive())
+ } returns Unit
+ every {
+ svc.setNodeTemplateAttributeValue(
+ "execute-remote-python",
+ "execute-command-logs",
+ "processed successfully".asJsonPrimitive())
+ } returns Unit
+
+ every {
+ svc.bluePrintContext()
+ } returns bluePrintRuntimeService.bluePrintContext()
+ return executionServiceInput
}
}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json
new file mode 100644
index 000000000..68a366432
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-remote-python-request.json
@@ -0,0 +1,23 @@
+{
+ "actionIdentifiers": {
+ "actionName": "activate",
+ "blueprintName": "remote_scripts",
+ "blueprintVersion": "1.0.0",
+ "mode": "sync"
+ },
+ "commonHeader": {
+ "flags": {
+ "force": true,
+ "ttl": 3600
+ },
+ "originatorId": "sdnc",
+ "requestId": "123456-1000",
+ "subRequestId": "sub-123456-1000",
+ "timestamp": "2012-04-23T18:25:43.511Z"
+ },
+ "payload": {
+ "execute-remote-python": {
+ "input": "1234"
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
index b4bbd50f9..3666b4109 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
+++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>functions</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
<artifactId>resource-resolution</artifactId>
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml
index ef2f8bbb6..47a7af7ea 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml
+++ b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml
@@ -18,7 +18,7 @@
<parent>
<artifactId>functions</artifactId>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
index faf5578c9..df66ff391 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>commons</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>db-lib</artifactId>
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
index 5f302993a..3261489ee 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>commons</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>dmaap-lib</artifactId>
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml
index e50b1915f..c7933a7ff 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml
@@ -14,14 +14,11 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>commons</artifactId>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -45,4 +42,4 @@
</dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
index a459d5fe2..8df218fe9 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
@@ -16,17 +16,22 @@
package org.onap.ccsdk.cds.blueprintsprocessor.grpc.service
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BasicAuthGrpcClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BluePrintGrpcLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BluePrintGrpcLibConfiguration::class,
@@ -36,21 +41,92 @@ import kotlin.test.assertNotNull
"blueprintsprocessor.grpcclient.sample.host=127.0.0.1",
"blueprintsprocessor.grpcclient.sample.port=50505",
"blueprintsprocessor.grpcclient.sample.username=sampleuser",
- "blueprintsprocessor.grpcclient.sample.password=sampleuser"
+ "blueprintsprocessor.grpcclient.sample.password=sampleuser",
+ "blueprintsprocessor.grpcclient.token.type=token-auth",
+ "blueprintsprocessor.grpcclient.token.host=127.0.0.1",
+ "blueprintsprocessor.grpcclient.token.port=50505",
+ "blueprintsprocessor.grpcclient.token.username=sampleuser",
+ "blueprintsprocessor.grpcclient.token.password=sampleuser"
])
class BluePrintGrpcLibPropertyServiceTest {
@Autowired
lateinit var bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService
+ /**
+ * Tests the GRPC client properties with selector for basic auth.
+ */
@Test
fun testGrpcClientProperties() {
val properties = bluePrintGrpcLibPropertyService.grpcClientProperties(
- "blueprintsprocessor.grpcclient.sample") as BasicAuthGrpcClientProperties
+ "blueprintsprocessor.grpcclient.sample")
+ as BasicAuthGrpcClientProperties
assertNotNull(properties, "failed to create property bean")
- assertNotNull(properties.host, "failed to get host property in property bean")
- assertNotNull(properties.port, "failed to get host property in property bean")
- assertNotNull(properties.username, "failed to get host property in property bean")
- assertNotNull(properties.password, "failed to get host property in property bean")
+ assertNotNull(properties.host, "failed to get host property" +
+ " in property bean")
+ assertNotNull(properties.port, "failed to get host property" +
+ " in property bean")
+ assertNotNull(properties.username, "failed to get host pro" +
+ "perty in property bean")
+ assertNotNull(properties.password, "failed to get host pr" +
+ "operty in property bean")
+ }
+
+ /**
+ * Tests the GRPC client properties with JSON node for token auth.
+ */
+ @Test
+ fun testGrpcClientPropertiesWithJson() {
+ val json: String = "{\n" +
+ " \"type\" : \"token-auth\",\n" +
+ " \"host\" : \"127.0.0.1\",\n" +
+ " \"port\" : \"50505\"\n" +
+ "}"
+ val mapper = ObjectMapper()
+ val actualObj: JsonNode = mapper.readTree(json)
+ val properties = bluePrintGrpcLibPropertyService.grpcClientProperties(
+ actualObj) as TokenAuthGrpcClientProperties
+ assertNotNull(properties, "failed to create property bean")
+ assertEquals(properties.host, "127.0.0.1")
+ assertNotNull(properties.port, "50505")
+ }
+
+ /**
+ * Tests the GRPC client service with selector for basic auth.
+ */
+ @Test
+ fun testGrpcClientServiceBasic() {
+ val svc = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(
+ "sample")
+ assertTrue(svc is BasicAuthGrpcClientService)
+ }
+
+ /**
+ * Tests the GRPC client service with selector for token auth.
+ */
+ @Test
+ fun testGrpcClientServiceToken() {
+ val svc = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(
+ "token")
+ assertTrue(svc is TokenAuthGrpcClientService)
+ }
+
+ /**
+ * Tests the GRPC client service with JSON node for basic auth.
+ */
+ @Test
+ fun testGrpcClientServiceWithJson() {
+ val json: String = "{\n" +
+ " \"type\" : \"basic-auth\",\n" +
+ " \"host\" : \"127.0.0.1\",\n" +
+ " \"port\" : \"50505\",\n" +
+ " \"username\" : \"sampleuser\",\n" +
+ " \"password\" : \"samplepwd\"\n" +
+ "}"
+ val mapper = ObjectMapper()
+ val actualObj: JsonNode = mapper.readTree(json)
+ val svc = bluePrintGrpcLibPropertyService
+ .blueprintGrpcClientService(actualObj)
+ assertTrue(svc is BasicAuthGrpcClientService)
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml
index 9b52565c1..5fdfb5064 100755
--- a/ms/blueprintsprocessor/modules/commons/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>commons</artifactId>
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml
index 93a9b793a..31feff177 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>commons</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>processor-core</artifactId>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
index 6809e7968..0cae94690 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>commons</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>rest-lib</artifactId>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt
index a85dc9ad7..37a797f78 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt
@@ -20,7 +20,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
-import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
@@ -63,7 +62,6 @@ import kotlin.test.assertNotNull
"blueprintsprocessor.restclient.ssl.sslKey=src/test/resources/keystore.p12",
"blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit"
])
-@Ignore
class BluePrintRestLibPropertyServiceTest {
@Autowired
@@ -215,5 +213,25 @@ class BluePrintRestLibPropertyServiceTest {
"eprintWebClientService")
}
+ @Test
+ fun testBlueprintWebClientServiceWithJsonNode() {
+ val json: String = "{\n" +
+ " \"type\" : \"ssl-basic-auth\",\n" +
+ " \"url\" : \"https://localhost:8443\",\n" +
+ " \"keyStoreInstance\" : \"PKCS12\",\n" +
+ " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" +
+ " \"sslTrustPassword\" : \"changeit\",\n" +
+ " \"basicAuth\" : {\n" +
+ " \"username\" : \"admin\",\n" +
+ " \"password\" : \"cds\"\n" +
+ " }\n" +
+ "}"
+ val mapper = ObjectMapper()
+ val actualObj: JsonNode = mapper.readTree(json)
+ val blueprintWebClientService = bluePrintRestLibPropertyService
+ .blueprintWebClientService(actualObj)
+ assertNotNull(blueprintWebClientService, "failed to create blu" +
+ "eprintWebClientService")
+ }
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml
index c8f6b9e42..17b630fdd 100644
--- a/ms/blueprintsprocessor/modules/inbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>inbounds</artifactId>
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
index 4d5857651..d5acf4f93 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>inbounds</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>resource-api</artifactId>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
index d3f8b4616..340f2c618 100755
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>inbounds</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>selfservice-api</artifactId>
diff --git a/ms/blueprintsprocessor/modules/outbounds/pom.xml b/ms/blueprintsprocessor/modules/outbounds/pom.xml
index d406462db..7512990c1 100644
--- a/ms/blueprintsprocessor/modules/outbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/outbounds/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>outbounds</artifactId>
diff --git a/ms/blueprintsprocessor/modules/pom.xml b/ms/blueprintsprocessor/modules/pom.xml
index c67c97882..3bdd13d58 100644
--- a/ms/blueprintsprocessor/modules/pom.xml
+++ b/ms/blueprintsprocessor/modules/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
index d366f740d..edfa4e3f7 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>services</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>execution-service</artifactId>
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
index c5fbea80f..b404fbed6 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
@@ -21,6 +21,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts;
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.node.ObjectNode
import io.mockk.every
import io.mockk.mockk
@@ -32,12 +33,16 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.scripts.BluePrintScriptsServiceImpl
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.BeforeTest
import kotlin.test.assertEquals
@@ -47,10 +52,16 @@ import kotlin.test.assertNotNull
* Unit test cases for abstract component function.
*/
@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [ComponentFunctionScriptingService::class,
+ BluePrintScriptsServiceImpl::class,PythonExecutorProperty::class,
+ BlueprintJythonService::class])
class AbstractComponentFunctionTest {
lateinit var blueprintContext: BluePrintContext
+ @Autowired
+ lateinit var compSvc: ComponentFunctionScriptingService
+
@BeforeTest
fun init() {
blueprintContext = mockk<BluePrintContext>()
@@ -82,12 +93,56 @@ class AbstractComponentFunctionTest {
}
}
+ /**
+ * Tests the abstract script component functionality.
+ */
+ @Test
+ fun testAbstractScriptComponent() {
+ runBlocking {
+ val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>("1234")
+ val samp = SampleRestconfComponent(compSvc)
+ val comp = samp as AbstractComponentFunction
+
+ comp.bluePrintRuntimeService = bluePrintRuntime
+ comp.stepName = "sample-step"
+ assertNotNull(comp, "failed to get kotlin instance")
+
+ val input = getMockedInput(bluePrintRuntime)
+ val inp = getMockedContext()
+
+ val output = comp.applyNB(input)
+
+ assertEquals(output.actionIdentifiers.actionName, "activate")
+ assertEquals(output.commonHeader.requestId, "1234")
+ assertEquals(output.stepData!!.name, "activate-restconf")
+ assertEquals(output.status.message, "success")
+ }
+ }
+
+ /**
+ * Mocked input for abstract function test.
+ */
+ private fun getMockedContext() {
+ val operationOutputs = hashMapOf<String, JsonNode>()
+ every {
+ blueprintContext.name()
+ } returns "SampleTest"
+ every {
+ blueprintContext.version()
+ } returns "SampleScriptComponent"
+ }
/**
* Mocked input for abstract function test.
*/
private fun getMockedInput(bluePrintRuntime: DefaultBluePrintRuntimeService):
ExecutionServiceInput {
+
+ val mapper = ObjectMapper()
+ val rootNode = mapper.createObjectNode()
+ rootNode.put("ip-address", "0.0.0.0")
+ rootNode.put("type", "rest")
+
val operationInputs = hashMapOf<String, JsonNode>()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] =
"activate-restconf".asJsonPrimitive()
@@ -95,6 +150,8 @@ class AbstractComponentFunctionTest {
"interfaceName".asJsonPrimitive()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] =
"operationName".asJsonPrimitive()
+ operationInputs["dynamic-properties"] = rootNode
+
val stepInputData = StepData().apply {
name = "activate-restconf"
@@ -125,4 +182,6 @@ class AbstractComponentFunctionTest {
return executionServiceInput
}
+
}
+
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
index dd417e56d..ae7b7b2ef 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
@@ -28,8 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
-import kotlin.test.assertNotNull
import kotlin.test.BeforeTest
+import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class])
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
index e09cbfb66..000d8c09b 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
@@ -23,6 +23,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
+
import org.slf4j.LoggerFactory
open class SampleComponent : AbstractComponentFunction() {
@@ -37,12 +40,34 @@ open class SampleComponent : AbstractComponentFunction() {
}
}
-open class SampleScriptComponent : AbstractComponentFunction() {
+open class SampleRestconfComponent (private var componentFunctionScriptingService: ComponentFunctionScriptingService)
+ : AbstractComponentFunction() {
val log = LoggerFactory.getLogger(SampleScriptComponent::class.java)!!
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+ var scriptComponent: AbstractScriptComponentFunction
+ scriptComponent = componentFunctionScriptingService
+ .scriptInstance<AbstractScriptComponentFunction>(this,
+ "internal",
+ "org.onap.ccsdk.cds.blueprintsprocessor.services" +
+ ".execution.scripts.SampleTest",
+ mutableListOf())
+ scriptComponent.executeScript(executionServiceInput)
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ }
+}
+
+open class SampleScriptComponent : AbstractScriptComponentFunction() {
+
+ val log = LoggerFactory.getLogger(SampleScriptComponent::class.java)!!
+
+
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt
new file mode 100644
index 000000000..6a95e29e7
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt
@@ -0,0 +1,42 @@
+package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 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=========================================================
+ */
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
+import org.slf4j.LoggerFactory
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+open class SampleTest : AbstractScriptComponentFunction() {
+
+ val log = LoggerFactory.getLogger(SampleTest::class.java)!!
+
+
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+ val isPresent = checkDynamicProperties("type")
+ assertTrue(isPresent)
+ val prop = getDynamicProperties("ip-address").toString()
+ assertEquals(prop, "\"0.0.0.0\"")
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml
index 751ad94d4..d2f1219e9 100755
--- a/ms/blueprintsprocessor/modules/services/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>services</artifactId>
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
index c48ff250f..d7f87aeff 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>services</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index 42abbc51d..5f3e926f7 100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -16,13 +16,12 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>blueprintsprocessor</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>parent</artifactId>
@@ -41,7 +40,6 @@
<jsch.version>0.1.55</jsch.version>
<protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
<eelf.version>1.0.0</eelf.version>
- <sli.version>0.4.2-SNAPSHOT</sli.version>
<guava.version>27.0.1-jre</guava.version>
<jython.version>2.7.1</jython.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
@@ -249,7 +247,7 @@
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sli-provider</artifactId>
- <version>${sli.version}</version>
+ <version>${ccsdk.sli.core.version}</version>
<exclusions>
<exclusion>
<groupId>commons-lang</groupId>
diff --git a/ms/blueprintsprocessor/pom.xml b/ms/blueprintsprocessor/pom.xml
index ffdb877e4..99d796972 100755
--- a/ms/blueprintsprocessor/pom.xml
+++ b/ms/blueprintsprocessor/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>ms</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>blueprintsprocessor</artifactId>
diff --git a/ms/command-executor/pom.xml b/ms/command-executor/pom.xml
index 7376d7746..c4a679b12 100755
--- a/ms/command-executor/pom.xml
+++ b/ms/command-executor/pom.xml
@@ -14,13 +14,12 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>ms</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>command-executor</artifactId>
diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml
index ddefb2787..d1d6551ed 100644
--- a/ms/controllerblueprints/application/pom.xml
+++ b/ms/controllerblueprints/application/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>application</artifactId>
diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml
index 563b4eb40..6da578814 100755
--- a/ms/controllerblueprints/distribution/pom.xml
+++ b/ms/controllerblueprints/distribution/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>distribution</artifactId>
diff --git a/ms/controllerblueprints/modules/blueprint-core/pom.xml b/ms/controllerblueprints/modules/blueprint-core/pom.xml
index 524a42f17..9e22af637 100644
--- a/ms/controllerblueprints/modules/blueprint-core/pom.xml
+++ b/ms/controllerblueprints/modules/blueprint-core/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>blueprint-core</artifactId>
<name>Controller Blueprints Core</name>
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt
new file mode 100644
index 000000000..e3e5c26a3
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt
@@ -0,0 +1,33 @@
+package org.onap.ccsdk.cds.controllerblueprints.core
+
+import org.junit.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+class BluePrintErrorTest {
+
+ @Test
+ fun testBluePrintErrorIsCreatedWithemptyList() {
+ val bluePrintError = BluePrintError()
+
+ assertTrue(bluePrintError.errors.isEmpty())
+ }
+
+ @Test
+ fun testAddErrorWith3Params() {
+ val bluePrintError = BluePrintError()
+
+ bluePrintError.addError("type", "name", "error")
+
+ assertEquals("type : name : error", bluePrintError.errors[0])
+ }
+
+ @Test
+ fun testAddErrorWith1Params() {
+ val bluePrintError = BluePrintError()
+
+ bluePrintError.addError("error")
+
+ assertEquals("error", bluePrintError.errors[0])
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt
index d5334dc5f..487b1d15b 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt
@@ -16,8 +16,12 @@
package org.onap.ccsdk.cds.controllerblueprints.core
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.*
import org.junit.Test
-import kotlin.test.assertEquals
+import kotlin.test.*
+
/**
*
*
@@ -25,11 +29,172 @@ import kotlin.test.assertEquals
*/
class CustomFunctionsTest {
@Test
- fun testFormat(): Unit {
+ fun testFormat() {
val returnValue : String = format("This is {} for times {}", "test", 2)
assertEquals("This is test for times 2", returnValue, "Failed to format String")
val returnValue1 : String = format("This is test for times 2")
assertEquals("This is test for times 2", returnValue1, "Failed to format empty args")
}
+
+ @Test
+ fun testStringAsJsonPrimitive() {
+ val returnValue: TextNode = "hello".asJsonPrimitive()
+ assertEquals("hello", returnValue.textValue())
+ }
+
+ @Test
+ fun testIntAsJsonPrimitive() {
+ val returnValue: IntNode = 1.asJsonPrimitive()
+ assertEquals(1, returnValue.intValue())
+ }
+
+ @Test
+ fun testBooleanAsJsonPrimitive() {
+ val returnValue: BooleanNode = false.asJsonPrimitive()
+ assertFalse(returnValue.asBoolean())
+ }
+
+ @Test
+ fun testAsJsonType() {
+ val nullReturnValue: JsonNode = null.asJsonType()
+ assertEquals(NullNode.instance, nullReturnValue)
+
+ val returnValueString: JsonNode = "hello".asJsonType()
+ assertEquals("hello", returnValueString.textValue())
+
+ val returnValueJsonNode: JsonNode = returnValueString.asJsonType()
+ assertEquals(returnValueString, returnValueJsonNode)
+
+ val returnValueInt: JsonNode = 1.asJsonType()
+ assertEquals(1, returnValueInt.intValue())
+
+ val returnValueBool: JsonNode = false.asJsonType()
+ assertFalse(returnValueBool.asBoolean())
+
+ val returnValue: JsonNode = BluePrintError().asJsonType()
+ assertEquals(JsonNodeType.OBJECT, returnValue.getNodeType())
+ }
+
+ @Test
+ fun testMapAsObjectNode() {
+ val returnValue: ObjectNode = hashMapOf("test" to BluePrintError()).asObjectNode()
+ assertNotNull(returnValue.get("test"))
+ }
+
+ @Test
+ fun testCastOptionalValue() {
+ val initMap: Map<String, *> = hashMapOf("test" to 1.1, "test2" to null)
+ val returnValue = initMap.castOptionalValue("test", Number::class)
+
+ assert(returnValue is Number)
+
+ val returnValueNull = initMap.castOptionalValue("test1", Number::class)
+
+ assertNull(returnValueNull)
+
+ val returnValueString: String? = initMap.castOptionalValue("test2", String::class)
+
+ assertNull(returnValueString)
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testCastValue() {
+ val initMap: Map<String, Double> = hashMapOf("test" to 1.1)
+ val returnValue = initMap.castValue("test", Number::class)
+
+ assertNotNull(returnValue)
+
+ initMap.castValue("test1", Number::class)
+ }
+
+ @Test
+ fun testAsListOfString() {
+ val arrayNode: ArrayNode = ObjectMapper().createObjectNode().putArray("array")
+
+ val result: List<String> = arrayNode.asListOfString()
+
+ assertTrue(result.isEmpty())
+ }
+
+ @Test
+ fun testReturnNullIfMissing() {
+ val valueExist = "hello".asJsonType().returnNullIfMissing()
+ assertNotNull(valueExist)
+
+ val valueNull = NullNode.instance.returnNullIfMissing()
+ assertNull(valueNull)
+
+ val missingValue = MissingNode.getInstance().returnNullIfMissing()
+ assertNull(missingValue)
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testRootFieldsToMap() {
+ 1.asJsonType().rootFieldsToMap()
+ }
+
+ @Test
+ fun testPutJsonElement() {
+ val mutMap = mutableMapOf("test" to 2.asJsonType())
+
+ mutMap.putJsonElement("hello", 3)
+
+ assertEquals(3, mutMap["hello"]?.asInt())
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testMapGetAsString() {
+ val initMap = hashMapOf("test" to "hello".asJsonType())
+
+ assertEquals("hello", initMap.getAsString("test"))
+
+ initMap.getAsString("test2")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testMapGetAsBoolean() {
+ val initMap = hashMapOf("test" to true.asJsonType())
+
+ assertTrue(initMap.getAsBoolean("test"))
+
+ initMap.getAsBoolean("test2")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testMapGetAsInt() {
+ val initMap = hashMapOf("test" to 1.asJsonType())
+
+ assertEquals(1, initMap.getAsInt("test"))
+
+ initMap.getAsInt("test2")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testCheckEquals() {
+ assertTrue(checkEquals("hello", "hello", { -> "error"}))
+
+ checkEquals("hello", "test", { -> "error"})
+ }
+
+ @Test(expected = IllegalStateException::class)
+ fun testCheckNotEmpty() {
+ assertEquals("hello", checkNotEmpty("hello", { -> "error"}))
+
+ checkNotEmpty("", { -> "error"})
+ }
+
+ @Test(expected = IllegalStateException::class)
+ fun testCheckNotBlank() {
+ assertEquals("hello", checkNotBlank("hello", { -> "error"}))
+
+ checkNotBlank(" ", { -> "error"})
+ }
+
+ @Test
+ fun testNullToEmpty() {
+ assertEquals("", nullToEmpty(null))
+
+ assertEquals("hello", nullToEmpty("hello"))
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt
index 2c6561f23..33890277f 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt
@@ -18,11 +18,18 @@
package org.onap.ccsdk.cds.controllerblueprints.core.service
+import com.fasterxml.jackson.databind.ObjectMapper
import org.slf4j.LoggerFactory
import org.junit.Test
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.data.*
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import kotlin.test.assertEquals
import kotlin.test.assertNotNull
+import kotlin.test.assertNull
+import kotlin.test.assertTrue
/**
*
@@ -49,5 +56,513 @@ class BluePrintContextTest {
log.trace("Properties {}", JacksonUtils.getJson(nodeType, true))
}
+ @Test
+ fun testImports() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.imports = mutableListOf()
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertTrue(bluePrintContext.imports()!!.isEmpty())
+
+ serviceTemplate.imports = null
+ assertNull(bluePrintContext.imports())
+ }
+
+ @Test
+ fun testDataTypes() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.dataTypes = mutableMapOf()
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertTrue(bluePrintContext.dataTypes()!!.isEmpty())
+
+ serviceTemplate.dataTypes = null
+ assertNull(bluePrintContext.dataTypes())
+ }
+
+ @Test
+ fun testInputs() {
+ val topologyTemplate = TopologyTemplate()
+ topologyTemplate.inputs = mutableMapOf()
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.topologyTemplate = topologyTemplate
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertTrue(bluePrintContext.inputs()!!.isEmpty())
+
+ topologyTemplate.inputs = null
+
+ assertNull(bluePrintContext.inputs())
+ }
+
+ @Test
+ fun testBluePrintJson() {
+ val serviceTemplate = ServiceTemplate()
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("{\"tosca_definitions_version\":\"controller_blueprint_1_0_0\"}", bluePrintContext.blueprintJson())
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testName() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_NAME to "hello")
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("hello", bluePrintContext.name())
+
+ serviceTemplate.metadata = mutableMapOf()
+ val bluePrintContext2 = BluePrintContext(serviceTemplate)
+ bluePrintContext2.name()
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testVersion() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_VERSION to "hello")
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("hello", bluePrintContext.version())
+
+ serviceTemplate.metadata = mutableMapOf()
+ val bluePrintContext2 = BluePrintContext(serviceTemplate)
+ bluePrintContext2.version()
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testAuthor() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_AUTHOR to "hello")
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("hello", bluePrintContext.author())
+
+ serviceTemplate.metadata = mutableMapOf()
+ val bluePrintContext2 = BluePrintContext(serviceTemplate)
+ bluePrintContext2.author()
+ }
+
+ @Test
+ fun testWorkflows() {
+ val topologyTemplate = TopologyTemplate()
+ topologyTemplate.workflows = mutableMapOf()
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.topologyTemplate = topologyTemplate
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertTrue(bluePrintContext.workflows()!!.isEmpty())
+
+ topologyTemplate.workflows = null
+ assertNull(bluePrintContext.workflows())
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testWorkFlowsByName() {
+ val topologyTemplate = TopologyTemplate()
+ topologyTemplate.workflows = mutableMapOf("workflow" to Workflow())
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.topologyTemplate = topologyTemplate
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.workflowByName("workflow"))
+
+ bluePrintContext.workflowByName("")
+ }
+
+ @Test
+ fun testWorkflowInput() {
+ val topologyTemplate = TopologyTemplate()
+ val workflow = Workflow()
+ workflow.inputs = mutableMapOf()
+ topologyTemplate.workflows = mutableMapOf("workflow" to workflow)
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.topologyTemplate = topologyTemplate
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertTrue(bluePrintContext.workflowInputs("workflow")!!.isEmpty())
+
+ workflow.inputs = null
+
+ assertNull(bluePrintContext.workflowInputs("workflow"))
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testWorkflowStepByName() {
+ val topologyTemplate = TopologyTemplate()
+ val workflow = Workflow()
+ workflow.steps = mutableMapOf("step" to Step())
+ topologyTemplate.workflows = mutableMapOf("workflow" to workflow)
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.topologyTemplate = topologyTemplate
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.workflowStepByName("workflow", "step"))
+
+ bluePrintContext.workflowStepByName("workflow", "")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testWorkflowStepNodeTemplate() {
+ val topologyTemplate = TopologyTemplate()
+ val workflow = Workflow()
+ val step = Step()
+ step.target = "hello"
+ workflow.steps = mutableMapOf("step" to step)
+ topologyTemplate.workflows = mutableMapOf("workflow" to workflow)
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.topologyTemplate = topologyTemplate
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("hello", bluePrintContext.workflowStepNodeTemplate("workflow", "step"))
+
+ bluePrintContext.workflowStepNodeTemplate("workflow", "")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testWorkflowFirstStepNodeTemplate() {
+ val topologyTemplate = TopologyTemplate()
+ val workflow = Workflow()
+ val step = Step()
+ step.target = "hello"
+ workflow.steps = mutableMapOf("step" to step, "step2" to Step())
+ topologyTemplate.workflows = mutableMapOf("workflow" to workflow)
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.topologyTemplate = topologyTemplate
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("hello", bluePrintContext.workflowFirstStepNodeTemplate("workflow"))
+
+ workflow.steps = null
+ bluePrintContext.workflowFirstStepNodeTemplate("workflow")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testWorkflowStepFirstCallOperation() {
+ val topologyTemplate = TopologyTemplate()
+ val workflow = Workflow()
+ val step = Step()
+ val activity = Activity()
+ activity.callOperation = "hello"
+ step.activities = arrayListOf(activity)
+ workflow.steps = mutableMapOf("step" to step)
+ topologyTemplate.workflows = mutableMapOf("workflow" to workflow)
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.topologyTemplate = topologyTemplate
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("hello", bluePrintContext.workflowStepFirstCallOperation("workflow", "step"))
+
+ bluePrintContext.workflowStepFirstCallOperation("workflow", "")
+ }
+
+ @Test
+ fun testDatatypeByName() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.dataTypes = mutableMapOf("data" to DataType())
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.dataTypeByName("data"))
+ assertNull(bluePrintContext.dataTypeByName(""))
+ }
+
+ @Test
+ fun testArtifactTypes() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.artifactTypes = mutableMapOf()
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertTrue(bluePrintContext.artifactTypes()!!.isEmpty())
+
+ serviceTemplate.artifactTypes = null
+ assertNull(bluePrintContext.artifactTypes())
+ }
+
+ @Test
+ fun testPolicyTypes() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.policyTypes = mutableMapOf()
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertTrue(bluePrintContext.policyTypes()!!.isEmpty())
+
+ serviceTemplate.policyTypes = null
+ assertNull(bluePrintContext.policyTypes())
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testPolicyTypeByName() {
+ val serviceTemplate = ServiceTemplate()
+ serviceTemplate.policyTypes = mutableMapOf("policy" to PolicyType())
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.policyTypeByName("policy"))
+ bluePrintContext.policyTypeByName("")
+ }
+
+ @Test
+ fun testPolicyTypesDerivedFrom() {
+ val serviceTemplate = ServiceTemplate()
+ val policyType = PolicyType()
+ policyType.derivedFrom = "hi"
+ val policyType2 = PolicyType()
+ policyType2.derivedFrom = "hello"
+ serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals(1, bluePrintContext.policyTypesDerivedFrom("hi")!!.size)
+
+ serviceTemplate.policyTypes = null
+ assertNull(bluePrintContext.policyTypesDerivedFrom("hi"))
+ }
+
+ @Test
+ fun testPolicyTypesTarget() {
+ val serviceTemplate = ServiceTemplate()
+ val policyType = PolicyType()
+ policyType.targets = mutableListOf("hi")
+ val policyType2 = PolicyType()
+ policyType2.targets = mutableListOf()
+ serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals(1, bluePrintContext.policyTypesTarget("hi")!!.size)
+
+ serviceTemplate.policyTypes = null
+ assertNull(bluePrintContext.policyTypesTarget("hi"))
+ }
+
+ @Test
+ fun testPolicyTypesTargetNDerivedFrom() {
+ val serviceTemplate = ServiceTemplate()
+ val policyType = PolicyType()
+ policyType.targets = mutableListOf("hi")
+ policyType.derivedFrom = "hi"
+ val policyType2 = PolicyType()
+ policyType2.targets = mutableListOf()
+ policyType2.derivedFrom = "hi"
+ serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals(1, bluePrintContext.policyTypesTargetNDerivedFrom("hi", "hi")!!.size)
+
+ serviceTemplate.policyTypes = null
+ assertNull(bluePrintContext.policyTypesTargetNDerivedFrom("hi", "hi"))
+ }
+
+ @Test
+ fun testNodeTypeDerivedFrom() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeType = NodeType()
+ nodeType.derivedFrom = "hi"
+ val nodeType2 = NodeType()
+ nodeType2.derivedFrom = "hiii"
+ serviceTemplate.nodeTypes = mutableMapOf("node" to nodeType, "node2" to nodeType2)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals(1, bluePrintContext.nodeTypeDerivedFrom("hi")!!.size)
+
+ serviceTemplate.nodeTypes = null
+ assertNull(bluePrintContext.nodeTypeDerivedFrom("hi"))
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testInterfaceNameForNodeType() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeType = NodeType()
+ nodeType.interfaces = mutableMapOf("hello" to InterfaceDefinition(), "hi" to InterfaceDefinition())
+ serviceTemplate.nodeTypes = mutableMapOf("node" to nodeType)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("hello", bluePrintContext.interfaceNameForNodeType("node"))
+
+ bluePrintContext.interfaceNameForNodeType("")
+ }
+
+ @Test
+ fun testNodeTemplateForNodeType() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ nodeTemplate.type = "hello"
+ val nodeTemplate2 = NodeTemplate()
+ nodeTemplate2.type = "hi"
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate, "node2" to nodeTemplate2)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals(1, bluePrintContext.nodeTemplateForNodeType("hello")!!.size)
+
+ serviceTemplate.topologyTemplate!!.nodeTemplates = null
+ assertNull(bluePrintContext.nodeTemplateForNodeType("hello"))
+ }
+
+ @Test
+ fun testNodeTemplateProperty() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ nodeTemplate.properties = mutableMapOf("prop" to ObjectMapper().createObjectNode())
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.nodeTemplateProperty("node", "prop"))
+
+ assertNull(bluePrintContext.nodeTemplateProperty("node", ""))
+
+ nodeTemplate.properties = null
+ assertNull(bluePrintContext.nodeTemplateProperty("node", "prop"))
+ }
+
+ @Test
+ fun testNodeTemplateArtifacts() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ nodeTemplate.artifacts = mutableMapOf()
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertTrue(bluePrintContext.nodeTemplateArtifacts("node")!!.isEmpty())
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testNodeTemplateArtifact() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ nodeTemplate.artifacts = mutableMapOf("art" to ArtifactDefinition())
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.nodeTemplateArtifact("node", "art"))
+
+ bluePrintContext.nodeTemplateArtifact("node", "")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testNodeTemplateArtifactForArtifactType() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ val artifactDefinition = ArtifactDefinition()
+ artifactDefinition.type = "type"
+ val artifactDefinition2 = ArtifactDefinition()
+ artifactDefinition2.type = "No type"
+ nodeTemplate.artifacts = mutableMapOf("art" to artifactDefinition, "art2" to artifactDefinition2)
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.nodeTemplateArtifactForArtifactType("node", "type"))
+
+ bluePrintContext.nodeTemplateArtifactForArtifactType("", "")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testNodeTemplateFirstInterface() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ nodeTemplate.interfaces = mutableMapOf("interface" to InterfaceAssignment(), "interf" to InterfaceAssignment())
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.nodeTemplateFirstInterface("node"))
+
+ nodeTemplate.interfaces = null
+ bluePrintContext.nodeTemplateFirstInterface("node")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testNodeTemplateFirstInterfaceName() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ nodeTemplate.interfaces = mutableMapOf("interface" to InterfaceAssignment(), "interf" to InterfaceAssignment())
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("interface", bluePrintContext.nodeTemplateFirstInterfaceName("node"))
+
+ nodeTemplate.interfaces = null
+ bluePrintContext.nodeTemplateFirstInterfaceName("node")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testNodeTemplateFirstInterfaceFirstOperationName() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ val interfaceAssignment = InterfaceAssignment()
+ interfaceAssignment.operations = mutableMapOf("op" to OperationAssignment(), "op2" to OperationAssignment())
+ nodeTemplate.interfaces = mutableMapOf("intf" to interfaceAssignment)
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertEquals("op", bluePrintContext.nodeTemplateFirstInterfaceFirstOperationName("node"))
+
+ interfaceAssignment.operations = null
+ bluePrintContext.nodeTemplateFirstInterfaceFirstOperationName("node")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testNodeTemplateCapability() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ nodeTemplate.capabilities = mutableMapOf("cap" to CapabilityAssignment())
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.nodeTemplateCapability("node", "cap"))
+
+ bluePrintContext.nodeTemplateCapability("node", "")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testNodeTemplateRequirement() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ nodeTemplate.requirements = mutableMapOf("req" to RequirementAssignment())
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.nodeTemplateRequirement("node", "req"))
+
+ bluePrintContext.nodeTemplateRequirement("node", "")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testNodeTemplateRequirementNode() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ val requirementAssignment = RequirementAssignment()
+ requirementAssignment.node = "node"
+ nodeTemplate.requirements = mutableMapOf("req" to requirementAssignment)
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.nodeTemplateRequirementNode("node", "req"))
+
+ bluePrintContext.nodeTemplateRequirementNode("node", "")
+ }
+
+ @Test
+ fun testNodeTemplateCapabilityProperty() {
+ val serviceTemplate = ServiceTemplate()
+ val nodeTemplate = NodeTemplate()
+ val capabilityAssignment = CapabilityAssignment()
+ capabilityAssignment.properties = mutableMapOf("prop" to ObjectMapper().createObjectNode())
+ nodeTemplate.capabilities = mutableMapOf("cap" to capabilityAssignment)
+ serviceTemplate.topologyTemplate = TopologyTemplate()
+ serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate)
+ val bluePrintContext = BluePrintContext(serviceTemplate)
+
+ assertNotNull(bluePrintContext.nodeTemplateCapabilityProperty("node", "cap", "prop"))
+
+ capabilityAssignment.properties = null
+
+ assertNull(bluePrintContext.nodeTemplateCapabilityProperty("node", "cap", "prop"))
+ }
}
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml
index 64a5c12ab..2f4b0472d 100644
--- a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml
+++ b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml
@@ -18,7 +18,7 @@
<parent>
<artifactId>modules</artifactId>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blueprint-scripts</artifactId>
diff --git a/ms/controllerblueprints/modules/blueprint-validation/pom.xml b/ms/controllerblueprints/modules/blueprint-validation/pom.xml
index 12502ce78..24755ec06 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/pom.xml
+++ b/ms/controllerblueprints/modules/blueprint-validation/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>blueprint-validation</artifactId>
<name>Controller Blueprints Validation Service</name>
diff --git a/ms/controllerblueprints/modules/db-resources/pom.xml b/ms/controllerblueprints/modules/db-resources/pom.xml
index 0364800df..af0aa1aff 100644
--- a/ms/controllerblueprints/modules/db-resources/pom.xml
+++ b/ms/controllerblueprints/modules/db-resources/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>db-resources</artifactId>
<name>Controller Blueprints DB Resources</name>
diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml
index c4d1b1d37..3310c3824 100644
--- a/ms/controllerblueprints/modules/pom.xml
+++ b/ms/controllerblueprints/modules/pom.xml
@@ -15,13 +15,12 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>modules</artifactId>
diff --git a/ms/controllerblueprints/modules/resource-dict/pom.xml b/ms/controllerblueprints/modules/resource-dict/pom.xml
index 3f4f762b0..5892f52cf 100644
--- a/ms/controllerblueprints/modules/resource-dict/pom.xml
+++ b/ms/controllerblueprints/modules/resource-dict/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>resource-dict</artifactId>
<name>Controller Blueprints Resource Dictionary</name>
diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml
index 40a5c259d..79b3bb980 100644
--- a/ms/controllerblueprints/modules/service/pom.xml
+++ b/ms/controllerblueprints/modules/service/pom.xml
@@ -18,13 +18,12 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>modules</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>service</artifactId>
<name>Controller Blueprints Service</name>
diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml
index 276c4001b..236dcc1dc 100644
--- a/ms/controllerblueprints/parent/pom.xml
+++ b/ms/controllerblueprints/parent/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>controllerblueprints</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>parent</artifactId>
diff --git a/ms/controllerblueprints/pom.xml b/ms/controllerblueprints/pom.xml
index 2e361acd5..211110627 100644
--- a/ms/controllerblueprints/pom.xml
+++ b/ms/controllerblueprints/pom.xml
@@ -18,13 +18,13 @@
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>ms</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>controllerblueprints</artifactId>
<name>Controller Blueprints Root</name>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<properties>
<service.name>ControllerBlueprints</service.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/ms/pom.xml b/ms/pom.xml
index b97ebc03f..4bd744c9c 100644
--- a/ms/pom.xml
+++ b/ms/pom.xml
@@ -14,19 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>ms</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Micro-services Root</name>
diff --git a/ms/sdclistener/application/pom.xml b/ms/sdclistener/application/pom.xml
index 5513279cc..62191b185 100644
--- a/ms/sdclistener/application/pom.xml
+++ b/ms/sdclistener/application/pom.xml
@@ -1,23 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- ~ Copyright (C) 2019 Bell Canada. All rights reserved.
+ ~ Copyright © 2019 Bell Canada.
~
- ~ NOTICE: All the intellectual and technical concepts contained herein are
- ~ proprietary to Bell Canada and are protected by trade secret or copyright law.
- ~ Unauthorized copying of this file, via any medium is strictly prohibited.
+ ~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds.sdclistener</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>application</artifactId>
<packaging>jar</packaging>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<name>SDC Listener Application</name>
<properties>
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java
index eb339aef7..d5f156e55 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerNotificationCallback.java
@@ -21,10 +21,10 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Objects;
-import java.util.Optional;
import org.onap.ccsdk.cds.sdclistener.dto.SdcListenerDto;
import org.onap.ccsdk.cds.sdclistener.service.ListenerService;
import org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus;
+import org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.NotificationType;
import org.onap.ccsdk.cds.sdclistener.util.FileUtil;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.consumer.INotificationCallback;
@@ -81,7 +81,9 @@ public class SdcListenerNotificationCallback implements INotificationCallback {
*/
private void downloadCsarArtifacts(IArtifactInfo info, IDistributionClient distributionClient) {
final String url = info.getArtifactURL();
+ sdcListenerDto.setArtifactUrl(url);
final String id = info.getArtifactUUID();
+ final String distributionId = sdcListenerDto.getDistributionId();
if (Objects.equals(info.getArtifactType(), SdcListenerConfiguration.TOSCA_CSAR)) {
LOGGER.info("Trying to download the artifact from : {} and UUID is {} ", url, id);
@@ -90,38 +92,38 @@ public class SdcListenerNotificationCallback implements INotificationCallback {
IDistributionClientDownloadResult result = distributionClient.download(info);
if (!Objects.equals(result.getDistributionActionResult(), SUCCESS)) {
- String errorMessage = String.format("Failed to download the artifact from : %s due to %s ", url,
+ final String errorMessage = String.format("Failed to download the artifact from : %s due to %s ", url,
result.getDistributionActionResult());
- listenerStatus.sendResponseStatusBackToSDC(sdcListenerDto.getDistributionId(),
- DistributionStatusEnum.COMPONENT_DONE_ERROR, errorMessage);
+ listenerStatus
+ .sendResponseBackToSdc(distributionId, DistributionStatusEnum.DOWNLOAD_ERROR, errorMessage,
+ url, NotificationType.DOWNLOAD);
LOGGER.error(errorMessage);
} else {
+ listenerStatus.sendResponseBackToSdc(distributionId, DistributionStatusEnum.DOWNLOAD_OK, null, url,
+ NotificationType.DOWNLOAD);
LOGGER.info("Trying to write CSAR artifact to file with URL {} and UUID {}", url, id);
processCsarArtifact(result);
}
}
}
- public void processCsarArtifact(IDistributionClientDownloadResult result) {
+ private void processCsarArtifact(IDistributionClientDownloadResult result) {
Path cbaArchivePath = Paths.get(pathToStoreArchives, "cba-archive");
Path csarArchivePath = Paths.get(pathToStoreArchives, "csar-archive");
// Extract and store the CSAR archive into local disk.
- listenerService.extractCsarAndStore(result, csarArchivePath.toString());
+ listenerService.extractCsarAndStore(result, csarArchivePath);
- Optional<List<File>> csarFiles = FileUtil.getFilesFromDisk(csarArchivePath);
+ List<File> csarFiles = FileUtil.getFilesFromDisk(csarArchivePath);
- if (csarFiles.isPresent()) {
- //Extract CBA archive from CSAR package and store it into local disk.
- List<File> files = csarFiles.get();
+ if (!csarFiles.isEmpty()) {
+ final String archivePath = cbaArchivePath.toString();
- if (!files.isEmpty()) {
- final String archivePath = cbaArchivePath.toString();
- files.forEach(file -> listenerService.extractBluePrint(file.getAbsolutePath(), archivePath));
- files.forEach(file -> FileUtil.deleteFile(file, archivePath));
- } else {
- LOGGER.error("The CSAR file is not present at this location {}", csarArchivePath);
- }
+ //Extract CBA archive from CSAR package and store it into local disk
+ csarFiles.forEach(file -> listenerService.extractBluePrint(file.getAbsolutePath(), archivePath));
+ csarFiles.forEach(file -> FileUtil.deleteFile(file, csarArchivePath.toString()));
+ } else {
+ LOGGER.error("Could not able to read CSAR files from this location {}", csarArchivePath);
}
listenerService.saveBluePrintToCdsDatabase(cbaArchivePath, sdcListenerDto.getManagedChannelForGrpc());
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java
index 6f782d10a..5866a63e0 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/client/SdcListenerAuthClientInterceptor.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onap.ccsdk.cds.sdclistener.client;
import io.grpc.CallOptions;
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java
index a9e51ac12..44245752f 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/controller/HealthCheck.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onap.ccsdk.cds.sdclistener.controller;
import org.springframework.http.MediaType;
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java
index c7c3d4829..a59022c3f 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/dto/SdcListenerDto.java
@@ -34,6 +34,8 @@ public class SdcListenerDto {
@Value("${listenerservice.config.grpcPort}")
private int grpcPort;
+ private String artifactUrl;
+
@Autowired
private SdcListenerAuthClientInterceptor sdcListenerAuthClientInterceptor;
@@ -67,4 +69,12 @@ public class SdcListenerDto {
public ManagedChannel getManagedChannelForGrpc() {
return managedChannel;
}
+
+ public String getArtifactUrl() {
+ return artifactUrl;
+ }
+
+ public void setArtifactUrl(String artifactUrl) {
+ this.artifactUrl = artifactUrl;
+ }
}
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java
index 446c3e621..bc72c8f98 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerService.java
@@ -43,5 +43,5 @@ public interface ListenerService {
* @param result - IDistributionClientDownloadResult contains payload.
* @param csarArchivePath The destination path where CSAR will be stored.
*/
- void extractCsarAndStore(IDistributionClientDownloadResult result, String csarArchivePath);
+ void extractCsarAndStore(IDistributionClientDownloadResult result, Path csarArchivePath);
}
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java
index 9a6ae8779..148d0c028 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2019 AT&T, Bell Canada
+ * Copyright © 2019 Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onap.ccsdk.cds.sdclistener.service;
-import static java.nio.file.Files.walk;
+import static java.lang.String.format;
+import static org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.NotificationType.SDC_LISTENER_COMPONENT;
import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_ERROR;
import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK;
import com.google.protobuf.ByteString;
@@ -31,20 +31,19 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.List;
-import java.util.Optional;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.commons.io.FileUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput;
+import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk;
import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor;
import org.onap.ccsdk.cds.sdclistener.dto.SdcListenerDto;
import org.onap.ccsdk.cds.sdclistener.handler.BluePrintProcesssorHandler;
import org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus;
import org.onap.ccsdk.cds.sdclistener.util.FileUtil;
-import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
-import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput;
-import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,12 +74,15 @@ public class ListenerServiceImpl implements ListenerService {
@Value("${listenerservice.config.grpcPort}")
private int grpcPort;
- private static final String CBA_ZIP_PATH = "Artifacts/Resources/[a-zA-Z0-9-_]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_]+[.]zip";
+ private static final String CBA_ZIP_PATH = "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip";
private static final int SUCCESS_CODE = 200;
private static final Logger LOGGER = LoggerFactory.getLogger(ListenerServiceImpl.class);
@Override
public void extractBluePrint(String csarArchivePath, String cbaArchivePath) {
+ int validPathCount = 0;
+ final String distributionId = getDistributionId();
+ final String artifactUrl = getArtifactUrl();
Path cbaStorageDir = getStorageDirectory(cbaArchivePath);
try (ZipFile zipFile = new ZipFile(csarArchivePath)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
@@ -88,14 +90,26 @@ public class ListenerServiceImpl implements ListenerService {
ZipEntry entry = entries.nextElement();
String fileName = entry.getName();
if (Pattern.matches(CBA_ZIP_PATH, fileName)) {
+ validPathCount++;
final String cbaArchiveName = Paths.get(fileName).getFileName().toString();
LOGGER.info("Storing the CBA archive {}", cbaArchiveName);
storeBluePrint(zipFile, cbaArchiveName, cbaStorageDir, entry);
}
}
+ if (validPathCount == 0) {
+ LOGGER
+ .info("CBA archive doesn't exist in the CSAR Package or it doesn't exist as per the given path {}",
+ CBA_ZIP_PATH);
+ listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_OK, null,
+ artifactUrl, SDC_LISTENER_COMPONENT);
+ }
+
} catch (Exception e) {
- LOGGER.error("Failed to extract blueprint {}", e);
+ final String errorMessage = format("Failed to extract blueprint %s", e.getMessage());
+ listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_ERROR, errorMessage,
+ artifactUrl, SDC_LISTENER_COMPONENT);
+ LOGGER.error(errorMessage);
}
}
@@ -121,15 +135,17 @@ public class ListenerServiceImpl implements ListenerService {
@Override
public void saveBluePrintToCdsDatabase(Path cbaArchivePath, ManagedChannel channel) {
- Optional<List<File>> zipFiles = FileUtil.getFilesFromDisk(cbaArchivePath);
- zipFiles.ifPresent(files -> prepareRequestForCdsBackend(files, channel, cbaArchivePath.toString()));
+ List<File> zipFiles = FileUtil.getFilesFromDisk(cbaArchivePath);
+ if (!zipFiles.isEmpty()) {
+ prepareRequestForCdsBackend(zipFiles, channel, cbaArchivePath.toString());
+ }
}
@Override
- public void extractCsarAndStore(IDistributionClientDownloadResult result, String csarArchivePath) {
+ public void extractCsarAndStore(IDistributionClientDownloadResult result, Path csarArchivePath) {
// Create CSAR storage directory
- Path csarStorageDir = getStorageDirectory(csarArchivePath);
+ Path csarStorageDir = getStorageDirectory(csarArchivePath.toString());
byte[] payload = result.getArtifactPayload();
String csarFileName = result.getArtifactFilename();
Path targetLocation = csarStorageDir.resolve(csarFileName);
@@ -140,8 +156,11 @@ public class ListenerServiceImpl implements ListenerService {
try (FileOutputStream outFile = new FileOutputStream(targetCsarFile)) {
outFile.write(payload, 0, payload.length);
+ if (!csarArchivePath.toFile().exists()) {
+ LOGGER.error("Could not able to store the CSAR at this location {}", csarArchivePath);
+ }
} catch (Exception e) {
- LOGGER.error("Failed to put CSAR file into target location {}, {}", targetLocation, e);
+ LOGGER.error("Fail to write the data into FileOutputStream {}, {}", targetLocation, e);
}
}
@@ -159,44 +178,51 @@ public class ListenerServiceImpl implements ListenerService {
}
private void prepareRequestForCdsBackend(List<File> files, ManagedChannel managedChannel, String path) {
- final String distributionId = sdcListenerDto.getDistributionId();
+ final String distributionId = getDistributionId();
+ final String artifactUrl = getArtifactUrl();
files.forEach(zipFile -> {
try {
- final BluePrintUploadInput request = generateBluePrintUploadInputBuilder(zipFile);
+ final BluePrintUploadInput request = generateBluePrintUploadInputBuilder(zipFile, path);
// Send request to CDS Backend.
final Status responseStatus = bluePrintProcesssorHandler.sendRequest(request, managedChannel);
if (responseStatus.getCode() != SUCCESS_CODE) {
- final String errorMessage = String.format("Failed to store the CBA archive into CDS DB due to %s",
+ final String errorMessage = format("Failed to store the CBA archive into CDS DB due to %s",
responseStatus.getErrorMessage());
- listenerStatus.sendResponseStatusBackToSDC(distributionId,
- COMPONENT_DONE_ERROR, errorMessage);
+ listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_ERROR, errorMessage, artifactUrl,
+ SDC_LISTENER_COMPONENT);
LOGGER.error(errorMessage);
-
} else {
LOGGER.info(responseStatus.getMessage());
- listenerStatus.sendResponseStatusBackToSDC(distributionId,
- COMPONENT_DONE_OK, null);
+ listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_OK, null, artifactUrl,
+ SDC_LISTENER_COMPONENT);
}
} catch (Exception e) {
- final String errorMessage = String.format("Failure due to %s", e.getMessage());
- listenerStatus.sendResponseStatusBackToSDC(distributionId, COMPONENT_DONE_ERROR, errorMessage);
- LOGGER.error("Failure due to {}", e);
- } finally {
- FileUtil.deleteFile(zipFile, path);
+ final String errorMessage = format("Failure due to %s", e.getMessage());
+ listenerStatus.sendResponseBackToSdc(distributionId, COMPONENT_DONE_ERROR, errorMessage, artifactUrl,
+ SDC_LISTENER_COMPONENT);
+ LOGGER.error(errorMessage);
}
});
}
- private BluePrintUploadInput generateBluePrintUploadInputBuilder(File file) throws IOException {
+ private BluePrintUploadInput generateBluePrintUploadInputBuilder(File file, String path) throws IOException {
byte[] bytes = FileUtils.readFileToByteArray(file);
FileChunk fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(bytes)).build();
-
+ FileUtil.deleteFile(file, path);
return BluePrintUploadInput.newBuilder()
.setFileChunk(fileChunk)
.build();
}
+
+ private String getDistributionId() {
+ return sdcListenerDto.getDistributionId();
+ }
+
+ private String getArtifactUrl() {
+ return sdcListenerDto.getArtifactUrl();
+ }
}
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/DistributionStatusMessage.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessage.java
index 60463762b..7a959692a 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/DistributionStatusMessage.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessage.java
@@ -15,10 +15,11 @@
*/
package org.onap.ccsdk.cds.sdclistener.status;
-import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
+import org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
+import org.onap.sdc.api.consumer.IDistributionStatusMessage;
import org.onap.sdc.utils.DistributionStatusEnum;
-public class DistributionStatusMessage implements IFinalDistrStatusMessage {
+public class ComponentStatusMessage implements IComponentDoneStatusMessage, IDistributionStatusMessage {
public String componentName;
@@ -28,17 +29,16 @@ public class DistributionStatusMessage implements IFinalDistrStatusMessage {
public DistributionStatusEnum status;
+ public long timeStamp;
+
+ public String artifactUrl;
+
@Override
public String getDistributionID() {
return distributionID;
}
@Override
- public long getTimestamp() {
- return 0;
- }
-
- @Override
public DistributionStatusEnum getStatus() {
return status;
}
@@ -52,4 +52,14 @@ public class DistributionStatusMessage implements IFinalDistrStatusMessage {
public String getComponentName() {
return componentName;
}
+
+ @Override
+ public String getArtifactURL() {
+ return artifactUrl;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return timeStamp;
+ }
}
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java
index ff64c0d0c..446fdc068 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java
@@ -20,7 +20,8 @@ import java.util.Objects;
import org.onap.ccsdk.cds.sdclistener.dto.SdcListenerDto;
import org.onap.ccsdk.cds.sdclistener.util.BuilderUtil;
import org.onap.sdc.api.IDistributionClient;
-import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
+import org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
+import org.onap.sdc.api.consumer.IDistributionStatusMessage;
import org.onap.sdc.api.results.IDistributionClientResult;
import org.onap.sdc.utils.DistributionStatusEnum;
import org.slf4j.Logger;
@@ -45,32 +46,62 @@ public class SdcListenerStatus {
@Autowired
private SdcListenerDto sdcListenerDto;
+ public enum NotificationType {
+ DOWNLOAD, SDC_LISTENER_COMPONENT;
+ }
+
/**
- * Send the response back to SDC.
- *
+ * Send the component status back to SDC.
* @param distributionID SDC Distribution ID
* @param status Distribution status
- * @param errorReason Reason of failure
+ * @param errorReason Reason of failure if present
+ * @param url Artifact URL
+ * @param type - NotificationType(Download or Component)
*/
- public void sendResponseStatusBackToSDC(String distributionID, DistributionStatusEnum status, String errorReason) {
-
+ public void sendResponseBackToSdc(String distributionID, DistributionStatusEnum status, String errorReason,
+ String url, NotificationType type) {
final IDistributionClient distributionClient = sdcListenerDto.getDistributionClient();
- IFinalDistrStatusMessage finalDistribution = new BuilderUtil<>(new DistributionStatusMessage())
- .build(builder -> {
- builder.distributionID = distributionID;
- builder.status = status;
- builder.consumerID = consumerId;
- builder.componentName = COMPONENT_NAME;
- }).create();
+ switch (type) {
+ case SDC_LISTENER_COMPONENT:
+ IComponentDoneStatusMessage componentStatusMessage = buildStatusMessage(distributionID, status, url,
+ COMPONENT_NAME);
- if (errorReason == null) {
- checkResponseStatusFromSdc(distributionClient.sendFinalDistrStatus(finalDistribution));
- } else {
- checkResponseStatusFromSdc(distributionClient.sendFinalDistrStatus(finalDistribution, errorReason));
+ if (errorReason == null) {
+ checkResponseStatusFromSdc(distributionClient.sendComponentDoneStatus(componentStatusMessage));
+ } else {
+ checkResponseStatusFromSdc(
+ distributionClient.sendComponentDoneStatus(componentStatusMessage, errorReason));
+ }
+ break;
+
+ case DOWNLOAD:
+ IDistributionStatusMessage downloadStatusMessage = buildStatusMessage(distributionID, status, url,
+ null);
+
+ if (errorReason == null) {
+ checkResponseStatusFromSdc(distributionClient.sendDownloadStatus(downloadStatusMessage));
+ } else {
+ checkResponseStatusFromSdc(
+ distributionClient.sendDownloadStatus(downloadStatusMessage, errorReason));
+ }
+ default:
+ break;
}
}
+ private ComponentStatusMessage buildStatusMessage(String distributionId, DistributionStatusEnum status, String url,
+ String componentName) {
+ return new BuilderUtil<>(new ComponentStatusMessage()).build(builder -> {
+ builder.distributionID = distributionId;
+ builder.status = status;
+ builder.consumerID = consumerId;
+ builder.componentName = componentName;
+ builder.timeStamp = System.currentTimeMillis();
+ builder.artifactUrl = url;
+ }).create();
+ }
+
private void checkResponseStatusFromSdc(IDistributionClientResult result) {
if (!Objects.equals(result.getDistributionActionResult(), SUCCESS)) {
LOGGER.error("SDC failed to receive the response from cds-sdc listener due to {}",
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/BuilderUtil.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/BuilderUtil.java
index 1f546d107..a5c4a5c16 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/BuilderUtil.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/BuilderUtil.java
@@ -1,9 +1,17 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
package org.onap.ccsdk.cds.sdclistener.util;
diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java
index 967e854d7..b6d0e4809 100644
--- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java
+++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/util/FileUtil.java
@@ -1,11 +1,18 @@
/*
- * Copyright (C) 2019 Bell Canada. All rights reserved.
+ * Copyright © 2019 Bell Canada
*
- * NOTICE: All the intellectual and technical concepts contained herein are
- * proprietary to Bell Canada and are protected by trade secret or copyright law.
- * Unauthorized copying of this file, via any medium is strictly prohibited.
+ * 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.
*/
-
package org.onap.ccsdk.cds.sdclistener.util;
import static java.nio.file.Files.walk;
@@ -13,8 +20,8 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.io.FileUtils;
@@ -47,15 +54,16 @@ public final class FileUtil {
* @param path where files reside.
* @return list of files.
*/
- public static Optional<List<File>> getFilesFromDisk(Path path) {
+ public static List<File> getFilesFromDisk(Path path) {
+
try (Stream<Path> fileTree = walk(path)) {
// Get the list of files from the path
- return Optional.of(fileTree.filter(Files::isRegularFile)
- .map(Path::toFile)
- .collect(Collectors.toList()));
+ return fileTree.filter(Files::isRegularFile)
+ .map(Path::toFile)
+ .collect(Collectors.toList());
} catch (IOException e) {
LOGGER.error("Failed to find the file due to", e);
}
- return Optional.empty();
+ return new ArrayList<>();
}
}
diff --git a/ms/sdclistener/application/src/main/resources/application.yml b/ms/sdclistener/application/src/main/resources/application.yaml
index b3f8443eb..b3f8443eb 100644
--- a/ms/sdclistener/application/src/main/resources/application.yml
+++ b/ms/sdclistener/application/src/main/resources/application.yaml
diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java
index f5ff2bdb8..aa8f8e4e8 100644
--- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java
+++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java
@@ -16,6 +16,8 @@
package org.onap.ccsdk.cds.sdclistener.service;
import static junit.framework.TestCase.assertTrue;
+import static org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.NotificationType.SDC_LISTENER_COMPONENT;
+import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -27,6 +29,10 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
import org.onap.ccsdk.cds.sdclistener.SdcListenerConfiguration;
import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor;
import org.onap.ccsdk.cds.sdclistener.dto.SdcListenerDto;
@@ -37,6 +43,7 @@ import org.onap.sdc.impl.mock.DistributionClientResultStubImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@@ -46,40 +53,73 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest(classes = {ListenerServiceImplTest.class})
public class ListenerServiceImplTest {
- private static final String CSAR_SAMPLE = "src/test/resources/service-Testsvc140.csar";
+ private static final String CSAR_SAMPLE = "src/test/resources/service-ServicePnfTest-csar.csar";
+ private static final String WRONG_CSAR_SAMPLE = "src/test/resources/wrong_csar_pattern.csar";
+ private static final String CBA_ZIP_PATH = "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip";
private static final String ZIP_FILE = ".zip";
private static final String CSAR_FILE = ".csar";
+ private static final String DISTRIBUTION_ID = "1";
+ private static final String URL = "/sdc/v1/artifact";
+
+
private String csarArchivePath;
private Path tempDirectoryPath;
@Rule
public TemporaryFolder folder = new TemporaryFolder();
+ @Rule
+ public MockitoRule mockitoRule = MockitoJUnit.rule();
+
@Autowired
private ListenerServiceImpl listenerService;
+ @MockBean
+ SdcListenerStatus status;
+
+ @MockBean
+ SdcListenerDto listenerDto;
+
@Before
public void setup() {
+ MockitoAnnotations.initMocks(this);
csarArchivePath = folder.getRoot().toString();
tempDirectoryPath = Paths.get(csarArchivePath, "cds-sdc-listener-test");
}
+
@Test
public void extractBluePrintSuccessfully() throws IOException {
// Act
listenerService.extractBluePrint(CSAR_SAMPLE, tempDirectoryPath.toString());
- // Verify
+ // Verify.
String result = checkFileExists(tempDirectoryPath);
assertTrue(result.contains(ZIP_FILE));
}
@Test
+ public void extractBluePrintFailure() {
+ // Arrange
+ Mockito.when(listenerDto.getDistributionId()).thenReturn(DISTRIBUTION_ID);
+ Mockito.when(listenerDto.getArtifactUrl()).thenReturn(URL);
+ Mockito.doCallRealMethod().when(status)
+ .sendResponseBackToSdc(DISTRIBUTION_ID, COMPONENT_DONE_OK, null, URL, SDC_LISTENER_COMPONENT);
+
+ // Act
+ listenerService.extractBluePrint(WRONG_CSAR_SAMPLE, tempDirectoryPath.toString());
+
+ // Verify
+ Mockito.verify(status)
+ .sendResponseBackToSdc(DISTRIBUTION_ID, COMPONENT_DONE_OK, null, URL, SDC_LISTENER_COMPONENT);
+ }
+
+ @Test
public void storeCsarArtifactToFileSuccessfully() throws IOException {
// Arrange
DistributionClientDownloadResultStubImpl resultStub = new DistributionClientDownloadResultStubImpl();
// Act
- listenerService.extractCsarAndStore(resultStub, tempDirectoryPath.toString());
+ listenerService.extractCsarAndStore(resultStub, tempDirectoryPath);
// Verify
String result = checkFileExists(tempDirectoryPath);
diff --git a/ms/sdclistener/application/src/test/resources/service-ServicePnfTest-csar.csar b/ms/sdclistener/application/src/test/resources/service-ServicePnfTest-csar.csar
new file mode 100644
index 000000000..62a77dcaf
--- /dev/null
+++ b/ms/sdclistener/application/src/test/resources/service-ServicePnfTest-csar.csar
Binary files differ
diff --git a/ms/sdclistener/application/src/test/resources/service-Testsvc140.csar b/ms/sdclistener/application/src/test/resources/service-Testsvc140.csar
deleted file mode 100644
index 4aa0de72b..000000000
--- a/ms/sdclistener/application/src/test/resources/service-Testsvc140.csar
+++ /dev/null
Binary files differ
diff --git a/ms/sdclistener/application/src/test/resources/wrong_csar_pattern.csar b/ms/sdclistener/application/src/test/resources/wrong_csar_pattern.csar
new file mode 100644
index 000000000..ee18b580d
--- /dev/null
+++ b/ms/sdclistener/application/src/test/resources/wrong_csar_pattern.csar
Binary files differ
diff --git a/ms/sdclistener/distribution/pom.xml b/ms/sdclistener/distribution/pom.xml
index a79a14c52..af0114973 100755
--- a/ms/sdclistener/distribution/pom.xml
+++ b/ms/sdclistener/distribution/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.ccsdk.cds.sdclistener</groupId>
<artifactId>parent</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>distribution</artifactId>
diff --git a/ms/sdclistener/parent/pom.xml b/ms/sdclistener/parent/pom.xml
index fabdc2530..695d5e86e 100755
--- a/ms/sdclistener/parent/pom.xml
+++ b/ms/sdclistener/parent/pom.xml
@@ -16,13 +16,12 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>sdclistener</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</parent>
<groupId>org.onap.ccsdk.cds.sdclistener</groupId>
<artifactId>parent</artifactId>
@@ -35,7 +34,6 @@
<grpc.version>1.18.0</grpc.version>
<protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
<eelf.version>1.0.0</eelf.version>
- <sli.version>0.4.2-SNAPSHOT</sli.version>
<guava.version>27.0.1-jre</guava.version>
<onap.logger.slf4j>1.2.2</onap.logger.slf4j>
<powermock.version>1.7.4</powermock.version>
diff --git a/ms/sdclistener/pom.xml b/ms/sdclistener/pom.xml
index 70e8529f6..6aeb5484e 100644
--- a/ms/sdclistener/pom.xml
+++ b/ms/sdclistener/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>ms</artifactId>
- <version>0.4.2-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>