diff options
author | Piotr Jaszczyk <piotr.jaszczyk@nokia.com> | 2018-11-07 15:08:43 +0100 |
---|---|---|
committer | Piotr Jaszczyk <piotr.jaszczyk@nokia.com> | 2018-11-15 12:51:43 +0100 |
commit | 4d15e5a578dc2c94af2b7f1c7ad02fb44d384501 (patch) | |
tree | baad5e6314ef6d2a0f1409b0a23e0001e814f0a8 /hv-collector-ves-message-generator | |
parent | 3fdd2fe2b4f35e18998d050c632fc6de24a7e3b1 (diff) |
Update project and dependencies
* Changed version from 4.0.0-SNAPSHOT to 1.1.0-SNAPSHOT as per Vijay
suggestion
* Updated Reactor to BOM Californium-SR2
* Updated mockito-kotlin to 2.0.0
* Introduced some fixes to support OpenJDK 11 compilation
Change-Id: Ib25979ef50c7241a019bf98efd9759e0b8792d58
Issue-ID: DCAEGEN2-961
Signed-off-by: Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
Diffstat (limited to 'hv-collector-ves-message-generator')
3 files changed, 33 insertions, 7 deletions
diff --git a/hv-collector-ves-message-generator/pom.xml b/hv-collector-ves-message-generator/pom.xml index 87728f67..dae42e2d 100644 --- a/hv-collector-ves-message-generator/pom.xml +++ b/hv-collector-ves-message-generator/pom.xml @@ -33,7 +33,7 @@ <parent> <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId> <artifactId>ves-hv-collector</artifactId> - <version>4.0.0-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> <relativePath>..</relativePath> </parent> diff --git a/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageGeneratorImpl.kt b/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageGeneratorImpl.kt index cc1d16fe..fa39ed16 100644 --- a/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageGeneratorImpl.kt +++ b/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageGeneratorImpl.kt @@ -31,9 +31,8 @@ import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType.INVA import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType.INVALID_WIRE_FRAME import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType.TOO_BIG_PAYLOAD import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType.VALID -import org.onap.ves.VesEventOuterClass.VesEvent import org.onap.ves.VesEventOuterClass.CommonEventHeader - +import org.onap.ves.VesEventOuterClass.VesEvent import reactor.core.publisher.Flux import reactor.core.publisher.Mono import java.nio.charset.Charset @@ -54,10 +53,17 @@ class MessageGeneratorImpl internal constructor( private fun createMessageFlux(parameters: MessageParameters): Flux<WireFrameMessage> = Mono.fromCallable { createMessage(parameters.commonEventHeader, parameters.messageType) } .let { - if (parameters.amount < 0) - it.repeat() - else - it.repeat(parameters.amount) + when { + parameters.amount < 0 -> + // repeat forever + it.repeat() + parameters.amount == 0L -> + // do not generate any message + Flux.empty() + else -> + // send original message and additional amount-1 messages + it.repeat(parameters.amount - 1) + } } private fun createMessage(commonEventHeader: CommonEventHeader, messageType: MessageType): WireFrameMessage = diff --git a/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageGeneratorImplTest.kt b/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageGeneratorImplTest.kt index ee76b789..e2aec7df 100644 --- a/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageGeneratorImplTest.kt +++ b/hv-collector-ves-message-generator/src/test/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageGeneratorImplTest.kt @@ -50,6 +50,7 @@ object MessageGeneratorImplTest : Spek({ val maxPayloadSizeBytes = 1024 val generator = MessageGeneratorImpl(PayloadGenerator(), maxPayloadSizeBytes) given("single message parameters") { + on("messages amount not specified in parameters") { it("should create infinite flux") { val limit = 1000L @@ -64,6 +65,20 @@ object MessageGeneratorImplTest : Spek({ .verifyComplete() } } + + on("messages amount = 0 specified in parameters") { + it("should create empty message flux") { + generator + .createMessageFlux(listOf(MessageParameters( + commonHeader(PERF3GPP), + MessageType.VALID, + 0 + ))) + .test() + .verifyComplete() + } + } + on("messages amount specified in parameters") { it("should create message flux of specified size") { generator @@ -77,6 +92,7 @@ object MessageGeneratorImplTest : Spek({ .verifyComplete() } } + on("message type requesting valid message") { it("should create flux of valid messages with given domain") { generator @@ -94,6 +110,7 @@ object MessageGeneratorImplTest : Spek({ .verifyComplete() } } + on("message type requesting too big payload") { it("should create flux of messages with given domain and payload exceeding threshold") { @@ -112,6 +129,7 @@ object MessageGeneratorImplTest : Spek({ .verifyComplete() } } + on("message type requesting invalid GPB data ") { it("should create flux of messages with invalid payload") { generator @@ -130,6 +148,7 @@ object MessageGeneratorImplTest : Spek({ .verifyComplete() } } + on("message type requesting invalid wire frame ") { it("should create flux of messages with invalid version") { generator @@ -148,6 +167,7 @@ object MessageGeneratorImplTest : Spek({ .verifyComplete() } } + on("message type requesting fixed payload") { it("should create flux of valid messages with fixed payload") { generator |