diff options
Diffstat (limited to 'hv-collector-ves-message-generator/src')
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()!! |