summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2018-09-11 20:55:46 -0400
committerBrinda Santh <brindasanth@in.ibm.com>2018-09-11 20:55:46 -0400
commitf887437d17c600814e088402350f2724d0fa9bc7 (patch)
treea39e7dd53b700a71cf96f79cad8b4a4ae16c308a /ms/blueprintsprocessor/modules/services
parent14494258aa1648da961a065c4379761e505f915e (diff)
Blueprints Processor Service
Add Input, default, mdsal and sdnc db resource processor prototype. Change-Id: I1ad8c4ea5d7cdf5793af23ac52b7152d1a58b762 Issue-ID: CCSDK-548 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/services')
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt45
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt44
-rw-r--r--ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt36
-rw-r--r--ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt23
-rw-r--r--ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt23
-rw-r--r--ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt48
-rw-r--r--ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt50
-rw-r--r--ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java20
-rw-r--r--ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json30
9 files changed, 288 insertions, 31 deletions
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt
new file mode 100644
index 00000000..427dc873
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt
@@ -0,0 +1,45 @@
+/*
+ * 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.execution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode
+import org.springframework.stereotype.Component
+
+/**
+ * JavaScriptExecuteComponent
+ *
+ * @author Brinda Santh
+ */
+@Component("component-javascript-executor")
+class JavaScriptExecuteComponent : 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/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt
new file mode 100644
index 00000000..59be1f51
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt
@@ -0,0 +1,44 @@
+/*
+ * 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.execution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode
+import org.springframework.stereotype.Component
+
+/**
+ * PythonExecuteComponent
+ *
+ * @author Brinda Santh
+ */
+@Component("component-python-executor")
+class PythonExecuteComponent : 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/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
index 14ab7842..d442c96b 100644
--- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,9 +17,14 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.BlueprintProcessorException
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
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.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
import org.springframework.stereotype.Service
/**
@@ -28,7 +34,7 @@ import org.springframework.stereotype.Service
*/
@Service
-class ResourceResolutionService {
+class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {
fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
val resourceResolutionOutput = ResourceResolutionOutput()
@@ -36,6 +42,10 @@ class ResourceResolutionService {
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"
@@ -43,4 +53,28 @@ class ResourceResolutionService {
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(format("failed to get resource processor for instance name({}) " +
+ "for resource assignment({})", processorInstanceName, 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/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
index 396ca1d7..9580ca49 100644
--- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,25 +17,33 @@
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 {
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ 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>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ log.info("Processing Resource Assignments")
}
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
}
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ 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/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
index 9d0734e6..05f7d5cd 100644
--- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,25 +17,33 @@
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 {
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ 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>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ log.info("Processing Resource Assignments")
}
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
}
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ 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/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..9d54cd46
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/resolution-service/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/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..4b11f580
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/resolution-service/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/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java
index 63359908..0768c609 100644
--- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java
+++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -24,6 +25,11 @@ 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;
@@ -42,7 +48,9 @@ import java.util.List;
* @author Brinda Santh DATE : 8/15/2018
*/
@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = ResourceResolutionService.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);
@@ -57,8 +65,8 @@ public class ResourceResolutionServiceTest {
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);
+ 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());
@@ -68,13 +76,13 @@ public class ResourceResolutionServiceTest {
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);
+ 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);
+ Assert.assertNotNull("failed to populate output", resourceResolutionOutput);
}
}
diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json
index 02ce68be..ddcf32ee 100644
--- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json
+++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json
@@ -1,12 +1,22 @@
[
- {
- "name": "country",
- "input-param": true,
- "property": {
- "type": "string"
- },
- "dictionary-name": "country",
- "dictionary-source": "db",
- "dependencies": []
- }
+ {
+ "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": []
+ }
]