Blueprints Processor Microservice
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 15 Nov 2018 18:12:09 +0000 (13:12 -0500)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 15 Nov 2018 18:12:09 +0000 (13:12 -0500)
Implement Resource Resolution Processor Interface definitions.

Change-Id: Ic2eb7915d48b9473639494ee9d159003bf56e81e
Issue-ID: CCSDK-724
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
12 files changed:
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt with 52% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt with 52% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java [deleted file]
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt

index ff1a01d..a485fa6 100644 (file)
@@ -1,39 +1,32 @@
 /*\r
- *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
  *\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
  *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
  *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
  */\r
 \r
 package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution\r
 \r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode\r
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction\r
 import org.springframework.stereotype.Component\r
 \r
 @Component("component-resource-resolution")\r
-open class ResourceResolutionComponent : ComponentNode {\r
-    override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {\r
+open class ResourceResolutionComponent : AbstractComponentFunction() {\r
+    override fun process(executionRequest: ExecutionServiceInput) {\r
         TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
     }\r
 \r
-    override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
-    }\r
-\r
-    override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
-    }\r
-\r
-    override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {\r
+    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {\r
         TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
     }\r
 }
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt
new file mode 100644 (file)
index 0000000..e234d05
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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
+
+class ResourceResolutionConstants {
+    companion object {
+        const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+
+    }
+
+}
\ No newline at end of file
index 3ee7e41..155b3b0 100644 (file)
@@ -20,10 +20,12 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils\r
+import org.springframework.beans.factory.annotation.Autowired\r
+import org.springframework.context.ApplicationContext\r
 import org.springframework.stereotype.Service\r
 \r
 /**\r
@@ -33,7 +35,11 @@ import org.springframework.stereotype.Service
  */\r
 \r
 @Service\r
-class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {\r
+class ResourceResolutionService {\r
+\r
+\r
+    @Autowired\r
+    private lateinit var applicationContext: ApplicationContext\r
 \r
     fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {\r
         val resourceResolutionOutput = ResourceResolutionOutput()\r
@@ -43,7 +49,7 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory:
 \r
         val context = hashMapOf<String, Any>()\r
 \r
-        process(resourceResolutionOutput.resourceAssignments, context)\r
+        process(resourceResolutionOutput.resourceAssignments)\r
 \r
         val status = Status()\r
         status.code = 200\r
@@ -53,7 +59,13 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory:
         return resourceResolutionOutput\r
     }\r
 \r
-    fun process(resourceAssignments: MutableList<ResourceAssignment>, context: MutableMap<String, Any>): Unit {\r
+    fun registeredResourceSources(): List<String> {\r
+        return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)\r
+                .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
+                .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
+    }\r
+\r
+    fun process(resourceAssignments: MutableList<ResourceAssignment>) {\r
 \r
         val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
 \r
@@ -61,18 +73,18 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory:
             batchResourceAssignments.filter { it.name != "*" && it.name != "start" }\r
                     .map { resourceAssignment ->\r
                         val dictionarySource = resourceAssignment.dictionarySource\r
-                        val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource)\r
-                        val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName)\r
+                        val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)\r
+\r
+                        val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor\r
                                 ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +\r
                                         "for resource assignment(${resourceAssignment.name})")\r
                         try {\r
-                            resourceAssignmentProcessor.validate(resourceAssignment, context)\r
-                            resourceAssignmentProcessor.process(resourceAssignment, context)\r
-                        } catch (e: Exception) {\r
-                            resourceAssignmentProcessor.errorHandle(resourceAssignment, context)\r
+                            // Invoke Apply Method\r
+                            resourceAssignmentProcessor.apply(resourceAssignment)\r
+                        } catch (e: RuntimeException) {\r
+                            resourceAssignmentProcessor.recover(e, resourceAssignment)\r
                             throw BluePrintProcessorException(e)\r
                         }\r
-\r
                     }\r
         }\r
     }\r
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2018 IBM.
+ *  Modifications 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.
 
 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
+ * DataBaseResourceAssignmentProcessor
  *
  * @author Brinda Santh
  */
 @Service("resource-assignment-processor-db")
-open class SdncResourceAssignmentProcessor : ResourceAssignmentProcessor {
+open class DataBaseResourceAssignmentProcessor : 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 process(executionRequest: ResourceAssignment) {
     }
 
-    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
-        log.info("ErrorHandle Resource Assignments")
+    override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
     }
-
-    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
-        log.info("Re Trigger Resource Assignments")
-    }
-
 }
\ No newline at end of file
index 9580ca4..e701e71 100644 (file)
@@ -17,7 +17,6 @@
 \r
 package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\r
 \r
-import com.att.eelf.configuration.EELFManager\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
 import org.springframework.stereotype.Service\r
@@ -28,22 +27,11 @@ import org.springframework.stereotype.Service
  * @author Brinda Santh\r
  */\r
 @Service("resource-assignment-processor-default")\r
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor {\r
-    private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java)\r
+open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {\r
 \r
-    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        log.info("Validation Resource Assignments")\r
+    override fun process(executionRequest: ResourceAssignment) {\r
     }\r
 \r
-    override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        log.info("Processing Resource Assignments")\r
-    }\r
-\r
-    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        log.info("ErrorHandle Resource Assignments")\r
-    }\r
-\r
-    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        log.info("Re Trigger Resource Assignments")\r
+    override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {\r
     }\r
 }
\ No newline at end of file
index 05f7d5c..9e177d4 100644 (file)
@@ -17,7 +17,6 @@
 \r
 package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\r
 \r
-import com.att.eelf.configuration.EELFManager\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
 import org.springframework.stereotype.Service\r
@@ -28,22 +27,11 @@ import org.springframework.stereotype.Service
  * @author Brinda Santh\r
  */\r
 @Service("resource-assignment-processor-input")\r
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor {\r
-    private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java)\r
+open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {\r
 \r
-    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        log.info("Validation Resource Assignments")\r
+    override fun process(executionRequest: ResourceAssignment) {\r
     }\r
 \r
-    override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        log.info("Processing Resource Assignments")\r
-    }\r
-\r
-    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        log.info("ErrorHandle Resource Assignments")\r
-    }\r
-\r
-    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        log.info("Re Trigger Resource Assignments")\r
+    override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {\r
     }\r
 }
\ No newline at end of file
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2018 IBM.
+ *  Modifications 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.
 
 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
+ * SimpleRestResourceAssignmentProcessor
  *
  * @author Brinda Santh
  */
 @Service("resource-assignment-processor-mdsal")
-open class MDSALResourceAssignmentProcessor : ResourceAssignmentProcessor {
-    private val log = EELFManager.getInstance().getLogger(MDSALResourceAssignmentProcessor::class.java)
+open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() {
 
-    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
-        log.info("Validation Resource Assignments")
+    override fun process(executionRequest: ResourceAssignment) {
     }
 
-    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")
+    override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
     }
 }
\ 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
deleted file mode 100644 (file)
index 0768c60..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*\r
- *  Copyright © 2017-2018 AT&T Intellectual Property.\r
- *  Modifications Copyright © 2018 IBM.\r
- *\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.MDSALResourceAssignmentProcessor;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SdncResourceAssignmentProcessor;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.test.context.ContextConfiguration;\r
-import org.springframework.test.context.junit4.SpringRunner;\r
-\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.List;\r
-\r
-/**\r
- * ResourceResolutionServiceTest\r
- *\r
- * @author Brinda Santh DATE : 8/15/2018\r
- */\r
-@RunWith(SpringRunner.class)\r
-@ContextConfiguration(classes = {ResourceResolutionService.class, ResourceAssignmentProcessorFactory.class,\r
-        InputResourceAssignmentProcessor.class, DefaultResourceAssignmentProcessor.class,\r
-        SdncResourceAssignmentProcessor.class, MDSALResourceAssignmentProcessor.class})\r
-public class ResourceResolutionServiceTest {\r
-    private static Logger log = LoggerFactory.getLogger(ResourceResolutionServiceTest.class);\r
-\r
-    @Autowired\r
-    private ResourceResolutionService resourceResolutionService;\r
-\r
-    @Test\r
-    public void testResolveResource() throws Exception {\r
-\r
-        Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService);\r
-\r
-        String resourceResolutionInputContent = FileUtils.readFileToString(\r
-                new File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset());\r
-\r
-        ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class);\r
-        Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput);\r
-\r
-        String resourceAssignmentContent = FileUtils.readFileToString(\r
-                new File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset());\r
-        List<ResourceAssignment> batchResourceAssignment =\r
-                JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);\r
-\r
-        Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment));\r
-        resourceResolutionInput.setResourceAssignments(batchResourceAssignment);\r
-\r
-        ObjectNode inputContent = (ObjectNode) JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");\r
-        Assert.assertNotNull("failed to populate input payload ", inputContent);\r
-        resourceResolutionInput.setPayload(inputContent);\r
-        log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true));\r
-\r
-        ResourceResolutionOutput resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput);\r
-        Assert.assertNotNull("failed to populate output", resourceResolutionOutput);\r
-\r
-    }\r
-}\r
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt
new file mode 100644 (file)
index 0000000..a7d573c
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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 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.factory.ResourceAssignmentProcessorFactory
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DataBaseResourceAssignmentProcessor
+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.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+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 kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+/**
+ * ResourceResolutionServiceTest
+ *
+ * @author Brinda Santh DATE : 8/15/2018
+ */
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [ResourceResolutionService::class, ResourceAssignmentProcessorFactory::class,
+    InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
+    DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+class ResourceResolutionServiceTest {
+
+    private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
+
+    @Autowired
+    lateinit var resourceResolutionService: ResourceResolutionService
+
+
+    @Test
+    fun testRegisteredSource() {
+        val sources = resourceResolutionService.registeredResourceSources()
+        assertNotNull(sources, "failed to get registered sources")
+        assertTrue(sources.containsAll(arrayListOf("input", "default", "db", "mdsal")), "failed to get registered sources")
+    }
+
+    @Test
+    @Throws(Exception::class)
+    fun testResolveResource() {
+
+        Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+        val resourceResolutionInputContent = FileUtils.readFileToString(
+                File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset())
+
+        val resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput::class.java)
+        Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput)
+
+        val resourceAssignmentContent = FileUtils.readFileToString(
+                File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset())
+        val batchResourceAssignment = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
+
+        Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment))
+        resourceResolutionInput!!.resourceAssignments = batchResourceAssignment as MutableList<ResourceAssignment>
+
+        val inputContent = JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json") as ObjectNode
+        Assert.assertNotNull("failed to populate input payload ", inputContent)
+        resourceResolutionInput.payload = inputContent
+        log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true))
+
+        val resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput)
+        Assert.assertNotNull("failed to populate output", resourceResolutionOutput)
+
+    }
+
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..a816a06
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<configuration>\r
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+        <!-- encoders are assigned the type\r
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+        <encoder>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+        </encoder>\r
+    </appender>\r
+\r
+\r
+    <logger name="org.springframework" level="warn"/>\r
+    <logger name="org.hibernate" level="info"/>\r
+    <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+    <root level="warn">\r
+        <appender-ref ref="STDOUT"/>\r
+    </root>\r
+\r
+</configuration>\r
index 0e70e49..9a0d1f9 100644 (file)
@@ -34,14 +34,6 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
         return executionRequest\r
     }\r
 \r
-    override fun process(executionRequest: ExecutionServiceInput) {\r
-        log.info("Processing...")\r
-    }\r
-\r
-    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {\r
-        log.info("Recovering...")\r
-    }\r
-\r
     override fun prepareResponse(): ExecutionServiceOutput {\r
         log.info("Preparing Response...")\r
         return ExecutionServiceOutput()\r
index 5787721..5aa9013 100644 (file)
@@ -37,10 +37,10 @@ class MockComponentFunction : AbstractComponentFunction() {
     private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
 
     override fun process(executionRequest: ExecutionServiceInput) {
-        super.process(executionRequest)
+        log.info("Processing component..")
     }
 
     override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
-        super.recover(runtimeException, executionRequest)
+        log.info("Recovering component..")
     }
 }
\ No newline at end of file