summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/pom.xml63
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/pom.xml31
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt39
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt79
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt49
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt49
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt48
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt50
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java88
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json35
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json27
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json26
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json15
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json22
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json18
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json22
16 files changed, 661 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml
new file mode 100644
index 000000000..50ea7b0e7
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2017-2018 AT&T Intellectual Property.
+ ~
+ ~ 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">
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <relativePath>../parent</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
+ <artifactId>functions</artifactId>
+ <name>Blueprints Processor Functions POM</name>
+ <description>Blueprints Processor Functions POM</description>
+ <modules>
+ <module>resource-resolution</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>execution-service</artifactId>
+ </dependency>
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
new file mode 100644
index 000000000..a2d3bb85e
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2017-2018 AT&T Intellectual Property.
+ ~
+ ~ 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.apps.blueprintsprocessor</groupId>
+ <artifactId>functions</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>resource-resolution</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor Resolution Service</name>
+ <description>Blueprints Processor Resolution Service</description>
+
+</project>
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
new file mode 100644
index 000000000..ff1a01d58
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.apps.blueprintsprocessor.services.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode
+import org.springframework.stereotype.Component
+
+@Component("component-resource-resolution")
+open class ResourceResolutionComponent : ComponentNode {
+ override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
new file mode 100644
index 000000000..3ee7e41ff
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.apps.blueprintsprocessor.services.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
+import org.springframework.stereotype.Service
+
+/**
+ * ResourceResolutionService
+ * @author Brinda Santh
+ * 8/14/2018
+ */
+
+@Service
+class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {
+
+ fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
+ val resourceResolutionOutput = ResourceResolutionOutput()
+ resourceResolutionOutput.actionIdentifiers = resourceResolutionInput.actionIdentifiers
+ resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
+ resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
+
+ val context = hashMapOf<String, Any>()
+
+ process(resourceResolutionOutput.resourceAssignments, context)
+
+ val status = Status()
+ status.code = 200
+ status.message = "Success"
+ resourceResolutionOutput.status = status
+
+ return resourceResolutionOutput
+ }
+
+ fun process(resourceAssignments: MutableList<ResourceAssignment>, context: MutableMap<String, Any>): Unit {
+
+ val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
+
+ bulkSequenced.map { batchResourceAssignments ->
+ batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
+ .map { resourceAssignment ->
+ val dictionarySource = resourceAssignment.dictionarySource
+ val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource)
+ val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName)
+ ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
+ "for resource assignment(${resourceAssignment.name})")
+ try {
+ resourceAssignmentProcessor.validate(resourceAssignment, context)
+ resourceAssignmentProcessor.process(resourceAssignment, context)
+ } catch (e: Exception) {
+ resourceAssignmentProcessor.errorHandle(resourceAssignment, context)
+ throw BluePrintProcessorException(e)
+ }
+
+ }
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
new file mode 100644
index 000000000..9580ca49a
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.apps.blueprintsprocessor.services.resolution.processor
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
+import org.springframework.stereotype.Service
+
+/**
+ * DefaultResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-default")
+open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor {
+ private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Processing Resource Assignments")
+ }
+
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
+ }
+
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
new file mode 100644
index 000000000..05f7d5cdd
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.apps.blueprintsprocessor.services.resolution.processor
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
+import org.springframework.stereotype.Service
+
+/**
+ * InputResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-input")
+open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor {
+ private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Processing Resource Assignments")
+ }
+
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
+ }
+
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt
new file mode 100644
index 000000000..9d54cd46a
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * 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.apps.blueprintsprocessor.services.resolution.processor
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
+import org.springframework.stereotype.Service
+
+/**
+ * MDSALResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-mdsal")
+open class MDSALResourceAssignmentProcessor : ResourceAssignmentProcessor {
+ private val log = EELFManager.getInstance().getLogger(MDSALResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Processing Resource Assignments")
+ }
+
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
+ }
+
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt
new file mode 100644
index 000000000..4b11f580e
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * 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.apps.blueprintsprocessor.services.resolution.processor
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
+import org.springframework.stereotype.Service
+
+/**
+ * SdncResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-db")
+open class SdncResourceAssignmentProcessor : ResourceAssignmentProcessor {
+
+ private val log = EELFManager.getInstance().getLogger(SdncResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Processing Resource Assignments")
+ }
+
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
+ }
+
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java b/ms/blueprintsprocessor/functions/resource-resolution/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java
new file mode 100644
index 000000000..0768c6099
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.apps.blueprintsprocessor.services.resolution;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.MDSALResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SdncResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.io.File;
+import java.nio.charset.Charset;
+import java.util.List;
+
+/**
+ * ResourceResolutionServiceTest
+ *
+ * @author Brinda Santh DATE : 8/15/2018
+ */
+@RunWith(SpringRunner.class)
+@ContextConfiguration(classes = {ResourceResolutionService.class, ResourceAssignmentProcessorFactory.class,
+ InputResourceAssignmentProcessor.class, DefaultResourceAssignmentProcessor.class,
+ SdncResourceAssignmentProcessor.class, MDSALResourceAssignmentProcessor.class})
+public class ResourceResolutionServiceTest {
+ private static Logger log = LoggerFactory.getLogger(ResourceResolutionServiceTest.class);
+
+ @Autowired
+ private ResourceResolutionService resourceResolutionService;
+
+ @Test
+ public void testResolveResource() throws Exception {
+
+ Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService);
+
+ String resourceResolutionInputContent = FileUtils.readFileToString(
+ new File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset());
+
+ ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class);
+ Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput);
+
+ String resourceAssignmentContent = FileUtils.readFileToString(
+ new File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset());
+ List<ResourceAssignment> batchResourceAssignment =
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);
+
+ Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment));
+ resourceResolutionInput.setResourceAssignments(batchResourceAssignment);
+
+ ObjectNode inputContent = (ObjectNode) JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");
+ Assert.assertNotNull("failed to populate input payload ", inputContent);
+ resourceResolutionInput.setPayload(inputContent);
+ log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true));
+
+ ResourceResolutionOutput resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput);
+ Assert.assertNotNull("failed to populate output", resourceResolutionOutput);
+
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json
new file mode 100644
index 000000000..679b92db4
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json
@@ -0,0 +1,35 @@
+{
+ "locations": {
+ "name": "locations",
+ "data-type": "list",
+ "entry-schema": "dt-location",
+ "source": {
+ "db": {
+ "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
+ "input-key-mapping": {
+ "profile_name": "profile_name"
+ },
+ "output-key-mapping": {
+ "db-country": "country",
+ "db-state": "state"
+ }
+ }
+ },
+ "candidate-dependency": {
+ "db": {
+ "names": [
+ "profile_name"
+ ]
+ }
+ }
+ },
+ "profile_name": {
+ "name": "profile_name",
+ "data-type": "string",
+ "source": {
+ "input": {
+
+ }
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json
new file mode 100644
index 000000000..32d04b690
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json
@@ -0,0 +1,27 @@
+{
+ "location": {
+ "name": "location",
+ "data-type": "dt-location",
+ "source": {
+ "db": {
+ "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
+ "input-key-mapping": {
+ "profile_name": "profile_name"
+ },
+ "output-key-mapping": {
+ "db-country": "country",
+ "db-state": "state"
+ }
+ }
+ }
+ },
+ "profile_name": {
+ "name": "profile_name",
+ "data-type": "string",
+ "source": {
+ "input": {
+
+ }
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json
new file mode 100644
index 000000000..841404f22
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json
@@ -0,0 +1,26 @@
+{
+ "country": {
+ "name": "country",
+ "data-type": "string",
+ "source": {
+ "db": {
+ "query": "SELECT country FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
+ "input-key-mapping": {
+ "profile_name": "profile_name"
+ },
+ "output-key-mapping": {
+ "country": "country"
+ }
+ }
+ }
+ },
+ "profile_name": {
+ "name": "profile_name",
+ "data-type": "string",
+ "source": {
+ "input": {
+
+ }
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json
new file mode 100644
index 000000000..52e0a7967
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json
@@ -0,0 +1,15 @@
+{
+ "version": "1.0.0",
+ "description": "test Data Type",
+ "properties": {
+ "country": {
+ "required": true,
+ "type": "string"
+ },
+ "state": {
+ "required": false,
+ "type": "string"
+ }
+ },
+ "derived_from": "tosca.datatypes.Root"
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json
new file mode 100644
index 000000000..ddcf32eed
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json
@@ -0,0 +1,22 @@
+[
+ {
+ "name": "country",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "country",
+ "dictionary-source": "db",
+ "dependencies": ["state"]
+ },
+ {
+ "name": "state",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "state",
+ "dictionary-source": "input",
+ "dependencies": []
+ }
+]
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json
new file mode 100644
index 000000000..cd6fac128
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json
@@ -0,0 +1,18 @@
+{
+ "api-ver": "2.00",
+ "originator-id": "MSO",
+ "request-id": "123456",
+ "service-instance-id": "ibcx0001vm001",
+ "service-type": "AVPN",
+ "vnf-type": "vUSP - vDBE-IPX HUB",
+ "vnf-id": 123456,
+ "service-template-name": "VRR-baseconfiguration",
+ "service-template-version": "1.0.0",
+ "action-name": "resource-assignment-action",
+ "group-name": "sample group name",
+ "bundle-id": "sample bundle id",
+ "bundle-mac": [
+ "Sample bundle mac",
+ "Sample bundle mac"
+ ]
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
new file mode 100644
index 000000000..e8830a8a2
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
@@ -0,0 +1,22 @@
+{
+ "actionIdentifiers": {
+ "actionName": "sample-action",
+ "blueprintName": "sample-blurprint",
+ "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": {
+ },
+ "resourceAssignments": [
+ ]
+}