summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/test
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-11-22 18:06:08 -0500
committerKAPIL SINGAL <ks220y@att.com>2019-11-26 21:32:38 +0000
commit341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch)
tree113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/functions/resource-resolution/src/test
parentd274e5fc552cf9ae25500f504f0434981cf3accf (diff)
Formatting Code base with ktlint
No Business logic change, just the code format. Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3 To format run: mvn process-sources -P format Issue-ID: CCSDK-1947 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt26
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt44
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt190
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt47
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt35
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt)6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt44
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt25
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt8
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt19
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt144
17 files changed, 400 insertions, 264 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
index f8f0e991e..7dcaab733 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
@@ -25,8 +25,10 @@ class ResourceDefinitionDSLTest {
@Test
fun testResourceDefinitionDSL() {
- val testResourceDefinition = BluePrintTypes.resourceDefinition("service-instance-id",
- "VFW Service Instance Name") {
+ val testResourceDefinition = BluePrintTypes.resourceDefinition(
+ "service-instance-id",
+ "VFW Service Instance Name"
+ ) {
tags("service-instance-name, vfw, resources")
updatedBy("brindasanth@onap.com")
property("string", true)
@@ -74,7 +76,7 @@ class ResourceDefinitionDSLTest {
}
}
}
- //println(resourceDefinition.asJsonString(true))
+ // println(resourceDefinition.asJsonString(true))
assertNotNull(testResourceDefinition, "failed to generate testResourceDefinition")
val testResourceDefinitions = BluePrintTypes.resourceDefinitions {
@@ -86,26 +88,30 @@ class ResourceDefinitionDSLTest {
@Test
fun testResourceAssignment() {
- val testResourceAssignment = BluePrintTypes.resourceAssignment("instance-name",
- "service-instance-name", "odl-mdsal") {
+ val testResourceAssignment = BluePrintTypes.resourceAssignment(
+ "instance-name",
+ "service-instance-name", "odl-mdsal"
+ ) {
inputParameter(true)
property("string", true)
dependencies(arrayListOf("service-instance-id"))
}
- //println(resourceAssignment.asJsonString(true))
+ // println(resourceAssignment.asJsonString(true))
assertNotNull(testResourceAssignment, "failed to generate resourceAssignment")
val testResourceAssignments = BluePrintTypes.resourceAssignments {
resourceAssignment(testResourceAssignment)
- resourceAssignment("instance-name1",
- "service-instance-name", "odl-mdsal") {
+ resourceAssignment(
+ "instance-name1",
+ "service-instance-name", "odl-mdsal"
+ ) {
inputParameter(true)
property("string", true)
dependencies(arrayListOf("service-instance-id"))
}
}
- //println(testResourceAssignments.asJsonString(true))
+ // println(testResourceAssignments.asJsonString(true))
assertNotNull(testResourceAssignments, "failed to generate testResourceAssignments")
assertEquals(2, testResourceAssignments.size, "testResourceAssignments size doesn't match")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
index 671acff95..ae9b4208f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
@@ -26,7 +26,7 @@ class ResourceResolutionComponentDSLTest {
@Test
fun testNodeTypeComponentResourceResolution() {
val nodeType = BluePrintTypes.nodeTypeComponentResourceResolution()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeComponentResourceResolution")
}
@@ -42,11 +42,13 @@ class ResourceResolutionComponentDSLTest {
resourceType("vnf")
storeResult(false)
artifactPrefixNames(arrayListOf("template1", "template2"))
- dynamicProperties("""{
+ dynamicProperties(
+ """{
"prop1" : "1234",
"prop2" : true,
"prop3" : 23
- }""".trimIndent())
+ }""".trimIndent()
+ )
}
outputs {
resourceAssignmentParams(getAttribute("assignment-params"))
@@ -54,7 +56,7 @@ class ResourceResolutionComponentDSLTest {
}
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateComponentResourceResolution")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index b63fa6798..e1f708341 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -50,7 +50,6 @@ class ResourceResolutionComponentTest {
private val executionRequest = ExecutionServiceInput()
-
@Before
fun setup() {
@@ -81,8 +80,10 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: either provide resolution-key OR combination of resource-id and resource-type.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: either provide resolution-key OR combination of resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -98,8 +99,10 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: both resource-id and resource-type should be provided, one of them is missing.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: both resource-id and resource-type should be provided, one of them is missing.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -116,9 +119,11 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: can't persist resolution without a correlation key. " +
- "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: can't persist resolution without a correlation key. " +
+ "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -136,22 +141,23 @@ class ResourceResolutionComponentTest {
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence
coEvery {
- resourceResolutionService.resolveResources(any(),
- any(),
- any<List<String>>(),
- any<MutableMap<String, Any>>())
+ resourceResolutionService.resolveResources(
+ any(),
+ any(),
+ any<List<String>>(),
+ any<MutableMap<String, Any>>()
+ )
} returns mutableMapOf()
-
runBlocking {
resourceResolutionComponent.processNB(executionRequest)
}
-// FIXME add verification
-// coVerify {
-// resourceResolutionService.resolveResources(eq(bluePrintRuntimeService),
-// eq(nodeTemplateName), eq(artifactNames), eq(properties))
-// }
+ // FIXME add verification
+ // coVerify {
+ // resourceResolutionService.resolveResources(eq(bluePrintRuntimeService),
+ // eq(nodeTemplateName), eq(artifactNames), eq(properties))
+ // }
}
@Test
@@ -165,4 +171,4 @@ class ResourceResolutionComponentTest {
assertEquals(1, blueprintError.errors.size)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index db453acf4..e46d457cd 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -30,7 +30,12 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguratio
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.PayloadUtils
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.*
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.CapabilityResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.DatabaseResourceAssignmentProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.DefaultResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.InputResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.MockCapabilityScriptRA
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
@@ -57,12 +62,14 @@ import kotlin.test.assertTrue
* @author Brinda Santh DATE : 8/15/2018
*/
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
- DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
- CapabilityResourceResolutionProcessor::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
- BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
+@ContextConfiguration(
+ classes = [ResourceResolutionServiceImpl::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
+ BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@EnableAutoConfiguration
@@ -92,8 +99,14 @@ class ResourceResolutionServiceTest {
fun testRegisteredSource() {
val sources = resourceResolutionService.registeredResourceSources()
assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-db",
- "source-rest", "source-capability")), "failed to get registered sources : $sources")
+ assertTrue(
+ sources.containsAll(
+ arrayListOf(
+ "source-input", "source-default", "source-db",
+ "source-rest", "source-capability"
+ )
+ ), "failed to get registered sources : $sources"
+ )
}
@Test
@@ -103,29 +116,36 @@ class ResourceResolutionServiceTest {
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)!!
-
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResource")
-
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResource"
+ )
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- "baseconfig",
- props)
-
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ "baseconfig",
+ props
+ )
}
}
@@ -135,26 +155,33 @@ class ResourceResolutionServiceTest {
runBlocking {
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)!!
+ 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,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ bluePrintRuntimeService,
+ "resource-assignment",
+ artefactNames,
+ props
+ )
}
-
}
@Test
@@ -163,32 +190,41 @@ class ResourceResolutionServiceTest {
runBlocking {
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)!!
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResourcesWithMappingAndTemplate")
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourcesWithMappingAndTemplate"
+ )
val artifactPrefix = "another"
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- artifactPrefix,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ )
}
}
-
@Test
fun testResolveResourcesWithResourceIdAndResourceType() {
@@ -197,28 +233,38 @@ class ResourceResolutionServiceTest {
runBlocking {
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)!!
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResourcesWithMappingAndTemplate")
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourcesWithMappingAndTemplate"
+ )
val artifactPrefix = "another"
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- artifactPrefix,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ )
}
}
@@ -259,7 +305,7 @@ class ResourceResolutionServiceTest {
val raRuntimeService = mockk<ResourceAssignmentRuntimeService>()
every { raRuntimeService.bluePrintContext() } returns mockk<BluePrintContext>()
every { raRuntimeService.getBluePrintError() } returns BluePrintError()
- every { raRuntimeService.setBluePrintError(any())} returns Unit
+ every { raRuntimeService.setBluePrintError(any()) } returns Unit
every { raRuntimeService.getInputValue("device-id") } returns "123456".asJsonPrimitive()
every { raRuntimeService.putResolutionStore(any(), any()) } returns Unit
@@ -271,8 +317,10 @@ class ResourceResolutionServiceTest {
val sources = arrayListOf<String>("sdno", "sdnc")
val resourceResolutionService = ResourceResolutionServiceImpl(applicationContext, mockk(), mockk(), mockk())
- val resolvedResources = resourceResolutionService.resolveResourceDefinition(raRuntimeService,
- resourceDefinitions, "port-speed", sources)
+ val resolvedResources = resourceResolutionService.resolveResourceDefinition(
+ raRuntimeService,
+ resourceDefinitions, "port-speed", sources
+ )
assertNotNull(resolvedResources, "failed to resolve the resources")
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
index 2eb208566..2e9dc9e2a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
@@ -25,53 +25,51 @@ class ResourceSourceDSLTest {
@Test
fun testNodeTypeSourceInput() {
val nodeType = BluePrintTypes.nodeTypeSourceInput()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceInput")
}
@Test
fun testNodeTypeSourceDefault() {
val nodeType = BluePrintTypes.nodeTypeSourceDefault()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceDefault")
}
@Test
fun testNodeTypeSourceDb() {
val nodeType = BluePrintTypes.nodeTypeSourceDb()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceDb")
}
@Test
fun testNodeTypeSourceRest() {
val nodeType = BluePrintTypes.nodeTypeSourceRest()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceRest")
}
@Test
fun testNodeTypeSourceCapability() {
val nodeType = BluePrintTypes.nodeTypeSourceCapability()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceCapability")
}
@Test
fun testNodeTemplateSourceInput() {
val nodeTemplate = BluePrintTypes.nodeTemplateSourceInput("InputSystem", "") {
-
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceInput")
}
@Test
fun testNodeTemplateSourceDefault() {
val nodeTemplate = BluePrintTypes.nodeTemplateSourceDefault("DefaultSystem", "") {
-
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDefault")
}
@@ -91,7 +89,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDb")
}
@@ -115,7 +113,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceRest")
}
@@ -128,7 +126,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceCapability")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
index dcf2e64a5..4f864a49c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
@@ -72,13 +72,15 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix
+ )
assertEquals(2, res.size)
}
@@ -88,12 +90,14 @@ open class ResourceResolutionDBServiceTest {
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrenceTestException() {
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} throws EmptyResultDataAccessException(1)
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix
+ )
assert(res.isEmpty())
}
@@ -107,13 +111,15 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix
+ )
assertEquals(2, res.size)
}
@@ -123,12 +129,14 @@ open class ResourceResolutionDBServiceTest {
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrenceTestException() {
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} throws EmptyResultDataAccessException(1)
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix
+ )
assert(res.isEmpty())
}
@@ -141,12 +149,14 @@ open class ResourceResolutionDBServiceTest {
rr.value = "testValue"
every {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns rr
runBlocking {
val res =
resourceResolutionDBService.readValue(
- blueprintName, blueprintVersion, artifactPrefix, resolutionKey, "bob")
+ blueprintName, blueprintVersion, artifactPrefix, resolutionKey, "bob"
+ )
assertEquals(rr.name, res.name)
assertEquals(rr.value, res.value)
@@ -160,12 +170,14 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- any(), any(), any(), any())
+ any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.readWithResolutionKey(
- blueprintName, blueprintVersion, artifactPrefix, resolutionKey)
+ blueprintName, blueprintVersion, artifactPrefix, resolutionKey
+ )
assertEquals(2, res.size)
}
}
@@ -177,12 +189,14 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
- any(), any(), any(), any())
+ any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.readWithResourceIdAndResourceType(
- blueprintName, blueprintVersion, resourceId, resourceType)
+ blueprintName, blueprintVersion, resourceId, resourceType
+ )
assertEquals(2, res.size)
}
}
@@ -203,9 +217,10 @@ open class ResourceResolutionDBServiceTest {
runBlocking {
val res =
resourceResolutionDBService.write(
- props, bluePrintRuntimeService, artifactPrefix, resourceAssignment)
+ props, bluePrintRuntimeService, artifactPrefix, resourceAssignment
+ )
assertEquals(resourceResolution, res)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
index 48c6f02ef..18a9f3233 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
@@ -54,11 +54,13 @@ class TemplateResolutionServiceTest {
runBlocking {
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
val res =
templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bluePrintRuntimeService, artifactPrefix, resolutionKey)
+ bluePrintRuntimeService, artifactPrefix, resolutionKey
+ )
assertEquals(tr.result, res)
}
}
@@ -69,10 +71,12 @@ class TemplateResolutionServiceTest {
runBlocking {
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bluePrintRuntimeService, artifactPrefix, resolutionKey)
+ bluePrintRuntimeService, artifactPrefix, resolutionKey
+ )
}
}
@@ -83,7 +87,8 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns null
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
assertEquals(tr, res)
@@ -97,16 +102,19 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
every {
templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns Unit
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
verify {
templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- eq(resolutionKey), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence))
+ eq(resolutionKey), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence)
+ )
}
assertEquals(tr, res)
}
@@ -120,18 +128,21 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns tr
every {
templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns Unit
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
verify {
templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- eq(resourceId), eq(resourceType), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence))
+ eq(resourceId), eq(resourceType), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence)
+ )
}
assertEquals(tr, res)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt
index f64ba2bbd..d6331fe33 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt
@@ -20,9 +20,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
class MockBluePrintRestLibPropertyService(bluePrintProperties: BluePrintPropertiesService) :
- BluePrintRestLibPropertyService(bluePrintProperties) {
+ BluePrintRestLibPropertyService(bluePrintProperties) {
- fun mockBlueprintWebClientService (selector: String):
+ fun mockBlueprintWebClientService(selector: String):
MockBlueprintWebClientService {
val prefix = "blueprintsprocessor.restclient.$selector"
val restClientProperties = restClientProperties(prefix)
@@ -33,4 +33,4 @@ class MockBluePrintRestLibPropertyService(bluePrintProperties: BluePrintProperti
MockBlueprintWebClientService {
return MockBlueprintWebClientService(restClientProperties)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
index fede7be7b..ef5c79eab 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
@@ -25,32 +25,37 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientSer
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import java.nio.charset.Charset
-import java.util.*
+import java.util.Base64
-class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties): BlueprintWebClientService {
+class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties) : BlueprintWebClientService {
private var mockServer: ClientAndServer
private var port: String = if (restClientProperties.url.split(":")[2].isEmpty()) "8080"
- else restClientProperties.url.split(":")[2]
+ else restClientProperties.url.split(":")[2]
private var headers: Map<String, String>
init {
- mockServer = ClientAndServer.startClientAndServer(port.toInt())
- headers = defaultHeaders()
+ mockServer = ClientAndServer.startClientAndServer(port.toInt())
+ headers = defaultHeaders()
// Create expected requests and responses
setRequest("GET", "/aai/v14/network/generic-vnfs/generic-vnf/123456")
- setRequest("GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" +
- "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name")
- setRequestWithPayload("PUT", "/query",
- "{\r\n\"start\": \"\\/nodes\\/vf-modules?vf-module-name=vf-module-name\",\r\n\"query\": \"\\/query\\/related-to?startingNodeType=vf-module&relatedToNodeType=generic-vnf\"\r\n}")
+ setRequest(
+ "GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" +
+ "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name"
+ )
+ setRequestWithPayload(
+ "PUT", "/query",
+ "{\r\n\"start\": \"\\/nodes\\/vf-modules?vf-module-name=vf-module-name\",\r\n\"query\": \"\\/query\\/related-to?startingNodeType=vf-module&relatedToNodeType=generic-vnf\"\r\n}"
+ )
}
override fun defaultHeaders(): Map<String, String> {
val encodedCredentials = this.setBasicAuth("admin", "aaiTest")
return mapOf(
- HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials")
+ HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
+ HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
+ HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials"
+ )
}
override fun host(uri: String): String {
@@ -87,11 +92,11 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
else -> {
"Get response"
}
-
}
- mockServer.`when`(request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
- .withMethod(method)
- .withPath(path)
+ mockServer.`when`(
+ request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
+ .withMethod(method)
+ .withPath(path)
).respond(response().withStatusCode(200).withBody("{\"aai-resource\":\"$requestResponse\"}"))
}
@@ -106,9 +111,9 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
else -> {
"Get response"
}
-
}
- mockServer.`when`(request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
+ mockServer.`when`(
+ request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
.withMethod(method)
.withPath(path)
.withQueryStringParameter("format", "resource")
@@ -119,6 +124,7 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
private fun setBasicAuth(username: String, password: String): String {
val credentialsString = "$username:$password"
return Base64.getEncoder().encodeToString(
- credentialsString.toByteArray(Charset.defaultCharset()))
+ credentialsString.toByteArray(Charset.defaultCharset())
+ )
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
index 7644df37a..0a4de9218 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
@@ -28,7 +28,7 @@ open class MockDatabaseConfiguration {
@Bean(name = ["MariaDatabaseConfiguration", "MySqlDatabaseConfiguration", "PrimaryDatabaseConfiguration"])
open fun createDatabaseConfiguration(): BluePrintDBLibGenericService {
- return mockk<BluePrintDBLibGenericService>()
+ return mockk<BluePrintDBLibGenericService>()
}
}
@@ -42,6 +42,4 @@ open class MockBlueprintProcessorCatalogServiceImpl {
every { bluePrintValidatorService.validateBluePrints(any<BluePrintRuntimeService<*>>()) } returns true
return bluePrintValidatorService
}
-
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
index e5b559826..a7379e22a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
@@ -29,10 +29,12 @@ import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
-import java.util.*
+import java.util.HashMap
-class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertyService:
- MockBluePrintRestLibPropertyService) : ResourceAssignmentProcessor() {
+class MockRestResourceResolutionProcessor(
+ private val blueprintRestLibPropertyService:
+ MockBluePrintRestLibPropertyService
+) : ResourceAssignmentProcessor() {
private val logger = LoggerFactory.getLogger(MockRestResourceResolutionProcessor::class.java)
@@ -77,8 +79,10 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
- logger.info("MockRestResource ($dSource) dictionary information: " +
- "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})")
+ logger.info(
+ "MockRestResource ($dSource) dictionary information: " +
+ "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
+ )
// Get the Rest Client Service
val restClientService = blueprintWebClientService(executionRequest)
@@ -90,7 +94,8 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
populateResource(executionRequest, sourceProperties, responseBody, path)
restClientService.tearDown()
} else {
- val errMsg = "Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath) response_code: ($responseStatusCode)"
+ val errMsg =
+ "Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath) response_code: ($responseStatusCode)"
logger.warn(errMsg)
throw BluePrintProcessorException(errMsg)
}
@@ -110,8 +115,12 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
}
@Throws(BluePrintProcessorException::class)
- private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource,
- restResponse: String, path: String) {
+ private fun populateResource(
+ resourceAssignment: ResourceAssignment,
+ sourceProperties: RestResourceSource,
+ restResponse: String,
+ path: String
+ ) {
val type = nullToEmpty(resourceAssignment.property?.type)
lateinit var entrySchemaType: String
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
index 98f68ebaa..8f6ac9fd5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
@@ -140,9 +140,7 @@ class CapabilityResourceResolutionProcessorTest {
}
}
-open class MockCapabilityService {
-
-}
+open class MockCapabilityService
open class MockCapabilityScriptRA : ResourceAssignmentProcessor() {
val log = logger(MockCapabilityScriptRA::class)
@@ -157,6 +155,6 @@ open class MockCapabilityScriptRA : ResourceAssignmentProcessor() {
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ 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/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
index ac5ba3c46..da2282018 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
@@ -22,7 +22,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDatabaseConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockBlueprintProcessorCatalogServiceImpl
@@ -38,10 +38,12 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [DatabaseResourceAssignmentProcessor::class, BluePrintPropertyConfiguration::class,
- BluePrintPropertiesService::class, BluePrintDBLibPropertySevice::class, BluePrintDBLibConfiguration::class,
- BluePrintCoreConfiguration::class, MockDatabaseConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class,
- BluePrintPropertiesService::class, PrimaryDatabaseConfiguration::class])
+@ContextConfiguration(
+ classes = [DatabaseResourceAssignmentProcessor::class, BluePrintPropertyConfiguration::class,
+ BluePrintPropertiesService::class, BluePrintDBLibPropertyService::class, BluePrintDBLibConfiguration::class,
+ BluePrintCoreConfiguration::class, MockDatabaseConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class,
+ BluePrintPropertiesService::class, PrimaryDatabaseConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class DatabaseResourceResolutionProcessorTest {
@@ -52,13 +54,14 @@ class DatabaseResourceResolutionProcessorTest {
fun `test database resource resolution processor db`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
databaseResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
databaseResourceAssignmentProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val resourceAssignment = ResourceAssignment().apply {
name = "service-instance-id"
@@ -73,4 +76,4 @@ class DatabaseResourceResolutionProcessorTest {
assertNotNull(processorName, "couldn't get Database resource assignment processor name")
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
index 093a3347a..a109131fe 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
@@ -40,7 +40,8 @@ class DefaultResourceResolutionProcessorTest {
fun `test default resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
@@ -61,4 +62,4 @@ class DefaultResourceResolutionProcessorTest {
println(processorName)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
index 242739067..17bb5e6b0 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
@@ -46,13 +46,14 @@ class InputResourceResolutionProcessorTest {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))
// mocking input for resource resolution
val textNode: JsonNode = TextNode("any value")
- every {resourceAssignmentRuntimeService.getInputValue("rr-name") } returns textNode
+ every { resourceAssignmentRuntimeService.getInputValue("rr-name") } returns textNode
inputResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
inputResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils.resourceDefinitions(bluePrintContext.rootPath)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
index 1c0f33fcd..af78a604a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
@@ -36,17 +36,20 @@ import kotlin.test.BeforeTest
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [MockRestResourceResolutionProcessor::class, MockBluePrintRestLibPropertyService::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, RestClientProperties::class])
+@ContextConfiguration(
+ classes = [MockRestResourceResolutionProcessor::class, MockBluePrintRestLibPropertyService::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, RestClientProperties::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class RestResourceResolutionProcessorTest {
+
@Autowired
lateinit var bluePrintRestLibPropertyService: MockBluePrintRestLibPropertyService
private lateinit var restResourceResolutionProcessor: MockRestResourceResolutionProcessor
@BeforeTest
- fun init(){
+ fun init() {
restResourceResolutionProcessor = MockRestResourceResolutionProcessor(bluePrintRestLibPropertyService)
}
@@ -54,13 +57,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
@@ -87,13 +91,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest aai get resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
@@ -120,13 +125,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest aai put resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
index d7a696848..7631339e8 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
@@ -64,11 +64,12 @@ class ResourceAssignmentUtilsTest {
fun setup() {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))
- //Init input map and expected values for tests
+ // Init input map and expected values for tests
initInputMapAndExpectedValuesForPrimitiveType()
initInputMapAndExpectedValuesForCollection()
initInputMapAndExpectedValuesForComplexType()
@@ -120,35 +121,34 @@ class ResourceAssignmentUtilsTest {
@Test
fun `generateResourceDataForAssignments - positive test`() {
- //given a valid resource assignment
+ // given a valid resource assignment
val validResourceAssignment = createResourceAssignmentForTest("valid_value")
- //and a list containing that resource assignment
+ // and a list containing that resource assignment
val resourceAssignmentList = listOf<ResourceAssignment>(validResourceAssignment)
- //when the values of the resources are evaluated
+ // when the values of the resources are evaluated
val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
- //then the assignment should produce a valid result
+ // then the assignment should produce a valid result
val expected = "{\n" + " \"pnf-id\" : \"valid_value\"\n" + "}"
- assertEquals(expected, outcome.replace("\r\n","\n"), "unexpected outcome generated")
+ assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
}
@Test
fun `generateResourceDataForAssignments - resource without value is not resolved as null`() {
- //given a valid resource assignment
+ // given a valid resource assignment
val resourceAssignmentWithNullValue = createResourceAssignmentForTest(null)
- //and a list containing that resource assignment
+ // and a list containing that resource assignment
val resourceAssignmentList = listOf<ResourceAssignment>(resourceAssignmentWithNullValue)
- //when the values of the resources are evaluated
+ // when the values of the resources are evaluated
val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
- //then the assignment should produce a valid result
+ // then the assignment should produce a valid result
val expected = "{\n" + " \"pnf-id\" : \"\${pnf-id}\"\n" + "}"
- assertEquals(expected, outcome.replace("\r\n","\n"), "unexpected outcome generated")
-
+ assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
}
private fun createResourceAssignmentForTest(resourceValue: String?): ResourceAssignment {
@@ -166,61 +166,77 @@ class ResourceAssignmentUtilsTest {
}
@Test
- fun parseResponseNodeTestForPrimitivesTypes(){
- var outcome = prepareResponseNodeForTest("sample-value", "string", "",
- inputMapToTestPrimitiveTypeWithValue)
+ fun parseResponseNodeTestForPrimitivesTypes() {
+ var outcome = prepareResponseNodeForTest(
+ "sample-value", "string", "",
+ inputMapToTestPrimitiveTypeWithValue
+ )
assertEquals(expectedValueToTestPrimitiveType, outcome, "Unexpected outcome returned for primitive type of simple String")
- outcome = prepareResponseNodeForTest("sample-key-value", "string", "",
- inputMapToTestPrimitiveTypeWithKeyValue)
+ outcome = prepareResponseNodeForTest(
+ "sample-key-value", "string", "",
+ inputMapToTestPrimitiveTypeWithKeyValue
+ )
assertEquals(expectedValueToTestPrimitiveType, outcome, "Unexpected outcome returned for primitive type of key-value String")
}
@Test
- fun parseResponseNodeTestForCollectionsOfString(){
- var outcome = prepareResponseNodeForTest("listOfString", "list",
- "string", inputMapToTestCollectionOfPrimitiveType)
+ fun parseResponseNodeTestForCollectionsOfString() {
+ var outcome = prepareResponseNodeForTest(
+ "listOfString", "list",
+ "string", inputMapToTestCollectionOfPrimitiveType
+ )
assertEquals(expectedValueToTesCollectionOfPrimitiveType, outcome, "unexpected outcome returned for list of String")
- outcome = prepareResponseNodeForTest("mapOfString", "map", "string",
- inputMapToTestCollectionOfPrimitiveType)
+ outcome = prepareResponseNodeForTest(
+ "mapOfString", "map", "string",
+ inputMapToTestCollectionOfPrimitiveType
+ )
assertEquals(expectedValueToTesCollectionOfPrimitiveType, outcome, "unexpected outcome returned for map of String")
}
@Test
- fun parseResponseNodeTestForCollectionsOfComplexType(){
- var outcome = prepareResponseNodeForTest("listOfMyDataTypeWithOneOutputKeyMapping", "list",
- "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping)
+ fun parseResponseNodeTestForCollectionsOfComplexType() {
+ var outcome = prepareResponseNodeForTest(
+ "listOfMyDataTypeWithOneOutputKeyMapping", "list",
+ "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping
+ )
assertEquals(expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping, outcome, "unexpected outcome returned for list of String")
- outcome = prepareResponseNodeForTest("listOfMyDataTypeWithAllOutputKeyMapping", "list",
- "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping)
+ outcome = prepareResponseNodeForTest(
+ "listOfMyDataTypeWithAllOutputKeyMapping", "list",
+ "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping
+ )
assertEquals(expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping, outcome, "unexpected outcome returned for list of String")
}
@Test
- fun `parseResponseNodeTestForComplexType find one output key mapping`(){
- val outcome = prepareResponseNodeForTest("complexTypeOneKeys", "host",
- "", inputMapToTestComplexTypeWithOneOutputKeyMapping)
+ fun `parseResponseNodeTestForComplexType find one output key mapping`() {
+ val outcome = prepareResponseNodeForTest(
+ "complexTypeOneKeys", "host",
+ "", inputMapToTestComplexTypeWithOneOutputKeyMapping
+ )
assertEquals(expectedValueToTestComplexTypeWithOneOutputKeyMapping, outcome, "Unexpected outcome returned for complex type")
}
@Test
- fun `parseResponseNodeTestForComplexType find all output key mapping`(){
- val outcome = prepareResponseNodeForTest("complexTypeAllKeys", "host",
- "", inputMapToTestComplexTypeWithAllOutputKeyMapping)
+ fun `parseResponseNodeTestForComplexType find all output key mapping`() {
+ val outcome = prepareResponseNodeForTest(
+ "complexTypeAllKeys", "host",
+ "", inputMapToTestComplexTypeWithAllOutputKeyMapping
+ )
assertEquals(expectedValueToTestComplexTypeWithAllOutputKeyMapping, outcome, "Unexpected outcome returned for complex type")
}
private fun initInputMapAndExpectedValuesForPrimitiveType() {
inputMapToTestPrimitiveTypeWithValue = "1.2.3.1".asJsonType()
val keyValue = mutableMapOf<String, String>()
- keyValue["value"]= "1.2.3.1"
+ keyValue["value"] = "1.2.3.1"
inputMapToTestPrimitiveTypeWithKeyValue = keyValue.asJsonType()
expectedValueToTestPrimitiveType = TextNode("1.2.3.1")
}
- private fun initInputMapAndExpectedValuesForCollection(){
+ private fun initInputMapAndExpectedValuesForCollection() {
val listOfIps = arrayListOf("1.2.3.1", "1.2.3.2", "1.2.3.3")
val arrayNodeForList1 = JacksonUtils.objectMapper.createArrayNode()
listOfIps.forEach {
@@ -230,12 +246,15 @@ class ResourceAssignmentUtilsTest {
}
inputMapToTestCollectionOfPrimitiveType = arrayNodeForList1
- expectedValueToTesCollectionOfPrimitiveType = arrayListOf(ExpectedResponseIp("1.2.3.1"),
- ExpectedResponseIp( "1.2.3.2"), ExpectedResponseIp("1.2.3.3")).asJsonType()
-
+ expectedValueToTesCollectionOfPrimitiveType = arrayListOf(
+ ExpectedResponseIp("1.2.3.1"),
+ ExpectedResponseIp("1.2.3.2"), ExpectedResponseIp("1.2.3.3")
+ ).asJsonType()
- val listOfIpAddresses = arrayListOf(IpAddress("1111", "1.2.3.1").asJsonType(),
- IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType())
+ val listOfIpAddresses = arrayListOf(
+ IpAddress("1111", "1.2.3.1").asJsonType(),
+ IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType()
+ )
val arrayNodeForList2 = JacksonUtils.objectMapper.createArrayNode()
listOfIpAddresses.forEach {
val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
@@ -259,15 +278,20 @@ class ResourceAssignmentUtilsTest {
arrayNodeForList3.add(childNode)
inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayNodeForList3
- expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
- ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")), ExpectedResponseIpAddress(
- IpAddress("3333", "1.2.3.3"))).asJsonType()
- expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(IpAddress("1111", "1.2.3.1"),
- IpAddress("2222", "1.2.3.2"),
- IpAddress("3333", "1.2.3.3")).asJsonType()
+ expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(
+ ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
+ ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")), ExpectedResponseIpAddress(
+ IpAddress("3333", "1.2.3.3")
+ )
+ ).asJsonType()
+ expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(
+ IpAddress("1111", "1.2.3.1"),
+ IpAddress("2222", "1.2.3.2"),
+ IpAddress("3333", "1.2.3.3")
+ ).asJsonType()
}
- private fun initInputMapAndExpectedValuesForComplexType(){
+ private fun initInputMapAndExpectedValuesForComplexType() {
val mapOfComplexType = mutableMapOf<String, JsonNode>()
mapOfComplexType["value"] = Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType()
mapOfComplexType["port"] = "8888".asJsonType()
@@ -275,7 +299,8 @@ class ResourceAssignmentUtilsTest {
inputMapToTestComplexTypeWithOneOutputKeyMapping = mapOfComplexType.asJsonType()
val objectNode = JacksonUtils.objectMapper.createObjectNode()
- expectedValueToTestComplexTypeWithOneOutputKeyMapping = objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())
+ expectedValueToTestComplexTypeWithOneOutputKeyMapping =
+ objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())
val childNode1 = JacksonUtils.objectMapper.createObjectNode()
childNode1.set("name", "my-ipAddress".asJsonPrimitive())
@@ -290,8 +315,12 @@ class ResourceAssignmentUtilsTest {
expectedValueToTestComplexTypeWithAllOutputKeyMapping = childNode2
}
- private fun prepareResponseNodeForTest(dictionary_source: String, sourceType: String, entrySchema: String,
- response: Any): JsonNode {
+ private fun prepareResponseNodeForTest(
+ dictionary_source: String,
+ sourceType: String,
+ entrySchema: String,
+ response: Any
+ ): JsonNode {
val resourceAssignment = when (sourceType) {
"list", "map" -> {
@@ -355,16 +384,16 @@ class ResourceAssignmentUtilsTest {
when (dictionary_source) {
"sample-key-value", "sample-value" -> {
- //Primary Type
- if (dictionary_source=="sample-key-value")
+ // Primary Type
+ if (dictionary_source == "sample-key-value")
outputMapping["sample-ip"] = "value"
}
"listOfString", "mapOfString" -> {
- //List of string
+ // List of string
outputMapping["ip"] = "value"
}
"listOfMyDataTypeWithOneOutputKeyMapping", "listOfMyDataTypeWithAllOutputKeyMapping" -> {
- //List or map of complex Type
+ // List or map of complex Type
if (dictionary_source == "listOfMyDataTypeWithOneOutputKeyMapping")
outputMapping["ipAddress"] = "value"
else {
@@ -373,16 +402,15 @@ class ResourceAssignmentUtilsTest {
}
}
else -> {
- //Complex Type
+ // Complex Type
if (dictionary_source == "complexTypeOneKeys")
outputMapping["host"] = "value"
else {
outputMapping["name"] = "name"
outputMapping["ipAddress"] = "ipAddress"
}
-
}
}
return outputMapping
}
-} \ No newline at end of file
+}