Move MessageParametersParser 79/58879/1
authorfkrzywka <filip.krzywka@nokia.com>
Tue, 31 Jul 2018 12:22:59 +0000 (14:22 +0200)
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>
Fri, 3 Aug 2018 08:50:43 +0000 (10:50 +0200)
To avoid dependency of utilities module on modules other than domain

Change-Id: I90ef8640a86501315d84848118d3e748aafd095c
Signed-off-by: fkrzywka <filip.krzywka@nokia.com>
Issue-ID: DCAEGEN2-601

hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/remote/ApiServer.kt
hv-collector-utils/pom.xml
hv-collector-ves-message-generator/pom.xml
hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/api/MessageParametersParser.kt [new file with mode: 0644]
hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/CommonEventHeaderParser.kt [moved from hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/messages/CommonEventHeaderParser.kt with 97% similarity]
hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt [moved from hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/messages/MessageParametersParser.kt with 87% similarity]
hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/impl/MessageParametersParserTest.kt [moved from hv-collector-utils/src/test/kotlin/org/onap/dcae/collectors/veshv/utils/messages/MessageParametersParserTest.kt with 88% similarity]
hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/impl/parameters.kt [moved from hv-collector-utils/src/test/kotlin/org/onap/dcae/collectors/veshv/utils/messages/parameters.kt with 98% similarity]
hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/HttpServer.kt

index 79f143e..cd25813 100644 (file)
@@ -24,7 +24,7 @@ import org.onap.dcae.collectors.veshv.domain.PayloadWireFrameMessage
 import org.onap.dcae.collectors.veshv.simulators.dcaeapp.kafka.ConsumerFactory
 import org.onap.dcae.collectors.veshv.simulators.dcaeapp.kafka.ConsumerStateProvider
 import org.onap.dcae.collectors.veshv.utils.logging.Logger
-import org.onap.dcae.collectors.veshv.utils.messages.MessageParametersParser
+import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParametersParser
 import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageGenerator
 import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParameters
 import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType.FIXED_PAYLOAD
@@ -41,7 +41,7 @@ import javax.json.Json
  * @since May 2018
  */
 class ApiServer(private val consumerFactory: ConsumerFactory,
-                private val messageParametersParser: MessageParametersParser = MessageParametersParser()) {
+                private val messageParametersParser: MessageParametersParser = MessageParametersParser.INSTANCE) {
 
     private lateinit var consumerState: ConsumerStateProvider
 
index 39097c1..9b21d75 100644 (file)
@@ -61,7 +61,7 @@
     <dependencies>
         <dependency>
             <groupId>${project.parent.groupId}</groupId>
-            <artifactId>hv-collector-ves-message-generator</artifactId>
+            <artifactId>hv-collector-domain</artifactId>
             <version>${project.parent.version}</version>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.glassfish</groupId>
-            <artifactId>javax.json</artifactId>
-        </dependency>
         <dependency>
             <groupId>com.nhaarman</groupId>
             <artifactId>mockito-kotlin</artifactId>
index a7dad24..f049d78 100644 (file)
             <artifactId>logback-classic</artifactId>
             <scope>runtime</scope>
         </dependency>
+        <dependency>
+            <groupId>org.glassfish</groupId>
+            <artifactId>javax.json</artifactId>
+        </dependency>
     </dependencies>
 
 
diff --git a/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/api/MessageParametersParser.kt b/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/api/MessageParametersParser.kt
new file mode 100644 (file)
index 0000000..060f28a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * ============LICENSE_START=======================================================
+ * dcaegen2-collectors-veshv
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.collectors.veshv.ves.message.generator.api
+
+import org.onap.dcae.collectors.veshv.ves.message.generator.impl.MessageParametersParserImpl
+import javax.json.JsonArray
+
+interface MessageParametersParser {
+    fun parse(request: JsonArray): List<MessageParameters>
+
+    companion object {
+        val INSTANCE: MessageParametersParser by lazy {
+            MessageParametersParserImpl()
+        }
+    }
+}
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package org.onap.dcae.collectors.veshv.utils.messages
+package org.onap.dcae.collectors.veshv.ves.message.generator.impl
 
 import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParameters
+import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParametersParser
 import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType
 import javax.json.JsonArray
 
@@ -27,10 +28,11 @@ import javax.json.JsonArray
  * @author Jakub Dudycz <jakub.dudycz@nokia.com>
  * @since July 2018
  */
-class MessageParametersParser(
-        private val commonEventHeaderParser: CommonEventHeaderParser = CommonEventHeaderParser()) {
+internal class MessageParametersParserImpl(
+        private val commonEventHeaderParser: CommonEventHeaderParser = CommonEventHeaderParser()
+) : MessageParametersParser {
 
-    fun parse(request: JsonArray): List<MessageParameters> =
+    override fun parse(request: JsonArray): List<MessageParameters> =
             try {
                 request
                         .map { it.asJsonObject() }
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package org.onap.dcae.collectors.veshv.utils.messages
+package org.onap.dcae.collectors.veshv.ves.message.generator.impl.impl
 
 import org.assertj.core.api.Assertions.assertThat
 import org.assertj.core.api.Assertions.assertThatExceptionOfType
@@ -26,8 +26,9 @@ import org.jetbrains.spek.api.dsl.describe
 import org.jetbrains.spek.api.dsl.given
 import org.jetbrains.spek.api.dsl.it
 import org.jetbrains.spek.api.dsl.on
-import org.onap.dcae.collectors.veshv.utils.messages.MessageParametersParser.ParsingException
+import org.onap.dcae.collectors.veshv.ves.message.generator.impl.MessageParametersParserImpl.ParsingException
 import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType
+import org.onap.dcae.collectors.veshv.ves.message.generator.impl.MessageParametersParserImpl
 
 private const val EXPECTED_MESSAGES_AMOUNT = 25000L
 
@@ -37,7 +38,7 @@ private const val EXPECTED_MESSAGES_AMOUNT = 25000L
  */
 object MessageParametersParserTest : Spek({
     describe("Messages parameters parser") {
-        val messageParametersParser = MessageParametersParser()
+        val messageParametersParser = MessageParametersParserImpl()
 
         given("parameters json array") {
             on("valid parameters json") {
index e602573..3fb4be9 100644 (file)
@@ -21,8 +21,8 @@ package org.onap.dcae.collectors.veshv.simulators.xnf.impl
 
 import arrow.effects.IO
 import org.onap.dcae.collectors.veshv.utils.logging.Logger
-import org.onap.dcae.collectors.veshv.utils.messages.MessageParametersParser
 import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageGenerator
+import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParametersParser
 import ratpack.handling.Chain
 import ratpack.handling.Context
 import ratpack.server.RatpackServer
@@ -35,7 +35,7 @@ import javax.json.Json
  * @since June 2018
  */
 internal class HttpServer(private val vesClient: XnfSimulator,
-                          private val messageParametersParser: MessageParametersParser = MessageParametersParser()) {
+                          private val messageParametersParser: MessageParametersParser = MessageParametersParser.INSTANCE) {
 
     fun start(port: Int): IO<RatpackServer> = IO {
         RatpackServer.start { server ->