aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/application/src/test/kotlin
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/application/src/test/kotlin
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/application/src/test/kotlin')
-rw-r--r--ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BaseUatTest.kt12
-rw-r--r--ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt24
-rw-r--r--ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/ExtendedTemporaryFolder.kt7
-rw-r--r--ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/TestSecuritySettings.kt9
-rw-r--r--ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServicesTest.kt47
-rw-r--r--ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/WorkingFoldersInitializer.kt12
6 files changed, 64 insertions, 47 deletions
diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BaseUatTest.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BaseUatTest.kt
index ec338f274..0ff5dc55d 100644
--- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BaseUatTest.kt
+++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BaseUatTest.kt
@@ -33,10 +33,12 @@ import kotlin.test.BeforeTest
@RunWith(SpringRunner::class)
// Also set blueprintsprocessor.httpPort=0
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(initializers = [
- WorkingFoldersInitializer::class,
- TestSecuritySettings.ServerContextInitializer::class
-])
+@ContextConfiguration(
+ initializers = [
+ WorkingFoldersInitializer::class,
+ TestSecuritySettings.ServerContextInitializer::class
+ ]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
abstract class BaseUatTest {
@@ -53,4 +55,4 @@ abstract class BaseUatTest {
companion object {
const val UAT_BLUEPRINTS_BASE_DIR = "../../../components/model-catalog/blueprint-model/uat-blueprints"
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt
index fa550d1d0..ad97ce82a 100644
--- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt
+++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt
@@ -38,8 +38,10 @@ import kotlin.test.Test
// Only one runner can be configured with jUnit 4. We had to replace the SpringRunner by equivalent jUnit rules.
// See more on https://docs.spring.io/autorepo/docs/spring-framework/current/spring-framework-reference/testing.html#testcontext-junit4-rules
@RunWith(Parameterized::class)
-class BlueprintsAcceptanceTest(@Suppress("unused") private val blueprintName: String, // readable test description
- private val rootFs: FileSystem) : BaseUatTest() {
+class BlueprintsAcceptanceTest(
+ @Suppress("unused") private val blueprintName: String, // readable test description
+ private val rootFs: FileSystem
+) : BaseUatTest() {
companion object {
@@ -55,14 +57,14 @@ class BlueprintsAcceptanceTest(@Suppress("unused") private val blueprintName: St
@JvmStatic
fun scanUatEmpoweredBlueprints(): List<Array<Any>> {
return (File(UAT_BLUEPRINTS_BASE_DIR)
- .listFiles { file -> file.isDirectory && File(file, UAT_SPECIFICATION_FILE).isFile }
- ?: throw RuntimeException("Failed to scan $UAT_BLUEPRINTS_BASE_DIR"))
- .map { file ->
- arrayOf(
- file.nameWithoutExtension,
- FileSystems.newFileSystem(file.canonicalFile.toPath(), null)
- )
- }
+ .listFiles { file -> file.isDirectory && File(file, UAT_SPECIFICATION_FILE).isFile }
+ ?: throw RuntimeException("Failed to scan $UAT_BLUEPRINTS_BASE_DIR"))
+ .map { file ->
+ arrayOf(
+ file.nameWithoutExtension,
+ FileSystems.newFileSystem(file.canonicalFile.toPath(), null)
+ )
+ }
}
}
@@ -91,4 +93,4 @@ class BlueprintsAcceptanceTest(@Suppress("unused") private val blueprintName: St
uatExecutor.execute(uatSpec, cbaBytes)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/ExtendedTemporaryFolder.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/ExtendedTemporaryFolder.kt
index 1c0067c36..c483d90b3 100644
--- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/ExtendedTemporaryFolder.kt
+++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/ExtendedTemporaryFolder.kt
@@ -21,8 +21,11 @@ package org.onap.ccsdk.cds.blueprintsprocessor.uat
import java.io.File
import java.io.IOException
-import java.nio.file.*
-import java.nio.file.attribute.*
+import java.nio.file.FileVisitResult
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.SimpleFileVisitor
+import java.nio.file.attribute.BasicFileAttributes
import javax.annotation.PreDestroy
class ExtendedTemporaryFolder {
diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/TestSecuritySettings.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/TestSecuritySettings.kt
index 216df9aef..b0917cb7d 100644
--- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/TestSecuritySettings.kt
+++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/TestSecuritySettings.kt
@@ -30,14 +30,15 @@ class TestSecuritySettings {
private const val authPassword = "Heisenberg"
fun clientAuthToken() =
- "Basic " + Base64Utils.encodeToString("$authUsername:$authPassword".toByteArray())
+ "Basic " + Base64Utils.encodeToString("$authUsername:$authPassword".toByteArray())
}
class ServerContextInitializer : ApplicationContextInitializer<ConfigurableApplicationContext> {
override fun initialize(context: ConfigurableApplicationContext) {
- TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context,
- "security.user.name=$authUsername",
- "security.user.password={noop}$authPassword"
+ TestPropertySourceUtils.addInlinedPropertiesToEnvironment(
+ context,
+ "security.user.name=$authUsername",
+ "security.user.password={noop}$authPassword"
)
}
}
diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServicesTest.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServicesTest.kt
index 78dc7099c..2df5f2940 100644
--- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServicesTest.kt
+++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServicesTest.kt
@@ -108,7 +108,7 @@ class UatServicesTest : BaseUatTest() {
}
private fun inlinedPropertySource(): MutableMap<String, Any> =
- (environment.propertySources[INLINED_PROPERTIES_PROPERTY_SOURCE_NAME] as MapPropertySource).source
+ (environment.propertySources[INLINED_PROPERTIES_PROPERTY_SOURCE_NAME] as MapPropertySource).source
@LocalServerPort
var localServerPort: Int = 0
@@ -122,11 +122,15 @@ class UatServicesTest : BaseUatTest() {
@BeforeTest
fun setupHttpClient() {
- val defaultHeaders = listOf(BasicHeader(org.apache.http.HttpHeaders.AUTHORIZATION,
- TestSecuritySettings.clientAuthToken()))
+ val defaultHeaders = listOf(
+ BasicHeader(
+ org.apache.http.HttpHeaders.AUTHORIZATION,
+ TestSecuritySettings.clientAuthToken()
+ )
+ )
httpClient = HttpClientBuilder.create()
- .setDefaultHeaders(defaultHeaders)
- .build()
+ .setDefaultHeaders(defaultHeaders)
+ .build()
}
@Test
@@ -134,9 +138,9 @@ class UatServicesTest : BaseUatTest() {
// GIVEN
val cbaBytes = compressToBytes(BLUEPRINT_BASE_DIR)
val multipartEntity = MultipartEntityBuilder.create()
- .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
- .addBinaryBody("cba", cbaBytes, ContentType.DEFAULT_BINARY, "cba.zip")
- .build()
+ .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
+ .addBinaryBody("cba", cbaBytes, ContentType.DEFAULT_BINARY, "cba.zip")
+ .build()
val request = HttpPost("$baseUrl/api/v1/uat/verify").apply {
entity = multipartEntity
}
@@ -168,10 +172,10 @@ class UatServicesTest : BaseUatTest() {
val cbaBytes = compressToBytes(BLUEPRINT_BASE_DIR)
val multipartEntity = MultipartEntityBuilder.create()
- .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
- .addBinaryBody("cba", cbaBytes, ContentType.DEFAULT_BINARY, "cba.zip")
- .addBinaryBody("uat", bareUatBytes, ContentType.DEFAULT_BINARY, "uat.yaml")
- .build()
+ .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
+ .addBinaryBody("cba", cbaBytes, ContentType.DEFAULT_BINARY, "cba.zip")
+ .addBinaryBody("uat", bareUatBytes, ContentType.DEFAULT_BINARY, "uat.yaml")
+ .build()
val request = HttpPost("$baseUrl/api/v1/uat/spy").apply {
entity = multipartEntity
}
@@ -193,7 +197,8 @@ class UatServicesTest : BaseUatTest() {
}
private fun createMockServer(service: ServiceDefinition): WireMockServer {
- val mockServer = WireMockServer(wireMockConfig()
+ val mockServer = WireMockServer(
+ wireMockConfig()
.dynamicPort()
.notifier(MarkedSlf4jNotifier(wireMockMarker))
)
@@ -212,10 +217,10 @@ class UatServicesTest : BaseUatTest() {
}
val responseDefinitionBuilder: ResponseDefinitionBuilder = aResponse()
- .withStatus(response.status)
+ .withStatus(response.status)
if (response.body != null) {
responseDefinitionBuilder.withBody(mapper.writeValueAsBytes(response.body))
- .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
+ .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
}
mappingBuilder.willReturn(responseDefinitionBuilder)
@@ -229,11 +234,11 @@ class UatServicesTest : BaseUatTest() {
val selector = service.selector
val httpPort = mockServer.port()
val properties = mapOf(
- "blueprintsprocessor.restclient.$selector.type" to "basic-auth",
- "blueprintsprocessor.restclient.$selector.url" to "http://localhost:$httpPort/",
- // TODO credentials should be validated
- "blueprintsprocessor.restclient.$selector.username" to "admin",
- "blueprintsprocessor.restclient.$selector.password" to "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
+ "blueprintsprocessor.restclient.$selector.type" to "basic-auth",
+ "blueprintsprocessor.restclient.$selector.url" to "http://localhost:$httpPort/",
+ // TODO credentials should be validated
+ "blueprintsprocessor.restclient.$selector.username" to "admin",
+ "blueprintsprocessor.restclient.$selector.password" to "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
)
setProperties(properties)
}
@@ -257,4 +262,4 @@ class UatServicesTest : BaseUatTest() {
val map: Map<String, Any> = Yaml().load(yaml)
return mapper.writeValueAsString(map)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/WorkingFoldersInitializer.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/WorkingFoldersInitializer.kt
index ab9ae31a0..3c1757432 100644
--- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/WorkingFoldersInitializer.kt
+++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/WorkingFoldersInitializer.kt
@@ -32,16 +32,20 @@ class WorkingFoldersInitializer : ApplicationContextInitializer<ConfigurableAppl
override fun initialize(context: ConfigurableApplicationContext) {
val tempFolder = ExtendedTemporaryFolder()
val properties = listOf("Deploy", "Archive", "Working")
- .map { "blueprintsprocessor.blueprint${it}Path=${tempFolder.newFolder(it)}" }
- .toTypedArray()
+ .map { "blueprintsprocessor.blueprint${it}Path=${tempFolder.newFolder(it)}" }
+ .toTypedArray()
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, *properties)
// Expose tempFolder as a bean so it can be accessed via DI
registerSingleton(context, "tempFolder", ExtendedTemporaryFolder::class.java, tempFolder)
}
@Suppress("SameParameterValue")
- private fun <T> registerSingleton(context: ConfigurableApplicationContext,
- beanName: String, beanClass: Class<T>, instance: T) {
+ private fun <T> registerSingleton(
+ context: ConfigurableApplicationContext,
+ beanName: String,
+ beanClass: Class<T>,
+ instance: T
+ ) {
val builder = BeanDefinitionBuilder.genericBeanDefinition(beanClass) { instance }
(context.beanFactory as BeanDefinitionRegistry).registerBeanDefinition(beanName, builder.beanDefinition)
}