Merge "Complementary Junit test coverage"
authorDan Timoney <dtimoney@att.com>
Tue, 2 Apr 2019 18:10:23 +0000 (18:10 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 2 Apr 2019 18:10:23 +0000 (18:10 +0000)
1  2 
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt

@@@ -73,22 -75,66 +76,68 @@@ class ResourceResolutionServiceTest 
      @Test
      @Throws(Exception::class)
      fun testResolveResource() {
 +        runBlocking {
  
 -        Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
 +            Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
  
 -        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
 -                "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
 +            val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
 +                    "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
  
 -        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
 -                ExecutionServiceInput::class.java)!!
 +            val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
 +                    ExecutionServiceInput::class.java)!!
  
 -        // Prepare Inputs
 -        PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
 +            // Prepare Inputs
 +            PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
  
 -        resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig", mapOf())
 +            resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig", mapOf())
  
 +        }
      }
  
+     @Test
+     @Throws(Exception::class)
+     fun testResolveResources() {
+         Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+         val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+                 ExecutionServiceInput::class.java)!!
+         val artefactNames = listOf("baseconfig", "another")
+         // Prepare Inputs
+         PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+         resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", artefactNames, mapOf())
+     }
+     @Test
+     @Throws(Exception::class)
+     fun testResolveResourcesWithMappingAndTemplate() {
+         Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+         val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+                 ExecutionServiceInput::class.java)!!
+         val artifactPrefix = "another"
+         // Velocity Artifact Definition Name
+         val artifactTemplate = "$artifactPrefix-template"
+         // Resource Assignment Artifact Definition Name
+         val artifactMapping = "$artifactPrefix-mapping"
+         // Prepare Inputs
+         PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+         resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", artifactMapping, artifactTemplate)
+     }
  }