diff options
author | 2019-11-22 18:06:08 -0500 | |
---|---|---|
committer | 2019-11-26 21:32:38 +0000 | |
commit | 341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch) | |
tree | 113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/modules/commons/rest-lib/src/test | |
parent | d274e5fc552cf9ae25500f504f0434981cf3accf (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/modules/commons/rest-lib/src/test')
3 files changed, 209 insertions, 150 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt index 1e4518a8c..53047d4a8 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt @@ -41,50 +41,59 @@ import kotlin.test.assertFailsWith import kotlin.test.assertNotNull @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BluePrintPropertyConfiguration::class, - BluePrintPropertiesService::class]) -@TestPropertySource(properties = -["blueprintsprocessor.restclient.sample.type=basic-auth", - "blueprintsprocessor.restclient.sample.url=http://localhost:8080", - "blueprintsprocessor.restclient.sample.userId=sampleuser", - "blueprintsprocessor.restclient.sslbasic.type=ssl-basic-auth", - "blueprintsprocessor.restclient.sslbasic.url=https://localhost:8443", - "blueprintsprocessor.restclient.sslbasic.username=admin", - "blueprintsprocessor.restclient.sslbasic.password=cds", - "blueprintsprocessor.restclient.sslbasic.keyStoreInstance=PKCS12", - "blueprintsprocessor.restclient.sslbasic.sslTrust=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.sslbasic.sslTrustPassword=changeit", - "blueprintsprocessor.restclient.ssltoken.type=ssl-token-auth", - "blueprintsprocessor.restclient.ssltoken.url=https://localhost:8443", - "blueprintsprocessor.restclient.ssltoken.token=72178473kjshdkjgvbsdkjv903274908", - "blueprintsprocessor.restclient.ssltoken.keyStoreInstance=PKCS12", - "blueprintsprocessor.restclient.ssltoken.sslTrust=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.ssltoken.sslTrustPassword=changeit", - "blueprintsprocessor.restclient.ssl.type=ssl-no-auth", - "blueprintsprocessor.restclient.ssl.url=https://localhost:8443", - "blueprintsprocessor.restclient.ssl.keyStoreInstance=PKCS12", - "blueprintsprocessor.restclient.ssl.sslTrust=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.ssl.sslTrustPassword=changeit", - "blueprintsprocessor.restclient.ssl.sslKey=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit" -]) +@ContextConfiguration( + classes = [BluePrintRestLibConfiguration::class, BluePrintPropertyConfiguration::class, + BluePrintPropertiesService::class] +) +@TestPropertySource( + properties = + ["blueprintsprocessor.restclient.sample.type=basic-auth", + "blueprintsprocessor.restclient.sample.url=http://localhost:8080", + "blueprintsprocessor.restclient.sample.userId=sampleuser", + "blueprintsprocessor.restclient.sslbasic.type=ssl-basic-auth", + "blueprintsprocessor.restclient.sslbasic.url=https://localhost:8443", + "blueprintsprocessor.restclient.sslbasic.username=admin", + "blueprintsprocessor.restclient.sslbasic.password=cds", + "blueprintsprocessor.restclient.sslbasic.keyStoreInstance=PKCS12", + "blueprintsprocessor.restclient.sslbasic.sslTrust=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.sslbasic.sslTrustPassword=changeit", + "blueprintsprocessor.restclient.ssltoken.type=ssl-token-auth", + "blueprintsprocessor.restclient.ssltoken.url=https://localhost:8443", + "blueprintsprocessor.restclient.ssltoken.token=72178473kjshdkjgvbsdkjv903274908", + "blueprintsprocessor.restclient.ssltoken.keyStoreInstance=PKCS12", + "blueprintsprocessor.restclient.ssltoken.sslTrust=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.ssltoken.sslTrustPassword=changeit", + "blueprintsprocessor.restclient.ssl.type=ssl-no-auth", + "blueprintsprocessor.restclient.ssl.url=https://localhost:8443", + "blueprintsprocessor.restclient.ssl.keyStoreInstance=PKCS12", + "blueprintsprocessor.restclient.ssl.sslTrust=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.ssl.sslTrustPassword=changeit", + "blueprintsprocessor.restclient.ssl.sslKey=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit" + ] +) class BluePrintRestLibPropertyServiceTest { + @Autowired lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService @Test fun testRestClientProperties() { val properties = bluePrintRestLibPropertyService.restClientProperties( - "blueprintsprocessor.restclient.sample") + "blueprintsprocessor.restclient.sample" + ) assertNotNull(properties, "failed to create property bean") - assertNotNull(properties.url, "failed to get url property in" + - " property bean") + assertNotNull( + properties.url, "failed to get url property in" + + " property bean" + ) } @Test fun testSSLBasicProperties() { val properties = bluePrintRestLibPropertyService.restClientProperties( - "blueprintsprocessor.restclient.sslbasic") + "blueprintsprocessor.restclient.sslbasic" + ) assertNotNull(properties, "failed to create property bean") val p: SSLBasicAuthRestClientProperties = properties as SSLBasicAuthRestClientProperties @@ -99,7 +108,8 @@ class BluePrintRestLibPropertyServiceTest { @Test fun testSSLTokenProperties() { val properties = bluePrintRestLibPropertyService.restClientProperties( - "blueprintsprocessor.restclient.ssltoken") + "blueprintsprocessor.restclient.ssltoken" + ) assertNotNull(properties, "failed to create property bean") val p: SSLTokenAuthRestClientProperties = @@ -114,7 +124,8 @@ class BluePrintRestLibPropertyServiceTest { @Test fun testSSLNoAuthProperties() { val properties = bluePrintRestLibPropertyService.restClientProperties( - "blueprintsprocessor.restclient.ssl") + "blueprintsprocessor.restclient.ssl" + ) assertNotNull(properties, "failed to create property bean") val p: SSLRestClientProperties = @@ -127,12 +138,12 @@ class BluePrintRestLibPropertyServiceTest { assertEquals(p.sslKeyPassword, "changeit") } - @Test fun testSSLBasicPropertiesAsJson() { val actualObj: JsonNode = defaultMapper.readTree(sslBasicAuthEndpointWithHeadersField()) val properties = bluePrintRestLibPropertyService.restClientProperties( - actualObj) + actualObj + ) assertNotNull(properties, "failed to create property bean") val p: SSLBasicAuthRestClientProperties = properties as SSLBasicAuthRestClientProperties @@ -166,7 +177,8 @@ class BluePrintRestLibPropertyServiceTest { fun testSSLNoAuthPropertiesAsJson() { val actualObj: JsonNode = defaultMapper.readTree(sslNoAuthEndpointWithHeadersField()) val properties = bluePrintRestLibPropertyService.restClientProperties( - actualObj) + actualObj + ) assertNotNull(properties, "failed to create property bean") val p: SSLRestClientProperties = @@ -185,8 +197,10 @@ class BluePrintRestLibPropertyServiceTest { fun testBlueprintWebClientService() { val blueprintWebClientService = bluePrintRestLibPropertyService .blueprintWebClientService("sample") - assertNotNull(blueprintWebClientService, - "failed to create blueprintWebClientService") + assertNotNull( + blueprintWebClientService, + "failed to create blueprintWebClientService" + ) } @Test @@ -197,7 +211,7 @@ class BluePrintRestLibPropertyServiceTest { assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService") } - //pass the result of $typeEndpointWithHeadersField() output with and without headers to compare. + // pass the result of $typeEndpointWithHeadersField() output with and without headers to compare. private fun validateHeadersDidNotChangeWithEmptyAdditionalHeaders(noHeaders: String, withHeaders: String) { val parsedObj: JsonNode = defaultMapper.readTree(noHeaders) val bpWebClientService = @@ -208,7 +222,7 @@ class BluePrintRestLibPropertyServiceTest { val bpWebClientServiceWithHeaders = bluePrintRestLibPropertyService.blueprintWebClientService(parsedObjWithHeaders) val extractedHeadersWithAdditionalHeaders = bpWebClientServiceWithHeaders.convertToBasicHeaders(mapOf()) - //Array<BasicHeader<>> -> Map<String,String> + // Array<BasicHeader<>> -> Map<String,String> val headersMap = extractedHeaders.map { it.name to it.value }.toMap() val additionalHeadersMap = extractedHeadersWithAdditionalHeaders.map { it.name to it.value }.toMap() assertEquals(headersMap, additionalHeadersMap) @@ -256,18 +270,20 @@ class BluePrintRestLibPropertyServiceTest { val bpWebClientService = bluePrintRestLibPropertyService.blueprintWebClientService(parsedObj) val extractedHeaders = bpWebClientService.convertToBasicHeaders(mapOf()) - assertEquals(MediaType.APPLICATION_XML.toString(), - extractedHeaders.filter { it.name == HttpHeaders.CONTENT_TYPE }[0].value!!) + assertEquals( + MediaType.APPLICATION_XML.toString(), + extractedHeaders.filter { it.name == HttpHeaders.CONTENT_TYPE }[0].value!! + ) } @Test fun `BasicAuth WebClientService additionalHeaders can overwrite default Content-Type`() { - //default content type is application/json + // default content type is application/json val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(contentTypeAdditionalHeader) additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson) } - //called from within "assertFailsWith(exceptionClass = BluePrintProcessorException::class) {" + // called from within "assertFailsWith(exceptionClass = BluePrintProcessorException::class) {" private fun attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson: String) { val parsedObj: JsonNode = defaultMapper.readTree(endPointWithHeadersJson) val bpWebClientService = @@ -281,7 +297,7 @@ class BluePrintRestLibPropertyServiceTest { val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(additionalHeadersWithAuth) attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) } - //spec says headers are case insensitive... + // spec says headers are case insensitive... assertFailsWith(exceptionClass = BluePrintProcessorException::class) { val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased) attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) @@ -309,7 +325,7 @@ class BluePrintRestLibPropertyServiceTest { @Test fun `TokenAuth WebClientService additionalHeaders can overwrite default Content-Type`() { - //default content type is application/json + // default content type is application/json val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(contentTypeAdditionalHeader) additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson) } @@ -320,14 +336,14 @@ class BluePrintRestLibPropertyServiceTest { val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(additionalHeadersWithAuth) attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) } - //spec says headers are case insensitive... + // spec says headers are case insensitive... assertFailsWith(exceptionClass = BluePrintProcessorException::class) { val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased) attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) } } - //TESTS FOR SSL BASIC AUTH headers + // TESTS FOR SSL BASIC AUTH headers @Test fun `SSLBasicAuth WebClientService with empty additionalHeaders does not modify headers`() { val endPointJson = sslBasicAuthEndpointWithHeadersField() @@ -349,7 +365,7 @@ class BluePrintRestLibPropertyServiceTest { @Test fun `SSLBasicAuth WebClientService additionalHeaders can overwrite default Content-Type`() { - //default content type is application/json + // default content type is application/json val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(contentTypeAdditionalHeader) additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson) } @@ -360,14 +376,14 @@ class BluePrintRestLibPropertyServiceTest { val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(additionalHeadersWithAuth) attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) } - //spec says headers are case insensitive... + // spec says headers are case insensitive... assertFailsWith(exceptionClass = BluePrintProcessorException::class) { val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased) attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) } } - //SSL-NO-AUTH headers tests + // SSL-NO-AUTH headers tests @Test fun `SSLNoAuth WebClientService with empty additionalHeaders does not modify headers`() { val endPointJson = sslNoAuthEndpointWithHeadersField() @@ -389,7 +405,7 @@ class BluePrintRestLibPropertyServiceTest { @Test fun `SSLNoAuth WebClientService additionalHeaders can overwrite default Content-Type`() { - //default content type is application/json + // default content type is application/json val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(contentTypeAdditionalHeader) additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson) } @@ -400,7 +416,7 @@ class BluePrintRestLibPropertyServiceTest { val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(additionalHeadersWithAuth) attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) } - //spec says headers are case insensitive... + // spec says headers are case insensitive... assertFailsWith(exceptionClass = BluePrintProcessorException::class) { val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased) attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) @@ -412,12 +428,15 @@ class BluePrintRestLibPropertyServiceTest { val expectedTokenAuthDefaultHeaders = mapOf<String, String>( "Content-Type" to "application/json", "Accept" to "application/json", - "Authorization" to "72178473kjshdkjgvbsdkjv903274908") + "Authorization" to "72178473kjshdkjgvbsdkjv903274908" + ) - val endPointWithHeadersJsonWithBasicAuthHeader = basicAuthEndpointWithHeadersField(""", + val endPointWithHeadersJsonWithBasicAuthHeader = basicAuthEndpointWithHeadersField( + """, "additionalHeaders" : { "authorization": "Basic aGF2ZTphbmljZWRheQo=" - }""".trimIndent()) + }""".trimIndent() + ) private fun sslTokenAuthEndpointWithHeadersField(headers: String = ""): String = """{ @@ -455,7 +474,7 @@ class BluePrintRestLibPropertyServiceTest { "sslKeyPassword" : "changeit"$headers }""".trimIndent() - //Don't forget to supply "," as the first char to make valid JSON + // Don't forget to supply "," as the first char to make valid JSON private fun basicAuthEndpointWithHeadersField(headers: String = ""): String = """{ "type": "basic-auth", @@ -496,4 +515,3 @@ class BluePrintRestLibPropertyServiceTest { }""".trimIndent() } } - diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt index 15133fa8a..f82fc6124 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt @@ -24,7 +24,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import kotlin.test.assertNotNull class RestClientPropertiesDSLTest { - + @Test fun testBasicAuthRestClientProperties() { val properties = BluePrintTypes.dslBasicAuthRestClientProperties { @@ -56,4 +56,4 @@ class RestClientPropertiesDSLTest { } assertNotNull(properties, "failed to get dslSSLRestClientProperties") } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt index 05f32904a..fa357e1fe 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt @@ -48,45 +48,56 @@ import org.springframework.security.web.server.SecurityWebFilterChain import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PatchMapping +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.PutMapping +import org.springframework.web.bind.annotation.RequestHeader +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController import kotlin.test.assertEquals import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class]) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) -@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, SampleController::class, - SecurityConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]) -@TestPropertySource(properties = -[ - "server.port=8443", - "server.ssl.enabled=true", - "server.ssl.key-store=classpath:keystore.p12", - "server.ssl.key-store-password=changeit", - "server.ssl.keyStoreType=PKCS12", - "server.ssl.keyAlias=tomcat", - "blueprintsprocessor.restclient.sample.type=basic-auth", - "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8081", - "blueprintsprocessor.restclient.sample.username=admin", - "blueprintsprocessor.restclient.sample.password=jans", - "blueprintsprocessor.restclient.test.type=ssl-basic-auth", - "blueprintsprocessor.restclient.test.url=https://localhost:8443", - "blueprintsprocessor.restclient.test.username=admin", - "blueprintsprocessor.restclient.test.password=jans", - "blueprintsprocessor.restclient.test.keyStoreInstance=PKCS12", - "blueprintsprocessor.restclient.test.sslTrust=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.test.sslTrustPassword=changeit" -]) +@ContextConfiguration( + classes = [BluePrintRestLibConfiguration::class, SampleController::class, + SecurityConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class] +) +@TestPropertySource( + properties = + [ + "server.port=8443", + "server.ssl.enabled=true", + "server.ssl.key-store=classpath:keystore.p12", + "server.ssl.key-store-password=changeit", + "server.ssl.keyStoreType=PKCS12", + "server.ssl.keyAlias=tomcat", + "blueprintsprocessor.restclient.sample.type=basic-auth", + "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8081", + "blueprintsprocessor.restclient.sample.username=admin", + "blueprintsprocessor.restclient.sample.password=jans", + "blueprintsprocessor.restclient.test.type=ssl-basic-auth", + "blueprintsprocessor.restclient.test.url=https://localhost:8443", + "blueprintsprocessor.restclient.test.username=admin", + "blueprintsprocessor.restclient.test.password=jans", + "blueprintsprocessor.restclient.test.keyStoreInstance=PKCS12", + "blueprintsprocessor.restclient.test.sslTrust=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.test.sslTrustPassword=changeit" + ] +) class RestClientServiceTest { @Autowired lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService @Autowired - lateinit var httpHandler : HttpHandler + lateinit var httpHandler: HttpHandler - lateinit var http : WebServer + lateinit var http: WebServer fun localPort() = http.port @@ -106,21 +117,26 @@ class RestClientServiceTest { @Test fun testPatch() { val restClientService = bluePrintRestLibPropertyService - .blueprintWebClientService("sample") + .blueprintWebClientService("sample") val response = restClientService.exchangeResource( - HttpMethod.PATCH.name, "/sample/name", "") - assertEquals("Patch request successful", response.body, - "failed to get patch response") + HttpMethod.PATCH.name, "/sample/name", "" + ) + assertEquals( + "Patch request successful", response.body, + "failed to get patch response" + ) } @Test fun testBaseAuth() { val restClientService = bluePrintRestLibPropertyService - .blueprintWebClientService("sample") + .blueprintWebClientService("sample") val headers = mutableMapOf<String, String>() headers["X-Transaction-Id"] = "1234" - val response = restClientService.exchangeResource(HttpMethod.GET.name, - "/sample/name", "") + val response = restClientService.exchangeResource( + HttpMethod.GET.name, + "/sample/name", "" + ) assertNotNull(response.body, "failed to get response") } @@ -135,12 +151,15 @@ class RestClientServiceTest { val mapper = ObjectMapper() val actualObj: JsonNode = mapper.readTree(json) val restClientService = bluePrintRestLibPropertyService - .blueprintWebClientService(actualObj) - lateinit var res:String + .blueprintWebClientService(actualObj) + lateinit var res: String runBlocking { val get = async(start = CoroutineStart.LAZY) { - restClientService.exchangeNB(HttpMethod.GET.name, - "/sample/basic", "").body} + restClientService.exchangeNB( + HttpMethod.GET.name, + "/sample/basic", "" + ).body + } get.start() res = get.await() } @@ -151,7 +170,7 @@ class RestClientServiceTest { @Test fun testSampleAaiReq() { val restClientService = bluePrintRestLibPropertyService - .blueprintWebClientService("test") + .blueprintWebClientService("test") val headers = mutableMapOf<String, String>() headers["X-TransactionId"] = "9999" headers["X-FromAppId"] = "AAI" @@ -171,34 +190,52 @@ class RestClientServiceTest { lateinit var res6: String runBlocking { val get1 = async(start = CoroutineStart.LAZY) { - restClientService.exchangeNB(HttpMethod.GET.name, - "/sample/aai/v14/business/customers", "", headers, - Customer::class.java).body} + restClientService.exchangeNB( + HttpMethod.GET.name, + "/sample/aai/v14/business/customers", "", headers, + Customer::class.java + ).body + } val get2 = async(start = CoroutineStart.LAZY) { - restClientService.exchangeNB(HttpMethod.GET.name, - "/sample/aai/v14/business/customers", "", headers, - Customer::class.java).body} + restClientService.exchangeNB( + HttpMethod.GET.name, + "/sample/aai/v14/business/customers", "", headers, + Customer::class.java + ).body + } val post = async(start = CoroutineStart.LAZY) { - restClientService.exchangeNB(HttpMethod.POST.name, - "/sample/aai/v14/business/customers", post1, headers, - String::class.java).body} + restClientService.exchangeNB( + HttpMethod.POST.name, + "/sample/aai/v14/business/customers", post1, headers, + String::class.java + ).body + } val put = async(start = CoroutineStart.LAZY) { - restClientService.exchangeNB(HttpMethod.PUT.name, - "/sample/aai/v14/business/customers", post1, headers, - String::class.java).body} + restClientService.exchangeNB( + HttpMethod.PUT.name, + "/sample/aai/v14/business/customers", post1, headers, + String::class.java + ).body + } val patch = async(start = CoroutineStart.LAZY) { - restClientService.exchangeNB(HttpMethod.PATCH.name, - "/sample/aai/v14/business/customers", post1, headers, - String::class.java).body} + restClientService.exchangeNB( + HttpMethod.PATCH.name, + "/sample/aai/v14/business/customers", post1, headers, + String::class.java + ).body + } val delete = async(start = CoroutineStart.LAZY) { - restClientService.exchangeNB(HttpMethod.DELETE.name, - "/sample/aai/v14/business/customers", "", headers, - String::class.java).body} + restClientService.exchangeNB( + HttpMethod.DELETE.name, + "/sample/aai/v14/business/customers", "", headers, + String::class.java + ).body + } get1.start() get2.start() @@ -246,13 +283,13 @@ open class SampleController { @GetMapping("/basic") fun getBasic(): String = "Basic request arrived successfully" - @GetMapping("/aai/v14/business/customers") fun getAaiCustomers( - @RequestHeader(name = "X-TransactionId", required = true) - transId: String, - @RequestHeader(name = "X-FromAppId", required = true) - appId: String) : String { + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String + ): String { if (transId != "9999" || appId != "AAI") { return "" } @@ -266,23 +303,24 @@ open class SampleController { @PostMapping("/aai/v14/business/customers") fun postAaiCustomers( - @RequestHeader(name = "X-TransactionId", required = true) - transId: String, - @RequestHeader(name = "X-FromAppId", required = true) - appId: String) : String { + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String + ): String { if (transId != "9999" || appId != "AAI") { return "" } return "The message is successfully posted" } - @PutMapping("/aai/v14/business/customers") fun putAaiCustomers( - @RequestHeader(name = "X-TransactionId", required = true) - transId: String, - @RequestHeader(name = "X-FromAppId", required = true) - appId: String) : String { + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String + ): String { if (transId != "9999" || appId != "AAI") { return "" } @@ -291,10 +329,11 @@ open class SampleController { @PatchMapping("/aai/v14/business/customers") fun patchAaiCustomers( - @RequestHeader(name = "X-TransactionId", required = true) - transId: String, - @RequestHeader(name = "X-FromAppId", required = true) - appId: String) : String { + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String + ): String { if (transId != "9999" || appId != "AAI") { return "" } @@ -303,10 +342,11 @@ open class SampleController { @DeleteMapping("/aai/v14/business/customers") fun deleteAaiCustomers( - @RequestHeader(name = "X-TransactionId", required = true) - transId: String, - @RequestHeader(name = "X-FromAppId", required = true) - appId: String) : String { + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String + ): String { if (transId != "9999" || appId != "AAI") { return "" } @@ -323,20 +363,20 @@ open class SecurityConfiguration { @Bean open fun userDetailsService(): MapReactiveUserDetailsService { val user: UserDetails = User.withDefaultPasswordEncoder() - .username("admin") - .password("jans") - .roles("USER") - .build() + .username("admin") + .password("jans") + .roles("USER") + .build() return MapReactiveUserDetailsService(user) } @Bean open fun springSecurityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { return http - .csrf().disable() - .authorizeExchange().anyExchange().authenticated() - .and().httpBasic() - .and().build() + .csrf().disable() + .authorizeExchange().anyExchange().authenticated() + .and().httpBasic() + .and().build() } } @@ -344,7 +384,8 @@ open class SecurityConfiguration { * Data class required for response */ data class Customer( - val id: String, - val name: String, - val type: String, - val resource: String) + val id: String, + val name: String, + val type: String, + val resource: String +) |