diff options
author | Dan Timoney <dtimoney@att.com> | 2020-04-30 19:48:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-30 19:48:09 +0000 |
commit | 6b6ac70007ba2b52c6beb8c0d22453a628c891f3 (patch) | |
tree | bb7652ee250367b28e7542036059d17423d9a506 /ms/blueprintsprocessor/functions/resource-resolution/src | |
parent | 7c7c3b5c0bbc83f927282e0ea9287c50365f64b5 (diff) | |
parent | 3fb8905c569e11c5c1a92ea583124e911862b596 (diff) |
Merge "Fix null safety - ResourceResolutionDBService.write"
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src')
2 files changed, 29 insertions, 5 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt index dc1553747..1a5d062a3 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt @@ -181,11 +181,11 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso resourceResolution.resolutionKey = resolutionKey resourceResolution.resourceType = resourceType resourceResolution.resourceId = resourceId - if (BluePrintConstants.STATUS_SUCCESS == resourceAssignment.status) { - resourceResolution.value = JacksonUtils.getValue(resourceAssignment.property?.value!!).toString() - } else { - resourceResolution.value = "" - } + resourceResolution.value = resourceAssignment.property?.value?.let { + if (BluePrintConstants.STATUS_SUCCESS == resourceAssignment.status) + JacksonUtils.getValue(it).toString() + else "" + } ?: "" resourceResolution.name = resourceAssignment.name resourceResolution.dictionaryName = resourceAssignment.dictionaryName resourceResolution.dictionaryVersion = resourceAssignment.version 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 e667cd16f..672d4b75d 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 @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db import io.mockk.every import io.mockk.mockk +import io.mockk.slot import kotlinx.coroutines.runBlocking import org.junit.Before import org.junit.Test @@ -225,6 +226,29 @@ open class ResourceResolutionDBServiceTest { } @Test + fun writeWithNullValue() { + val slot = slot<ResourceResolution>() + val resourceAssignment = ResourceAssignment() + resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS + resourceAssignment.dictionarySource = "ddSource" + resourceAssignment.dictionaryName = "ddName" + resourceAssignment.version = 1 + resourceAssignment.name = "test" + every { + resourceResolutionRepository.saveAndFlush(capture(slot)) + } returns ResourceResolution() + runBlocking { + resourceResolutionDBService.write( + props, bluePrintRuntimeService, artifactPrefix, resourceAssignment + ) + + val res = slot.captured + + assertEquals("", res.value) + } + } + + @Test fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyTest() { every { resourceResolutionRepository.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(any(), any(), any(), any()) |