aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/application
diff options
context:
space:
mode:
authorFrank Kimmlingen <frank.kimmlingen@telekom.de>2023-03-07 16:36:48 +0100
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2023-03-14 00:01:38 +0000
commit36128a2e16e5eac1dd47ff36e2e2d4d17586e60f (patch)
tree24122a71fd592dd47ea4fe9e5fa44e598597aa2c /ms/blueprintsprocessor/application
parent007e52dafa0653aad80db31721a0c5e0233562c7 (diff)
Enable JUnit tests
JUnit tests are no more executed: spring-boot-starter-test does not execute any junit4 tests by default Issue-ID: CCSDK-3859 Signed-off-by: Frank Kimmlingen <frank.kimmlingen@telekom.de> Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: I02a8d25350ca62262bfc6e07c2865cd8d7b4e6b2
Diffstat (limited to 'ms/blueprintsprocessor/application')
-rwxr-xr-xms/blueprintsprocessor/application/pom.xml5
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt31
2 files changed, 20 insertions, 16 deletions
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index 11f987c9b..fa152b2b1 100755
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -141,6 +141,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<scope>test</scope>
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt
index f6dd88dd5..d233b8be3 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatServices.kt
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright © 2023 Deutche Telekom AG
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.uat.utils
import com.fasterxml.jackson.databind.ObjectMapper
+import kotlinx.coroutines.reactor.awaitSingle
import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.blueprintsprocessor.uat.logging.LogColor.COLOR_SERVICES
import org.onap.ccsdk.cds.blueprintsprocessor.uat.logging.LogColor.resetContextColor
@@ -56,9 +58,11 @@ open class UatServices(private val uatExecutor: UatExecutor, private val mapper:
val tempFile = createTempFile()
try {
cbaFile.transferTo(tempFile)
- val uatSpec = readZipEntryAsText(tempFile, UAT_SPECIFICATION_FILE)
- val cbaBytes = tempFile.readBytes()
- uatExecutor.execute(uatSpec, cbaBytes)
+ .doOnSuccess {
+ val uatSpec = readZipEntryAsText(tempFile, UAT_SPECIFICATION_FILE)
+ val cbaBytes = tempFile.readBytes()
+ uatExecutor.execute(uatSpec, cbaBytes)
+ }.subscribe()
} catch (e: AssertionError) {
throw ResponseStatusException(HttpStatus.BAD_REQUEST, e.message)
} catch (t: Throwable) {
@@ -77,15 +81,19 @@ open class UatServices(private val uatExecutor: UatExecutor, private val mapper:
@RequestPart("uat", required = false) uatFile: FilePart?
): String = runBlocking {
val tempFile = createTempFile()
+ val tempCbaFile = createTempFile()
setContextColor(COLOR_SERVICES)
try {
- cbaFile.transferTo(tempFile)
val uatSpec = when {
- uatFile != null -> uatFile.readText()
+ uatFile != null -> {
+ uatFile.transferTo(tempFile).thenReturn(tempFile).awaitSingle()
+ tempFile.readText()
+ }
else -> readZipEntryAsText(tempFile, UAT_SPECIFICATION_FILE)
}
val uat = UatDefinition.load(mapper, uatSpec)
- val cbaBytes = tempFile.readBytes()
+ cbaFile.transferTo(tempCbaFile).thenReturn(tempCbaFile).awaitSingle()
+ val cbaBytes = tempCbaFile.readBytes()
val updatedUat = uatExecutor.execute(uat, cbaBytes)
return@runBlocking updatedUat.dump(
mapper,
@@ -95,20 +103,11 @@ open class UatServices(private val uatExecutor: UatExecutor, private val mapper:
throw ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, t.message, t)
} finally {
tempFile.delete()
+ tempCbaFile.delete()
resetContextColor()
}
}
- private fun FilePart.readText(): String {
- val tempFile = createTempFile()
- try {
- transferTo(tempFile).block()
- return tempFile.readText()
- } finally {
- tempFile.delete()
- }
- }
-
@Suppress("SameParameterValue")
private fun readZipEntryAsText(file: File, entryName: String): String {
return ZipFile(file).use { zipFile -> zipFile.readEntryAsText(entryName) }