summaryrefslogtreecommitdiffstats
path: root/hv-collector-utils/src/main/kotlin
diff options
context:
space:
mode:
authorJakub Dudycz <jakub.dudycz@nokia.com>2018-07-26 11:49:45 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-08-03 10:15:25 +0200
commita2d874fd73825b254a3e0be81cff57a5c3e1d9d7 (patch)
treeb8d90cf0c3acf46de5be92e64c8da97c969d9df4 /hv-collector-utils/src/main/kotlin
parentf738ede42e619f1a5c13671cb560224aa639f1db (diff)
DCAE APP simulator rework
- Extract message parameters parsing logic to standalone class in utils - Make DCAE APP simulator store whole received messages history - Add validation endpoint - Add new messege type: FIXED_PAYLOAD Closes ONAP-686 Change-Id: I865804716ad5e46a7503a8eee70cfe9ac75a6c1e Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com> Issue-ID: DCAEGEN2-601
Diffstat (limited to 'hv-collector-utils/src/main/kotlin')
-rw-r--r--hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt6
-rw-r--r--hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/messages/MessageParametersParser.kt9
2 files changed, 7 insertions, 8 deletions
diff --git a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt
index 9c873a0f..c00ce68d 100644
--- a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt
+++ b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/ArgBasedConfiguration.kt
@@ -54,20 +54,16 @@ abstract class ArgBasedConfiguration<T>(private val parser: CommandLineParser) {
protected abstract fun getConfiguration(cmdLine: CommandLine): Option<T>
- protected fun CommandLine.intValue(cmdLineOpt: CommandLineOption, default: Int): Int =
- intValue(cmdLineOpt).getOrElse { default }
-
protected fun CommandLine.longValue(cmdLineOpt: CommandLineOption, default: Long): Long =
longValue(cmdLineOpt).getOrElse { default }
protected fun CommandLine.stringValue(cmdLineOpt: CommandLineOption, default: String): String =
optionValue(cmdLineOpt).getOrElse { default }
-
protected fun CommandLine.intValue(cmdLineOpt: CommandLineOption): Option<Int> =
optionValue(cmdLineOpt).map(String::toInt)
- protected fun CommandLine.longValue(cmdLineOpt: CommandLineOption): Option<Long> =
+ private fun CommandLine.longValue(cmdLineOpt: CommandLineOption): Option<Long> =
optionValue(cmdLineOpt).map(String::toLong)
protected fun CommandLine.stringValue(cmdLineOpt: CommandLineOption): Option<String> =
diff --git a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/messages/MessageParametersParser.kt b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/messages/MessageParametersParser.kt
index 24c2cbfa..1621ba59 100644
--- a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/messages/MessageParametersParser.kt
+++ b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/messages/MessageParametersParser.kt
@@ -35,14 +35,17 @@ class MessageParametersParser(
request
.map { it.asJsonObject() }
.map {
- val commonEventHeader = commonEventHeaderParser.parse(it.getJsonObject("commonEventHeader"))
+ val commonEventHeader = commonEventHeaderParser
+ .parse(it.getJsonObject("commonEventHeader"))
val messageType = MessageType.valueOf(it.getString("messageType"))
- val messagesAmount = it.getJsonNumber("messagesAmount").longValue()
+ val messagesAmount = it.getJsonNumber("messagesAmount")?.longValue()
+ ?: throw ParsingException("\"messagesAmount\" could not be parsed from message.",
+ NullPointerException())
MessageParameters(commonEventHeader, messageType, messagesAmount)
}
} catch (e: Exception) {
throw ParsingException("Parsing request body failed", e)
}
- internal class ParsingException(message: String?, cause: Exception) : Exception(message, cause)
+ internal class ParsingException(message: String, cause: Exception) : Exception(message, cause)
}