aboutsummaryrefslogtreecommitdiffstats
path: root/hv-collector-ves-message-generator
diff options
context:
space:
mode:
authorFilip Krzywka <filip.krzywka@nokia.com>2018-11-27 13:04:48 +0100
committerFilip Krzywka <filip.krzywka@nokia.com>2018-11-28 08:07:22 +0100
commit77f896523f2065b1da1be21545155a29edea5122 (patch)
tree4c310e94f4836d2324f1689ca44f226f158b7886 /hv-collector-ves-message-generator
parent4f683d3e17025131a297baa67300da679bb85141 (diff)
Bump checkstyle version
- changed plugin invocation due to backwards incompatible changes made in detekt's RC9 version - disabled few rules that we actually don't follow in our code and we seem to be fine with it - turned on UnusedPrivateMember as it actually is a code smell/debt - supressed warnings in where it was plausible (according to common sense) - fixed warnings wherever possible Change-Id: I7be97f471ff46786ef1fca3432b759e7820ac681 Issue-ID: DCAEGEN2-996 Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'hv-collector-ves-message-generator')
-rw-r--r--hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt11
-rw-r--r--hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGenerator.kt1
-rw-r--r--hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/CommonEventHeaderParserTest.kt2
-rw-r--r--hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGeneratorTest.kt3
-rw-r--r--hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/parameters.kt4
5 files changed, 9 insertions, 12 deletions
diff --git a/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt b/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt
index ea0ee282..6ef6d53a 100644
--- a/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt
+++ b/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt
@@ -40,13 +40,13 @@ internal class MessageParametersParserImpl(
Try {
request
.map { it.asJsonObject() }
- .map {
+ .map { json ->
val commonEventHeader = commonEventHeaderParser
- .parse(it.getJsonObject("commonEventHeader"))
+ .parse(json.getJsonObject("commonEventHeader"))
.fold({ throw IllegalStateException("Invalid common header") }, ::identity)
- val messageType = MessageType.valueOf(it.getString("messageType"))
- val messagesAmount = it.getJsonNumber("messagesAmount")?.longValue()
- ?: throw NullPointerException("\"messagesAmount\" could not be parsed from message.")
+ val messageType = MessageType.valueOf(json.getString("messageType"))
+ val messagesAmount = json.getJsonNumber("messagesAmount")?.longValue()
+ ?: throw NullPointerException("\"messagesAmount\" could not be parsed.")
MessageParameters(commonEventHeader, messageType, messagesAmount)
}
}.toEither().mapLeft { ex ->
@@ -54,5 +54,4 @@ internal class MessageParametersParserImpl(
ex.message ?: "Unable to parse message parameters",
Option.fromNullable(ex))
}
-
}
diff --git a/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGenerator.kt b/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGenerator.kt
index ef7eefa6..545e237c 100644
--- a/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGenerator.kt
+++ b/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGenerator.kt
@@ -37,5 +37,4 @@ internal class PayloadGenerator {
.toString()
.toByteArray()
)
-
}
diff --git a/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/CommonEventHeaderParserTest.kt b/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/CommonEventHeaderParserTest.kt
index ce394cc1..3a33c44a 100644
--- a/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/CommonEventHeaderParserTest.kt
+++ b/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/CommonEventHeaderParserTest.kt
@@ -79,4 +79,4 @@ class CommonEventHeaderParserTest : Spek({
fun assertFailed(result: Option<CommonEventHeader>) =
result.fold({}, { fail() })
-fun jsonObject(json: ByteArrayInputStream) = Json.createReader(json).readObject() \ No newline at end of file
+fun jsonObject(json: ByteArrayInputStream) = Json.createReader(json).readObject()!! \ No newline at end of file
diff --git a/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGeneratorTest.kt b/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGeneratorTest.kt
index 5249a8d2..bb91245d 100644
--- a/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGeneratorTest.kt
+++ b/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/PayloadGeneratorTest.kt
@@ -19,12 +19,11 @@
*/
package org.onap.dcae.collectors.veshv.ves.message.generator.impl
+import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
-import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.dsl.on
-import org.onap.dcae.collectors.veshv.ves.message.generator.impl.PayloadGenerator
object PayloadGeneratorTest : Spek({
diff --git a/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/parameters.kt b/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/parameters.kt
index 5d112bae..78cfa028 100644
--- a/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/parameters.kt
+++ b/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/parameters.kt
@@ -99,8 +99,8 @@ private const val invalidMessageParameters =
fun validMessagesParametesJson() = Json
.createReader(validMessageParameters.reader())
- .readArray()
+ .readArray()!!
fun invalidMessagesParametesJson() = Json
.createReader(invalidMessageParameters.reader())
- .readArray()
+ .readArray()!!