aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/application/src/main/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/main/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/main/kotlin')
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.kt22
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintHttpServer.kt2
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.kt31
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/WebConfig.kt34
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt6
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/AuthenticationManager.kt7
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt30
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityConfiguration.kt8
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityContextRepository.kt16
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/JsonNormalizer.kt8
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/PathDeserializer.kt2
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/RequiredMapEntriesMatcher.kt (renamed from ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/MoreMatchers.kt)0
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatDefinition.kt38
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt124
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServices.kt8
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/ColorMarker.kt2
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/LogColor.kt2
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt8
18 files changed, 194 insertions, 154 deletions
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.kt
index 2d39eaa1f..bfde39aa0 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.kt
@@ -30,10 +30,12 @@ import org.springframework.stereotype.Component
@ConditionalOnProperty(name = ["blueprintsprocessor.grpcEnable"], havingValue = "true")
@Component
-open class BlueprintGRPCServer(private val bluePrintProcessingGRPCHandler: BluePrintProcessingGRPCHandler,
- private val bluePrintManagementGRPCHandler: BluePrintManagementGRPCHandler,
- private val authInterceptor: BasicAuthServerInterceptor)
- : ApplicationListener<ContextRefreshedEvent> {
+open class BlueprintGRPCServer(
+ private val bluePrintProcessingGRPCHandler: BluePrintProcessingGRPCHandler,
+ private val bluePrintManagementGRPCHandler: BluePrintManagementGRPCHandler,
+ private val authInterceptor: BasicAuthServerInterceptor
+) :
+ ApplicationListener<ContextRefreshedEvent> {
private val log = logger(BlueprintGRPCServer::class)
@@ -44,12 +46,12 @@ open class BlueprintGRPCServer(private val bluePrintProcessingGRPCHandler: BlueP
try {
log.info("Starting Blueprint Processor GRPC Starting..")
val server = ServerBuilder
- .forPort(grpcPort!!)
- .intercept(GrpcServerLoggingInterceptor())
- .intercept(authInterceptor)
- .addService(bluePrintProcessingGRPCHandler)
- .addService(bluePrintManagementGRPCHandler)
- .build()
+ .forPort(grpcPort!!)
+ .intercept(GrpcServerLoggingInterceptor())
+ .intercept(authInterceptor)
+ .addService(bluePrintProcessingGRPCHandler)
+ .addService(bluePrintManagementGRPCHandler)
+ .build()
server.start()
log.info("Blueprint Processor GRPC server started and ready to serve on port({})...", server.port)
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintHttpServer.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintHttpServer.kt
index 4251fb5cb..f152e307f 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintHttpServer.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintHttpServer.kt
@@ -30,4 +30,4 @@ open class BlueprintHttpServer : WebServerFactoryCustomizer<NettyReactiveWebServ
override fun customize(serverFactory: NettyReactiveWebServerFactory) {
serverFactory.port = httpPort!!
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.kt
index a8ee57d9d..243533b66 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.kt
@@ -33,28 +33,29 @@ import springfox.documentation.spring.web.plugins.Docket
* @author Brinda Santh
*/
@Configuration
-//@EnableSwagger2WebFlux
+// @EnableSwagger2WebFlux
open class SwaggerConfig {
@Bean
open fun api(): Docket {
return Docket(DocumentationType.SWAGGER_2)
- .select()
- .apis(RequestHandlerSelectors.withClassAnnotation(Api::class.java))
- .paths(PathSelectors.any())
- .build()
- .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.withClassAnnotation(Api::class.java))
+ .paths(PathSelectors.any())
+ .build()
+ .apiInfo(apiInfo())
}
private fun apiInfo(): ApiInfo {
return ApiInfo(
- "CDS Blueprints Processor APIs",
- "Provide APIs to interact with CBA, their resolved resources and templates, and stored resource configurations.",
- "0.7.0",
- null,
- Contact("CCSDK Team", "www.onap.org", "onap-discuss@lists.onap.org"),
- "Apache 2.0",
- "http://www.apache.org/licenses/LICENSE-2.0",
- emptyList())
+ "CDS Blueprints Processor APIs",
+ "Provide APIs to interact with CBA, their resolved resources and templates, and stored resource configurations.",
+ "0.7.0",
+ null,
+ Contact("CCSDK Team", "www.onap.org", "onap-discuss@lists.onap.org"),
+ "Apache 2.0",
+ "http://www.apache.org/licenses/LICENSE-2.0",
+ emptyList()
+ )
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/WebConfig.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/WebConfig.kt
index 5b12d8df7..d2d01cc64 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/WebConfig.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/WebConfig.kt
@@ -34,36 +34,38 @@ import org.springframework.web.reactive.config.WebFluxConfigurer
* @author Brinda Santh
*/
@Configuration
-open class WebConfig(private val authenticationManager: AuthenticationManager,
- private val securityContextRepository: SecurityContextRepository) : WebFluxConfigurer {
+open class WebConfig(
+ private val authenticationManager: AuthenticationManager,
+ private val securityContextRepository: SecurityContextRepository
+) : WebFluxConfigurer {
override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry.addResourceHandler("/swagger-ui.html**")
- .addResourceLocations("classpath:/META-INF/resources/")
+ .addResourceLocations("classpath:/META-INF/resources/")
registry.addResourceHandler("/webjars/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/")
+ .addResourceLocations("classpath:/META-INF/resources/webjars/")
}
override fun addCorsMappings(corsRegistry: CorsRegistry) {
corsRegistry.addMapping("/**")
- .allowedOrigins("*")
- .allowedMethods("*")
- .allowedHeaders("*")
- .maxAge(3600)
+ .allowedOrigins("*")
+ .allowedMethods("*")
+ .allowedHeaders("*")
+ .maxAge(3600)
}
@Bean
open fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
return http.csrf().disable()
- .formLogin().disable()
- .httpBasic().disable()
- .authenticationManager(authenticationManager)
- .securityContextRepository(securityContextRepository!!)
- .authorizeExchange()
- .pathMatchers(HttpMethod.OPTIONS).permitAll()
- .anyExchange().authenticated()
- .and().build()
+ .formLogin().disable()
+ .httpBasic().disable()
+ .authenticationManager(authenticationManager)
+ .securityContextRepository(securityContextRepository!!)
+ .authorizeExchange()
+ .pathMatchers(HttpMethod.OPTIONS).permitAll()
+ .anyExchange().authenticated()
+ .and().build()
}
}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt
index 66a19b2c5..8d4a27fc0 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt
@@ -29,8 +29,8 @@ import org.springframework.stereotype.Component
* @version 1.0
*/
@Component
-open class BluePrintCustomIndicator(private val bluePrintProcessorHealthCheck: BluePrintProcessorHealthCheck)
- : AbstractHealthIndicator() {
+open class BluePrintCustomIndicator(private val bluePrintProcessorHealthCheck: BluePrintProcessorHealthCheck) :
+ AbstractHealthIndicator() {
@Throws(Exception::class)
override fun doHealthCheck(builder: Health.Builder) {
@@ -42,6 +42,4 @@ open class BluePrintCustomIndicator(private val bluePrintProcessorHealthCheck: B
}
builder.withDetail("Services", result?.checks)
}
-
-
}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/AuthenticationManager.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/AuthenticationManager.kt
index 933425bc3..d9674d5b8 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/AuthenticationManager.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/AuthenticationManager.kt
@@ -23,8 +23,8 @@ import org.springframework.security.core.AuthenticationException
import reactor.core.publisher.Mono
@Configuration
-open class AuthenticationManager(private val authenticationProvider: AuthenticationProvider)
- : ReactiveAuthenticationManager {
+open class AuthenticationManager(private val authenticationProvider: AuthenticationProvider) :
+ ReactiveAuthenticationManager {
override fun authenticate(authentication: Authentication): Mono<Authentication> {
try {
@@ -32,6 +32,5 @@ open class AuthenticationManager(private val authenticationProvider: Authenticat
} catch (e: AuthenticationException) {
return Mono.error(e)
}
-
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt
index a0a4ae297..ab9ee29df 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt
@@ -15,7 +15,11 @@
*/
package org.onap.ccsdk.cds.blueprintsprocessor.security
-import io.grpc.*
+import io.grpc.Metadata
+import io.grpc.ServerCall
+import io.grpc.ServerCallHandler
+import io.grpc.ServerInterceptor
+import io.grpc.Status
import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.springframework.security.authentication.BadCredentialsException
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
@@ -23,23 +27,24 @@ import org.springframework.security.core.AuthenticationException
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Component
import java.nio.charset.StandardCharsets
-import java.util.*
+import java.util.Base64
@Component
-class BasicAuthServerInterceptor(private val authenticationManager: AuthenticationManager)
- : ServerInterceptor {
+class BasicAuthServerInterceptor(private val authenticationManager: AuthenticationManager) :
+ ServerInterceptor {
private val log = logger(BasicAuthServerInterceptor::class)
override fun <ReqT, RespT> interceptCall(
- call: ServerCall<ReqT, RespT>,
- headers: Metadata,
- next: ServerCallHandler<ReqT, RespT>): ServerCall.Listener<ReqT> {
+ call: ServerCall<ReqT, RespT>,
+ headers: Metadata,
+ next: ServerCallHandler<ReqT, RespT>
+ ): ServerCall.Listener<ReqT> {
val authHeader = headers.get(Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER))
if (authHeader.isNullOrEmpty()) {
throw Status.UNAUTHENTICATED.withDescription("Missing required authentication")
- .asRuntimeException()
+ .asRuntimeException()
}
try {
@@ -54,7 +59,6 @@ class BasicAuthServerInterceptor(private val authenticationManager: Authenticati
log.info("Authentication success: {}", authResult)
SecurityContextHolder.getContext().authentication = authResult
-
} catch (e: AuthenticationException) {
SecurityContextHolder.clearContext()
@@ -69,8 +73,10 @@ class BasicAuthServerInterceptor(private val authenticationManager: Authenticati
private fun decodeBasicAuth(authHeader: String): Array<String> {
val basicAuth: String
try {
- basicAuth = String(Base64.getDecoder().decode(authHeader.substring(6).toByteArray(StandardCharsets.UTF_8)),
- StandardCharsets.UTF_8)
+ basicAuth = String(
+ Base64.getDecoder().decode(authHeader.substring(6).toByteArray(StandardCharsets.UTF_8)),
+ StandardCharsets.UTF_8
+ )
} catch (e: IllegalArgumentException) {
throw BadCredentialsException("Failed to decode basic authentication token")
} catch (e: IndexOutOfBoundsException) {
@@ -84,4 +90,4 @@ class BasicAuthServerInterceptor(private val authenticationManager: Authenticati
return arrayOf(basicAuth.substring(0, delim), basicAuth.substring(delim + 1))
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityConfiguration.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityConfiguration.kt
index 70b0df2d1..29ec27daa 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityConfiguration.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityConfiguration.kt
@@ -38,8 +38,10 @@ open class SecurityConfiguration {
@Bean
open fun inMemoryUserService(): UserDetailsService {
- val user = User(username, password,
- listOf(SimpleGrantedAuthority("USER")))
+ val user = User(
+ username, password,
+ listOf(SimpleGrantedAuthority("USER"))
+ )
return InMemoryUserDetailsManager(user)
}
@@ -54,4 +56,4 @@ open class SecurityConfiguration {
provider.setUserDetailsService(inMemoryUserService())
return provider
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityContextRepository.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityContextRepository.kt
index f1c362f57..d646c2ee5 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityContextRepository.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/SecurityContextRepository.kt
@@ -25,11 +25,11 @@ import org.springframework.stereotype.Component
import org.springframework.web.server.ServerWebExchange
import reactor.core.publisher.Mono
import java.nio.charset.StandardCharsets
-import java.util.*
+import java.util.Base64
@Component
-class SecurityContextRepository(private val authenticationManager: AuthenticationManager)
- : ServerSecurityContextRepository {
+class SecurityContextRepository(private val authenticationManager: AuthenticationManager) :
+ ServerSecurityContextRepository {
override fun save(swe: ServerWebExchange, sc: SecurityContext): Mono<Void> {
throw UnsupportedOperationException("Not supported.")
@@ -44,7 +44,7 @@ class SecurityContextRepository(private val authenticationManager: Authenticatio
val password = tokens[1]
val auth = UsernamePasswordAuthenticationToken(username, password)
return this.authenticationManager!!.authenticate(auth)
- .map { SecurityContextImpl(it) }
+ .map { SecurityContextImpl(it) }
} else {
return Mono.empty()
}
@@ -53,8 +53,10 @@ class SecurityContextRepository(private val authenticationManager: Authenticatio
private fun decodeBasicAuth(authHeader: String): Array<String> {
val basicAuth: String
try {
- basicAuth = String(Base64.getDecoder().decode(authHeader.substring(6).toByteArray(StandardCharsets.UTF_8)),
- StandardCharsets.UTF_8)
+ basicAuth = String(
+ Base64.getDecoder().decode(authHeader.substring(6).toByteArray(StandardCharsets.UTF_8)),
+ StandardCharsets.UTF_8
+ )
} catch (e: IllegalArgumentException) {
throw BadCredentialsException("Failed to decode basic authentication token")
} catch (e: IndexOutOfBoundsException) {
@@ -68,4 +70,4 @@ class SecurityContextRepository(private val authenticationManager: Authenticatio
return arrayOf(basicAuth.substring(0, delim), basicAuth.substring(delim + 1))
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/JsonNormalizer.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/JsonNormalizer.kt
index 1a625c279..c5821bed1 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/JsonNormalizer.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/JsonNormalizer.kt
@@ -52,10 +52,10 @@ internal class JsonNormalizer {
private fun expandJstlSpec(jstlSpec: JsonNode): String {
val extendedJstlSpec = updateObjectNodes(jstlSpec, "*", ".")
return extendedJstlSpec.toString()
- // Handle the "?" as a prefix to literal/non-quoted values
- .replace("\"\\?([^\"]+)\"".toRegex(), "$1")
- // Also, remove the quotes added by Jackson for key and value of the wildcard matcher
- .replace("\"([.*])\"".toRegex(), "$1")
+ // Handle the "?" as a prefix to literal/non-quoted values
+ .replace("\"\\?([^\"]+)\"".toRegex(), "$1")
+ // Also, remove the quotes added by Jackson for key and value of the wildcard matcher
+ .replace("\"([.*])\"".toRegex(), "$1")
}
/**
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/PathDeserializer.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/PathDeserializer.kt
index 6b1b0c676..710a65c6f 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/PathDeserializer.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/PathDeserializer.kt
@@ -49,4 +49,4 @@ internal class PathDeserializer : StdDeserializer<String>(String::class.java) {
}
return flatJoinTo(StringBuilder(), path).toString()
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/MoreMatchers.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/RequiredMapEntriesMatcher.kt
index 163544fc9..163544fc9 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/MoreMatchers.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/RequiredMapEntriesMatcher.kt
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatDefinition.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatDefinition.kt
index 3046f1041..cc7ac69f0 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatDefinition.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatDefinition.kt
@@ -30,34 +30,45 @@ import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.nodes.Tag
@JsonInclude(JsonInclude.Include.NON_EMPTY)
-data class ProcessDefinition(val name: String, val request: JsonNode, val expectedResponse: JsonNode? = null,
- val responseNormalizerSpec: JsonNode? = null)
+data class ProcessDefinition(
+ val name: String,
+ val request: JsonNode,
+ val expectedResponse: JsonNode? = null,
+ val responseNormalizerSpec: JsonNode? = null
+)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
-data class RequestDefinition(val method: String,
- @JsonDeserialize(using = PathDeserializer::class)
- val path: String,
- val headers: Map<String, String> = emptyMap(),
- val body: JsonNode? = null)
+data class RequestDefinition(
+ val method: String,
+ @JsonDeserialize(using = PathDeserializer::class)
+ val path: String,
+ val headers: Map<String, String> = emptyMap(),
+ val body: JsonNode? = null
+)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
data class ResponseDefinition(val status: Int = 200, val body: JsonNode? = null) {
+
companion object {
val DEFAULT_RESPONSE = ResponseDefinition()
}
}
@JsonInclude(JsonInclude.Include.NON_EMPTY)
-data class ExpectationDefinition(val request: RequestDefinition,
- val response: ResponseDefinition = ResponseDefinition.DEFAULT_RESPONSE)
+data class ExpectationDefinition(
+ val request: RequestDefinition,
+ val response: ResponseDefinition = ResponseDefinition.DEFAULT_RESPONSE
+)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
data class ServiceDefinition(val selector: String, val expectations: List<ExpectationDefinition>)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
-data class UatDefinition(val processes: List<ProcessDefinition>,
- @JsonAlias("external-services")
- val externalServices: List<ServiceDefinition> = emptyList()) {
+data class UatDefinition(
+ val processes: List<ProcessDefinition>,
+ @JsonAlias("external-services")
+ val externalServices: List<ServiceDefinition> = emptyList()
+) {
fun dump(mapper: ObjectMapper, excludedProperties: List<String> = emptyList()): String {
val uatAsMap: Map<String, Any> = mapper.convertValue(this)
@@ -86,7 +97,6 @@ data class UatDefinition(val processes: List<ProcessDefinition>,
companion object {
fun load(mapper: ObjectMapper, spec: String): UatDefinition =
- mapper.convertValue(Yaml().load(spec), UatDefinition::class.java)
-
+ mapper.convertValue(Yaml().load(spec), UatDefinition::class.java)
}
}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt
index 4e97460d3..89ba1500b 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt
@@ -70,9 +70,9 @@ import java.util.concurrent.ConcurrentHashMap
*/
@Component
class UatExecutor(
- private val environment: ConfigurableEnvironment,
- private val restClientFactory: BluePrintRestLibPropertyService,
- private val mapper: ObjectMapper
+ private val environment: ConfigurableEnvironment,
+ private val restClientFactory: BluePrintRestLibPropertyService,
+ private val mapper: ObjectMapper
) {
companion object {
@@ -103,8 +103,8 @@ class UatExecutor(
fun execute(uat: UatDefinition, cbaBytes: ByteArray): UatDefinition {
val defaultHeaders = listOf(BasicHeader(HttpHeaders.AUTHORIZATION, clientAuthToken()))
val httpClient = HttpClientBuilder.create()
- .setDefaultHeaders(defaultHeaders)
- .build()
+ .setDefaultHeaders(defaultHeaders)
+ .build()
// Only if externalServices are defined
val mockInterceptor = MockPreInterceptor()
// Always defined and used, whatever the case
@@ -113,13 +113,13 @@ class UatExecutor(
try {
// Configure mocked external services and save their expected requests for further validation
val requestsPerClient = uat.externalServices.associateBy(
- { service ->
- createRestClientMock(service.expectations).also { restClient ->
- // side-effect: register restClient to override real instance
- mockInterceptor.registerMock(service.selector, restClient)
- }
- },
- { service -> service.expectations.map { it.request } }
+ { service ->
+ createRestClientMock(service.expectations).also { restClient ->
+ // side-effect: register restClient to override real instance
+ mockInterceptor.registerMock(service.selector, restClient)
+ }
+ },
+ { service -> service.expectations.map { it.request } }
)
val newProcesses = httpClient.use { client ->
@@ -129,8 +129,10 @@ class UatExecutor(
uat.processes.map { process ->
log.info("Executing process '${process.name}'")
val responseNormalizer = JsonNormalizer.getNormalizer(mapper, process.responseNormalizerSpec)
- val actualResponse = processBlueprint(client, process.request,
- process.expectedResponse, responseNormalizer)
+ val actualResponse = processBlueprint(
+ client, process.request,
+ process.expectedResponse, responseNormalizer
+ )
ProcessDefinition(process.name, process.request, actualResponse, process.responseNormalizerSpec)
}
}
@@ -139,10 +141,11 @@ class UatExecutor(
for ((mockClient, requests) in requestsPerClient) {
requests.forEach { request ->
verify(mockClient, atLeastOnce()).exchangeResource(
- eq(request.method),
- eq(request.path),
- argThat { assertJsonEquals(request.body, this) },
- argThat(RequiredMapEntriesMatcher(request.headers)))
+ eq(request.method),
+ eq(request.path),
+ argThat { assertJsonEquals(request.body, this) },
+ argThat(RequiredMapEntriesMatcher(request.headers))
+ )
}
// Don't mind the invocations to the overloaded exchangeResource(String, String, String)
verify(mockClient, atLeast(0)).exchangeResource(any(), any(), any())
@@ -150,7 +153,7 @@ class UatExecutor(
}
val newExternalServices = spyInterceptor.getSpies()
- .map(SpyService::asServiceDefinition)
+ .map(SpyService::asServiceDefinition)
return UatDefinition(newProcesses, newExternalServices)
} finally {
@@ -158,29 +161,32 @@ class UatExecutor(
}
}
- private fun createRestClientMock(restExpectations: List<ExpectationDefinition>)
- : BlueprintWebClientService {
+ private fun createRestClientMock(restExpectations: List<ExpectationDefinition>):
+ BlueprintWebClientService {
val restClient = mock<BlueprintWebClientService>(
- defaultAnswer = Answers.RETURNS_SMART_NULLS,
- // our custom verboseLogging handler
- invocationListeners = arrayOf(mockLoggingListener)
+ defaultAnswer = Answers.RETURNS_SMART_NULLS,
+ // our custom verboseLogging handler
+ invocationListeners = arrayOf(mockLoggingListener)
)
// Delegates to overloaded exchangeResource(String, String, String, Map<String, String>)
whenever(restClient.exchangeResource(any(), any(), any()))
- .thenAnswer { invocation ->
- val method = invocation.arguments[0] as String
- val path = invocation.arguments[1] as String
- val request = invocation.arguments[2] as String
- restClient.exchangeResource(method, path, request, emptyMap())
- }
+ .thenAnswer { invocation ->
+ val method = invocation.arguments[0] as String
+ val path = invocation.arguments[1] as String
+ val request = invocation.arguments[2] as String
+ restClient.exchangeResource(method, path, request, emptyMap())
+ }
for (expectation in restExpectations) {
- whenever(restClient.exchangeResource(
+ whenever(
+ restClient.exchangeResource(
eq(expectation.request.method),
eq(expectation.request.path),
any(),
- any()))
- .thenReturn(WebClientResponse(expectation.response.status, expectation.response.body.toString()))
+ any()
+ )
+ )
+ .thenReturn(WebClientResponse(expectation.response.status, expectation.response.body.toString()))
}
return restClient
}
@@ -188,9 +194,9 @@ class UatExecutor(
@Throws(AssertionError::class)
private fun uploadBlueprint(client: HttpClient, cbaBytes: ByteArray) {
val multipartEntity = MultipartEntityBuilder.create()
- .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
- .addBinaryBody("file", cbaBytes, ContentType.DEFAULT_BINARY, "cba.zip")
- .build()
+ .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
+ .addBinaryBody("file", cbaBytes, ContentType.DEFAULT_BINARY, "cba.zip")
+ .build()
val request = HttpPost("$baseUrl/api/v1/blueprint-model/publish").apply {
entity = multipartEntity
}
@@ -201,8 +207,12 @@ class UatExecutor(
}
@Throws(AssertionError::class)
- private fun processBlueprint(client: HttpClient, requestBody: JsonNode,
- expectedResponse: JsonNode?, responseNormalizer: (String) -> String): JsonNode {
+ private fun processBlueprint(
+ client: HttpClient,
+ requestBody: JsonNode,
+ expectedResponse: JsonNode?,
+ responseNormalizer: (String) -> String
+ ): JsonNode {
val stringEntity = StringEntity(mapper.writeValueAsString(requestBody), ContentType.APPLICATION_JSON)
val request = HttpPost("$baseUrl/api/v1/execution-service/process").apply {
entity = stringEntity
@@ -234,8 +244,8 @@ class UatExecutor(
}
private fun localServerPort(): Int =
- (environment.getProperty("local.server.port")
- ?: environment.getRequiredProperty("blueprint.httpPort")).toInt()
+ (environment.getProperty("local.server.port")
+ ?: environment.getRequiredProperty("blueprint.httpPort")).toInt()
private fun clientAuthToken(): String {
val username = environment.getRequiredProperty("security.user.name")
@@ -255,7 +265,7 @@ class UatExecutor(
}
override fun getInstance(selector: String): BlueprintWebClientService? =
- mocks[selector]
+ mocks[selector]
fun registerMock(selector: String, client: BlueprintWebClientService) {
mocks[selector] = client
@@ -277,21 +287,27 @@ class UatExecutor(
}
fun getSpies(): List<SpyService> =
- spies.values.toList()
+ spies.values.toList()
}
- private class SpyService(private val mapper: ObjectMapper,
- val selector: String,
- private val realService: BlueprintWebClientService) :
- BlueprintWebClientService by realService {
+ private class SpyService(
+ private val mapper: ObjectMapper,
+ val selector: String,
+ private val realService: BlueprintWebClientService
+ ) :
+ BlueprintWebClientService by realService {
private val expectations: MutableList<ExpectationDefinition> = mutableListOf()
override fun exchangeResource(methodType: String, path: String, request: String): WebClientResponse<String> =
- exchangeResource(methodType, path, request, DEFAULT_HEADERS)
-
- override fun exchangeResource(methodType: String, path: String, request: String,
- headers: Map<String, String>): WebClientResponse<String> {
+ exchangeResource(methodType, path, request, DEFAULT_HEADERS)
+
+ override fun exchangeResource(
+ methodType: String,
+ path: String,
+ request: String,
+ headers: Map<String, String>
+ ): WebClientResponse<String> {
val requestDefinition = RequestDefinition(methodType, path, headers, toJson(request))
val realAnswer = realService.exchangeResource(methodType, path, request, headers)
val responseBody = when {
@@ -309,7 +325,7 @@ class UatExecutor(
}
fun asServiceDefinition() =
- ServiceDefinition(selector, expectations)
+ ServiceDefinition(selector, expectations)
private fun toJson(str: String): JsonNode? {
return when {
@@ -320,9 +336,9 @@ class UatExecutor(
companion object {
private val DEFAULT_HEADERS = mapOf(
- HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE
+ HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
+ HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE
)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServices.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServices.kt
index f133fd7c7..5b62f1296 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServices.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatServices.kt
@@ -72,8 +72,10 @@ open class UatServices(private val uatExecutor: UatExecutor, private val mapper:
@PostMapping("/spy", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE], produces = ["text/vnd.yaml"])
@PreAuthorize("hasRole('USER')")
@Suppress("BlockingMethodInNonBlockingContext")
- open fun spy(@RequestPart("cba") cbaFile: FilePart,
- @RequestPart("uat", required = false) uatFile: FilePart?): String = runBlocking {
+ open fun spy(
+ @RequestPart("cba") cbaFile: FilePart,
+ @RequestPart("uat", required = false) uatFile: FilePart?
+ ): String = runBlocking {
val tempFile = createTempFile()
setContextColor(COLOR_SERVICES)
try {
@@ -118,4 +120,4 @@ open class UatServices(private val uatExecutor: UatExecutor, private val mapper:
// Fields that can be safely ignored from BPP response, and can be omitted on the UAT specification.
private val FIELDS_TO_EXCLUDE = listOf("timestamp")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/ColorMarker.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/ColorMarker.kt
index 10139c839..9ae3ff805 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/ColorMarker.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/ColorMarker.kt
@@ -21,4 +21,4 @@ package org.onap.ccsdk.cds.blueprintsprocessor.uat.logging
import org.slf4j.Marker
-class ColorMarker internal constructor(private val dlg: Marker) : Marker by dlg \ No newline at end of file
+class ColorMarker internal constructor(private val dlg: Marker) : Marker by dlg
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/LogColor.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/LogColor.kt
index dce516933..f0cba2670 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/LogColor.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/LogColor.kt
@@ -41,5 +41,5 @@ object LogColor {
}
fun markerOf(color: String): ColorMarker =
- ColorMarker(MarkerFactory.getMarker(color))
+ ColorMarker(MarkerFactory.getMarker(color))
}
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt
index d7b38d3fa..cad235450 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt
@@ -35,7 +35,7 @@ class SmartColorDiscriminator : AbstractDiscriminator<ILoggingEvent>() {
}
override fun getDiscriminatingValue(e: ILoggingEvent): String =
- (e.marker as? ColorMarker)?.name
- ?: e.mdcPropertyMap?.get(MDC_COLOR_KEY)
- ?: defaultValue
-} \ No newline at end of file
+ (e.marker as? ColorMarker)?.name
+ ?: e.mdcPropertyMap?.get(MDC_COLOR_KEY)
+ ?: defaultValue
+}