summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/dmaap-lib
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/modules/commons/dmaap-lib
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/modules/commons/dmaap-lib')
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt15
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt13
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt48
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt12
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt86
7 files changed, 109 insertions, 70 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt
index 2dbea8fc9..8ccd8cd56 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt
@@ -27,16 +27,17 @@ import com.att.nsa.mr.client.impl.MRSimplerBatchPublisher
/**
* Representation of DMAAP client service for AAF auth type.
*/
-class AafAuthDmaapClientService(private val clientProps:
- AafAuthDmaapClientProperties)
- : BluePrintDmaapClientService {
+class AafAuthDmaapClientService(
+ private val clientProps:
+ AafAuthDmaapClientProperties
+) :
+ BluePrintDmaapClientService {
/**
* The constructed DMAAP client.
*/
var clients: MutableList<MRBatchingPublisher> = mutableListOf()
-
/**
* Returns the DMAAP client after constructing it properly with the data
* that is required for AAF auth connection.
@@ -52,12 +53,12 @@ class AafAuthDmaapClientService(private val clientProps:
val client = MRClientFactory.createBatchingPublisher(
clientProps.host, t, clientProps.username,
clientProps.password, 1, 1, false,
- clientProps.type, "")
+ clientProps.type, ""
+ )
val batchPublisher = client as MRSimplerBatchPublisher
batchPublisher.props = clientProps.props
clients.add(client)
}
return clients
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt
index a4cb5a3e6..cbde4d003 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt
@@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory
import java.io.IOException
import java.util.concurrent.TimeUnit
-
/**
* Abstraction of DMAAP client services that could form DMAAP client from the
* properties provided. This abstraction also provides a mechanism to send
@@ -38,14 +37,16 @@ interface BluePrintDmaapClientService {
* Static variable for logging.
*/
companion object {
+
var log = LoggerFactory.getLogger(
- BluePrintDmaapClientService::class.java)!!
+ BluePrintDmaapClientService::class.java
+ )!!
}
/**
* Returns the properly constructed DMAAP client with the type.
*/
- fun getDmaapClient(): MutableList<MRBatchingPublisher>
+ fun getDmaapClient(): MutableList<MRBatchingPublisher>
/**
* Sends messages to the sessions created by the information provided from
@@ -93,8 +94,10 @@ interface BluePrintDmaapClientService {
var ms = client.close(timeout, TimeUnit.SECONDS)
msgs.add(ms)
} catch (e: IOException) {
- log.warn("Unable to cleanly close the connection from the " +
- "client $client", e)
+ log.warn(
+ "Unable to cleanly close the connection from the " +
+ "client $client", e
+ )
}
}
return msgs
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt
index 51cd3bf0a..44ed5316b 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt
@@ -37,10 +37,11 @@ open class BluePrintDmaapLibConfiguration
* Util constants required for DMAAP library to use.
*/
class DmaapLibConstants {
+
companion object {
const val SERVICE_BLUEPRINT_DMAAP_LIB_PROPERTY = "blueprint" +
"-dmaap-lib-property-service"
const val TYPE_HTTP_NO_AUTH = "HTTPNOAUTH"
const val TYPE_HTTP_AAF_AUTH = "HTTPAAF"
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt
index cde4987ff..a3eed159f 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt
@@ -36,7 +36,7 @@ import org.springframework.core.env.ConfigurableEnvironment
import org.springframework.core.env.Environment
import org.springframework.core.io.support.ResourcePropertySource
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.Properties
/**
* Representation of DMAAP lib property service to load the properties
@@ -52,8 +52,10 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
* Static variable for logging.
*/
companion object {
+
var log = LoggerFactory.getLogger(
- BluePrintDmaapLibPropertyService::class.java)!!
+ BluePrintDmaapLibPropertyService::class.java
+ )!!
}
/**
@@ -90,25 +92,30 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
*/
fun dmaapClientProperties(prefix: String): DmaapClientProperties {
val type = bluePrintPropertiesService.propertyBeanType(
- "$prefix.type", String::class.java)
+ "$prefix.type", String::class.java
+ )
val clientProps: DmaapClientProperties
when (type) {
TYPE_HTTP_NO_AUTH -> {
clientProps = bluePrintPropertiesService.propertyBeanType(
- prefix, HttpNoAuthDmaapClientProperties::class.java)
+ prefix, HttpNoAuthDmaapClientProperties::class.java
+ )
clientProps.props = parseEventProps()
}
TYPE_HTTP_AAF_AUTH -> {
clientProps = bluePrintPropertiesService.propertyBeanType(
- prefix, AafAuthDmaapClientProperties::class.java)
+ prefix, AafAuthDmaapClientProperties::class.java
+ )
clientProps.props = parseEventProps()
}
else -> {
- throw BluePrintProcessorException("DMAAP adaptor($type) is " +
- "not supported")
+ throw BluePrintProcessorException(
+ "DMAAP adaptor($type) is " +
+ "not supported"
+ )
}
}
return clientProps
@@ -124,20 +131,26 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
when (type) {
TYPE_HTTP_NO_AUTH -> {
- clientProps = JacksonUtils.readValue(jsonNode,
- HttpNoAuthDmaapClientProperties::class.java)!!
+ clientProps = JacksonUtils.readValue(
+ jsonNode,
+ HttpNoAuthDmaapClientProperties::class.java
+ )!!
clientProps.props = parseEventProps()
}
TYPE_HTTP_AAF_AUTH -> {
- clientProps = JacksonUtils.readValue(jsonNode,
- AafAuthDmaapClientProperties::class.java)!!
+ clientProps = JacksonUtils.readValue(
+ jsonNode,
+ AafAuthDmaapClientProperties::class.java
+ )!!
clientProps.props = parseEventProps()
}
else -> {
- throw BluePrintProcessorException("DMAAP adaptor($type) is " +
- "not supported")
+ throw BluePrintProcessorException(
+ "DMAAP adaptor($type) is " +
+ "not supported"
+ )
}
}
return clientProps
@@ -158,8 +171,10 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
}
else -> {
- throw BluePrintProcessorException("Unable to get the DMAAP " +
- "client")
+ throw BluePrintProcessorException(
+ "Unable to get the DMAAP " +
+ "client"
+ )
}
}
}
@@ -171,7 +186,8 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
private fun parseEventProps(): Properties {
val prodProps = Properties()
val proProps = (env as ConfigurableEnvironment).propertySources.get(
- "class path resource [event.properties]")
+ "class path resource [event.properties]"
+ )
if (proProps != null) {
val entries = (proProps as ResourcePropertySource).source.entries
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt
index 9d942943e..aa4c40ae6 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt
@@ -26,6 +26,7 @@ import java.util.Properties
* Representation of data required for all DMAAP client.
*/
open class DmaapClientProperties {
+
lateinit var props: Properties
lateinit var type: String
lateinit var host: String
@@ -41,6 +42,7 @@ open class HttpNoAuthDmaapClientProperties : DmaapClientProperties()
* Representation of data required for AAF auth DMAAP client.
*/
open class AafAuthDmaapClientProperties : DmaapClientProperties() {
+
lateinit var username: String
lateinit var password: String
}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt
index 8bf50a944..a3e347adc 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt
@@ -27,16 +27,17 @@ import com.att.nsa.mr.client.impl.MRSimplerBatchPublisher
/**
* Representation of DMAAP client service for HTTP no auth type.
*/
-class HttpNoAuthDmaapClientService(private val clientProps:
- HttpNoAuthDmaapClientProperties)
- : BluePrintDmaapClientService {
+class HttpNoAuthDmaapClientService(
+ private val clientProps:
+ HttpNoAuthDmaapClientProperties
+) :
+ BluePrintDmaapClientService {
/**
* The constructed DMAAP client.
*/
var clients: MutableList<MRBatchingPublisher> = mutableListOf()
-
/**
* Returns the DMAAP client after constructing it properly with the data
* that is required for HTTP no auth connection.
@@ -58,5 +59,4 @@ class HttpNoAuthDmaapClientService(private val clientProps:
return clients
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
index 4e91d59f9..3fb7f6802 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
@@ -49,19 +49,23 @@ import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
-@ContextConfiguration(classes = [BluePrintDmaapLibConfiguration::class, TestController::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties = ["server.port=9111",
- "blueprintsprocessor.dmaapclient.aai.topic=cds_aai",
- "blueprintsprocessor.dmaapclient.aai.type=HTTPNOAUTH",
- "blueprintsprocessor.dmaapclient.aai.host=127.0.0.1:9111",
- "blueprintsprocessor.dmaapclient.multi.topic=cds_multi1,cds_multi2",
- "blueprintsprocessor.dmaapclient.multi.type=HTTPNOAUTH",
- "blueprintsprocessor.dmaapclient.multi.host=127.0.0.1:9111"])
+@ContextConfiguration(
+ classes = [BluePrintDmaapLibConfiguration::class, TestController::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties = ["server.port=9111",
+ "blueprintsprocessor.dmaapclient.aai.topic=cds_aai",
+ "blueprintsprocessor.dmaapclient.aai.type=HTTPNOAUTH",
+ "blueprintsprocessor.dmaapclient.aai.host=127.0.0.1:9111",
+ "blueprintsprocessor.dmaapclient.multi.topic=cds_multi1,cds_multi2",
+ "blueprintsprocessor.dmaapclient.multi.type=HTTPNOAUTH",
+ "blueprintsprocessor.dmaapclient.multi.host=127.0.0.1:9111"]
+)
class TestDmaapEventPublisher {
@Autowired
- lateinit var dmaapService : BluePrintDmaapLibPropertyService
+ lateinit var dmaapService: BluePrintDmaapLibPropertyService
/**
* Tests the event properties being set properly and sent as request.
@@ -71,9 +75,11 @@ class TestDmaapEventPublisher {
val strList = mutableListOf<String>()
val dmaapClient = dmaapService.blueprintDmaapClientService("aai")
- strList.add("{\n" +
- " \"a\" : \"hello\"\n" +
- "}")
+ strList.add(
+ "{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}"
+ )
dmaapClient.sendMessage(strList)
val msgs = dmaapClient.close(2)
assertEquals(msgs!!.size, 1)
@@ -88,7 +94,7 @@ class TestDmaapEventPublisher {
@Test
fun testEventPropertiesWithSingleMsg() {
val dmaapClient = dmaapService.blueprintDmaapClientService("aai")
- val str : String = "{\n" +
+ val str: String = "{\n" +
" \"a\" : \"hello\"\n" +
"}"
dmaapClient.sendMessage(str)
@@ -106,9 +112,11 @@ class TestDmaapEventPublisher {
val strList = mutableListOf<String>()
val dmaapClient = dmaapService.blueprintDmaapClientService("multi")
- strList.add("{\n" +
- " \"a\" : \"hello\"\n" +
- "}")
+ strList.add(
+ "{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}"
+ )
dmaapClient.sendMessage(strList)
val msgs = dmaapClient.close(2)
assertEquals(msgs!!.size, 2)
@@ -118,7 +126,6 @@ class TestDmaapEventPublisher {
assertEquals(topic2!!.size, 0)
}
-
/**
* Tests the event properties with multiple topics with JSON node as input.
*/
@@ -134,9 +141,11 @@ class TestDmaapEventPublisher {
val strList = mutableListOf<String>()
val dmaapClient = dmaapService.blueprintDmaapClientService(node)
- strList.add("{\n" +
- " \"a\" : \"hello\"\n" +
- "}")
+ strList.add(
+ "{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}"
+ )
dmaapClient.sendMessage(strList)
val msgs = dmaapClient.close(2)
assertEquals(msgs!!.size, 2)
@@ -146,7 +155,6 @@ class TestDmaapEventPublisher {
assertEquals(topic2!!.size, 0)
}
-
/**
* Tests the event properties with multiple messages.
*/
@@ -155,12 +163,16 @@ class TestDmaapEventPublisher {
val strList = mutableListOf<String>()
val dmaapClient = dmaapService.blueprintDmaapClientService("aai")
- strList.add("{\n" +
- " \"a\" : \"hello\"\n" +
- "}")
- strList.add("{\n" +
- " \"a\" : \"second\"\n" +
- "}")
+ strList.add(
+ "{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}"
+ )
+ strList.add(
+ "{\n" +
+ " \"a\" : \"second\"\n" +
+ "}"
+ )
dmaapClient.sendMessage(strList)
val msgs = dmaapClient.close(2)
assertEquals(msgs!!.size, 1)
@@ -174,10 +186,13 @@ class TestDmaapEventPublisher {
@Test
fun testDmaapClientProperties() {
val properties = dmaapService.dmaapClientProperties(
- "blueprintsprocessor.dmaapclient.aai")
+ "blueprintsprocessor.dmaapclient.aai"
+ )
assertNotNull(properties, "failed to create property bean")
- assertNotNull(properties.host, "failed to get url property" +
- " in property bean")
+ assertNotNull(
+ properties.host, "failed to get url property" +
+ " in property bean"
+ )
}
/**
@@ -187,10 +202,11 @@ class TestDmaapEventPublisher {
fun testBlueprintDmaapClientService() {
val blueprintDmaapClientService =
dmaapService.blueprintDmaapClientService("aai")
- assertNotNull(blueprintDmaapClientService,
- "failed to create blueprintDmaapClientService")
+ assertNotNull(
+ blueprintDmaapClientService,
+ "failed to create blueprintDmaapClientService"
+ )
}
-
}
/**
@@ -204,7 +220,7 @@ open class TestController {
* Accepts request for a topic and sends a message as response.
*/
@PostMapping(path = ["/{topic}"])
- fun postTopic(@PathVariable(value = "topic") topic : String):
+ fun postTopic(@PathVariable(value = "topic") topic: String):
ResponseEntity<Any> {
var a = "{\n" +
" \"message\" : \"The message is published into $topic " +