summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Dudycz <jakub.dudycz@nokia.com>2019-01-22 18:26:20 +0100
committerJakub Dudycz <jakub.dudycz@nokia.com>2019-01-24 16:35:46 +0100
commit556b783cd4d083d234649ca52bb820af5d1fbcde (patch)
tree293139a4fb17b6dc3c832e914f538e78b292af0c
parent7a4a5d0fef06c29478f594cd6e82e5cb69cc70d2 (diff)
Write WTP and Protobuf encoders stubs
- Make slight architecture changes - Write encoders stubs - Add some util test classes - Write unit tests Change-Id: Ida49d42c89f3bb607aa4562d5a22f1a56ffc094a Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com> Issue-ID: DCAEGEN2-1113
-rw-r--r--services/hv-ves-client/producer/ct/pom.xml2
-rw-r--r--services/hv-ves-client/producer/impl/pom.xml15
-rw-r--r--services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerFactoryImpl.java8
-rw-r--r--services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java31
-rw-r--r--services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/ProducerCore.java50
-rw-r--r--services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/EncodersFactory.java33
-rw-r--r--services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/ProtobufEncoder.java44
-rw-r--r--services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/WireFrameEncoder.java43
-rw-r--r--services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/ProducerCoreTest.java83
-rw-r--r--services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/EncodersFactoryTest.java44
-rw-r--r--services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/ProtobufEncoderTest.java45
-rw-r--r--services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/WireFrameEncoderTest.java45
-rw-r--r--services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/utils/VesEventDomain.java45
-rw-r--r--services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/utils/VesEvents.java74
14 files changed, 539 insertions, 23 deletions
diff --git a/services/hv-ves-client/producer/ct/pom.xml b/services/hv-ves-client/producer/ct/pom.xml
index ba8861c9..237f0f57 100644
--- a/services/hv-ves-client/producer/ct/pom.xml
+++ b/services/hv-ves-client/producer/ct/pom.xml
@@ -62,10 +62,12 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
diff --git a/services/hv-ves-client/producer/impl/pom.xml b/services/hv-ves-client/producer/impl/pom.xml
index a5d6b90a..b099b316 100644
--- a/services/hv-ves-client/producer/impl/pom.xml
+++ b/services/hv-ves-client/producer/impl/pom.xml
@@ -47,5 +47,20 @@
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerFactoryImpl.java b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerFactoryImpl.java
index ad402f93..cf656adf 100644
--- a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerFactoryImpl.java
+++ b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerFactoryImpl.java
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducer;
import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducerFactory;
import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.ProducerOptions;
+import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders.EncodersFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.netty.tcp.TcpClient;
@@ -39,16 +40,17 @@ public class HvVesProducerFactoryImpl extends HvVesProducerFactory {
@Override
protected @NotNull HvVesProducer createProducer(ProducerOptions options) {
TcpClient tcpClient = TcpClient.create()
- .addressSupplier(() -> options.collectorAddresses().head());
+ .addressSupplier(() -> options.collectorAddresses().head());
+ ProducerCore producerCore = new ProducerCore(new EncodersFactory());
if (options.securityKeys() == null) {
LOGGER.warn("Using insecure connection");
} else {
LOGGER.info("Using secure tunnel");
final SslContext ctx = sslFactory.createSecureContext(options.securityKeys()).get();
- tcpClient = tcpClient.secure(ssl-> ssl.sslContext(ctx));
+ tcpClient = tcpClient.secure(ssl -> ssl.sslContext(ctx));
}
- return new HvVesProducerImpl(tcpClient);
+ return new HvVesProducerImpl(tcpClient, producerCore);
}
}
diff --git a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java
index 15038c3a..05873f6f 100644
--- a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java
+++ b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java
@@ -19,15 +19,10 @@
*/
package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl;
-import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.jetbrains.annotations.NotNull;
import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducer;
import org.onap.ves.VesEventOuterClass.VesEvent;
import org.reactivestreams.Publisher;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.NettyOutbound;
import reactor.netty.tcp.TcpClient;
@@ -38,30 +33,26 @@ import reactor.netty.tcp.TcpClient;
*/
public class HvVesProducerImpl implements HvVesProducer {
- private static final Logger LOGGER = LoggerFactory.getLogger(HvVesProducerImpl.class);
private final TcpClient tcpClient;
+ private final ProducerCore producerCore;
- HvVesProducerImpl(TcpClient tcpClient) {
+
+ HvVesProducerImpl(TcpClient tcpClient, ProducerCore producerCore) {
this.tcpClient = tcpClient;
+ this.producerCore = producerCore;
}
@Override
public @NotNull Mono<Void> send(Publisher<VesEvent> messages) {
return tcpClient
- .handle((inbound, outbound) -> handle(outbound, messages))
- .connect().then();
+ .handle((in, out) -> handle(messages, out))
+ .connect()
+ .then();
}
- private Publisher<Void> handle(NettyOutbound outbound, Publisher<VesEvent> messages) {
- final Flux<ByteBuf> encodedMessages = Flux.from(messages)
- .map(msg -> {
- LOGGER.debug("Encoding VesEvent '{}'", msg);
- final ByteBuf encodedMessage = outbound.alloc().buffer();
- encodedMessage.writeCharSequence(msg.getCommonEventHeader().getDomain(), StandardCharsets.UTF_8);
- encodedMessage.writeByte(0x0a);
- return encodedMessage;
- });
-
- return outbound.send(encodedMessages).then();
+ private Publisher<Void> handle(Publisher<VesEvent> messages, NettyOutbound outbound) {
+ return outbound
+ .send(producerCore.encode(messages, outbound.alloc()))
+ .then();
}
}
diff --git a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/ProducerCore.java b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/ProducerCore.java
new file mode 100644
index 00000000..baa6d6b3
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/ProducerCore.java
@@ -0,0 +1,50 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders.EncodersFactory;
+import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders.ProtobufEncoder;
+import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders.WireFrameEncoder;
+import org.onap.ves.VesEventOuterClass.VesEvent;
+import org.reactivestreams.Publisher;
+import reactor.core.publisher.Flux;
+
+
+/**
+ * @author <a href="mailto:jakub.dudycz@nokia.com">Jakub Dudycz</a>
+ */
+public class ProducerCore {
+
+ private final EncodersFactory encodersFactory;
+
+ public ProducerCore(EncodersFactory encodersFactory) {
+ this.encodersFactory = encodersFactory;
+ }
+
+ public Flux<ByteBuf> encode(Publisher<VesEvent> messages, ByteBufAllocator allocator) {
+ final WireFrameEncoder wireFrameEncoder = encodersFactory.createWireFrameEncoder(allocator);
+ final ProtobufEncoder protobufEncoder = encodersFactory.createProtobufEncoder(allocator);
+ return Flux.from(messages)
+ .map(protobufEncoder::encode)
+ .map(wireFrameEncoder::encode);
+ }
+}
diff --git a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/EncodersFactory.java b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/EncodersFactory.java
new file mode 100644
index 00000000..1d7b8b62
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/EncodersFactory.java
@@ -0,0 +1,33 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders;
+
+import io.netty.buffer.ByteBufAllocator;
+
+public class EncodersFactory {
+
+ public ProtobufEncoder createProtobufEncoder(ByteBufAllocator allocator) {
+ return new ProtobufEncoder(allocator);
+ }
+
+ public WireFrameEncoder createWireFrameEncoder(ByteBufAllocator allocator) {
+ return new WireFrameEncoder(allocator);
+ }
+}
diff --git a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/ProtobufEncoder.java b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/ProtobufEncoder.java
new file mode 100644
index 00000000..bb861c28
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/ProtobufEncoder.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.onap.ves.VesEventOuterClass.VesEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author <a href="mailto:jakub.dudycz@nokia.com">Jakub Dudycz</a>
+ */
+public class ProtobufEncoder {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProtobufEncoder.class);
+ private final ByteBufAllocator allocator;
+
+ public ProtobufEncoder(ByteBufAllocator allocator) {
+ this.allocator = allocator;
+ }
+
+ public ByteBuf encode(VesEvent event) {
+ LOGGER.debug("Encoding VesEvent '{}'", event);
+ return allocator.buffer().writeBytes(event.toByteArray());
+ }
+}
diff --git a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/WireFrameEncoder.java b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/WireFrameEncoder.java
new file mode 100644
index 00000000..a0807c68
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/WireFrameEncoder.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+
+/**
+ * @author <a href="mailto:jakub.dudycz@nokia.com">Jakub Dudycz</a>
+ */
+public class WireFrameEncoder {
+
+ private final ByteBufAllocator allocator;
+
+ public WireFrameEncoder(ByteBufAllocator allocator) {
+ this.allocator = allocator;
+ }
+
+ public ByteBuf encode(ByteBuf payload) {
+ final ByteBuf encodedMessage = allocator.buffer();
+ encodedMessage.writeByte(0xAA);
+ encodedMessage.writeBytes(payload);
+ encodedMessage.writeByte(0x0a);
+ return encodedMessage;
+ }
+}
diff --git a/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/ProducerCoreTest.java b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/ProducerCoreTest.java
new file mode 100644
index 00000000..c4211ff4
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/ProducerCoreTest.java
@@ -0,0 +1,83 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.utils.VesEvents.defaultVesEvent;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.buffer.Unpooled;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders.EncodersFactory;
+import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders.ProtobufEncoder;
+import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders.WireFrameEncoder;
+import org.onap.ves.VesEventOuterClass.VesEvent;
+import reactor.core.publisher.Flux;
+
+/**
+ * @author <a href="mailto:jakub.dudycz@nokia.com">Jakub Dudycz</a>
+ */
+public class ProducerCoreTest {
+
+ private ProducerCore producerCore;
+ private EncodersFactory encodersFactoryMock;
+
+ @BeforeEach
+ public void setUp() {
+ encodersFactoryMock = mock(EncodersFactory.class);
+ producerCore = new ProducerCore(encodersFactoryMock);
+ }
+
+ @Test
+ public void encode_should_encode_message_stream_to_wire_frame() {
+ final WireFrameEncoder wireFrameEncoder = mock(WireFrameEncoder.class);
+ final ProtobufEncoder protobufEncoder = mock(ProtobufEncoder.class);
+ final ByteBuf protoBuffer = Unpooled.copiedBuffer(new byte[3]);
+ final ByteBuf wireFrameBuffer = Unpooled.copiedBuffer(new byte[5]);
+
+ when(protobufEncoder.encode(any(VesEvent.class))).thenReturn(protoBuffer);
+ when(wireFrameEncoder.encode(protoBuffer)).thenReturn(wireFrameBuffer);
+ when(encodersFactoryMock.createProtobufEncoder(ByteBufAllocator.DEFAULT)).thenReturn(protobufEncoder);
+ when(encodersFactoryMock.createWireFrameEncoder(ByteBufAllocator.DEFAULT)).thenReturn(wireFrameEncoder);
+
+ // given
+ final int messageStreamSize = 2;
+ final Flux<VesEvent> messages = Flux.just(defaultVesEvent()).repeat(messageStreamSize - 1);
+
+ // when
+ final ByteBuf lastMessage = producerCore.encode(messages, ByteBufAllocator.DEFAULT).blockLast();
+
+ // then
+ verify(encodersFactoryMock).createProtobufEncoder(ByteBufAllocator.DEFAULT);
+ verify(encodersFactoryMock).createWireFrameEncoder(ByteBufAllocator.DEFAULT);
+ verify(protobufEncoder, times(messageStreamSize)).encode(any(VesEvent.class));
+ verify(wireFrameEncoder, times(messageStreamSize)).encode(protoBuffer);
+
+ assertThat(lastMessage).isNotNull();
+ assertThat(lastMessage).isEqualTo(wireFrameBuffer);
+ }
+}
diff --git a/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/EncodersFactoryTest.java b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/EncodersFactoryTest.java
new file mode 100644
index 00000000..c7439ced
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/EncodersFactoryTest.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import io.netty.buffer.ByteBufAllocator;
+import org.junit.jupiter.api.Test;
+
+/**
+ * @author <a href="mailto:jakub.dudycz@nokia.com">Jakub Dudycz</a>
+ */
+public class EncodersFactoryTest {
+
+ private final EncodersFactory encodersFactory = new EncodersFactory();
+
+ @Test
+ public void factory_methods_should_create_non_null_encoders_objects() {
+ // when
+ final ProtobufEncoder protobufEncoder = encodersFactory.createProtobufEncoder(ByteBufAllocator.DEFAULT);
+ final WireFrameEncoder wireFrameEncoder = encodersFactory.createWireFrameEncoder(ByteBufAllocator.DEFAULT);
+
+ // then
+ assertThat(protobufEncoder).isNotNull();
+ assertThat(wireFrameEncoder).isNotNull();
+ }
+}
diff --git a/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/ProtobufEncoderTest.java b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/ProtobufEncoderTest.java
new file mode 100644
index 00000000..042874c4
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/ProtobufEncoderTest.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.utils.VesEvents;
+import org.onap.ves.VesEventOuterClass.VesEvent;
+
+public class ProtobufEncoderTest {
+
+ private final ProtobufEncoder protobufEncoder = new ProtobufEncoder(ByteBufAllocator.DEFAULT);
+
+ @Test
+ void todo() {
+ // given
+ final VesEvent message = VesEvents.defaultVesEvent();
+
+ // when
+ final ByteBuf encodedMessage = protobufEncoder.encode(message);
+
+ // then
+ assertThat(encodedMessage.readableBytes()).isGreaterThan(0);
+ }
+}
diff --git a/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/WireFrameEncoderTest.java b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/WireFrameEncoderTest.java
new file mode 100644
index 00000000..97c38cf2
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/encoders/WireFrameEncoderTest.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.buffer.Unpooled;
+import org.junit.jupiter.api.Test;
+
+public class WireFrameEncoderTest {
+
+ private final WireFrameEncoder wireFrameEncoder = new WireFrameEncoder(ByteBufAllocator.DEFAULT);
+
+ @Test
+ void todo() {
+ // given
+ final ByteBuf buffer = Unpooled.buffer(0);
+
+ // when
+ final ByteBuf encodedBuffer = wireFrameEncoder.encode(buffer);
+
+ // then
+ assertThat(encodedBuffer.readableBytes()).isGreaterThan(0);
+ }
+
+}
diff --git a/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/utils/VesEventDomain.java b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/utils/VesEventDomain.java
new file mode 100644
index 00000000..7d5b1872
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/utils/VesEventDomain.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl.utils;
+
+public enum VesEventDomain {
+ FAULT("fault"),
+ HEARTBEAT("heartbeat"),
+ MEASUREMENT("measurement"),
+ MOBILE_FLOW("mobileFlow"),
+ OTHER("other"),
+ PNF_REGISTRATION("pnfRegistration"),
+ SIP_SIGNALING("sipSignaling"),
+ STATE_CHANGE("stateChange"),
+ SYSLOG("syslog"),
+ THRESHOLD_CROSSING_ALERT("thresholdCrossingAlert"),
+ VOICE_QUALITY("voiceQuality"),
+ PERF3GPP("perf3gpp");
+
+ private String name;
+
+ VesEventDomain(String name) {
+ this.name = name;
+ }
+
+ public String domainName() {
+ return name;
+ }
+}
diff --git a/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/utils/VesEvents.java b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/utils/VesEvents.java
new file mode 100644
index 00000000..0b9ae376
--- /dev/null
+++ b/services/hv-ves-client/producer/impl/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/utils/VesEvents.java
@@ -0,0 +1,74 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.dcaegen2.services.sdk.services.hvves.client.producer.impl.utils;
+
+import com.google.protobuf.ByteString;
+import java.util.UUID;
+import org.onap.ves.VesEventOuterClass.CommonEventHeader;
+import org.onap.ves.VesEventOuterClass.CommonEventHeader.Priority;
+import org.onap.ves.VesEventOuterClass.VesEvent;
+
+public final class VesEvents {
+
+ private VesEvents() {
+ }
+
+ public static VesEvent defaultVesEvent() {
+ return vesEvent(VesEventDomain.PERF3GPP, UUID.randomUUID().toString(), ByteString.EMPTY);
+ }
+
+ public static VesEvent vesEvent(VesEventDomain domain, String id, ByteString eventFields) {
+ return vesEvent(commonEventHeader(domain, id), eventFields);
+ }
+
+ private static VesEvent vesEvent(CommonEventHeader commonEventHeader, ByteString eventFields) {
+ return VesEvent
+ .newBuilder()
+ .setCommonEventHeader(commonEventHeader)
+ .setEventFields(eventFields)
+ .build();
+ }
+
+ private static CommonEventHeader commonEventHeader(
+ VesEventDomain domain,
+ String id
+ ) {
+ return CommonEventHeader.newBuilder()
+ .setVersion("sample-version")
+ .setDomain(domain.domainName())
+ .setSequence(1)
+ .setPriority(Priority.NORMAL)
+ .setEventId(id)
+ .setEventName("sample-event-name")
+ .setEventType("sample-event-type")
+ .setStartEpochMicrosec(100000000)
+ .setLastEpochMicrosec(100000005)
+ .setNfNamingCode("sample-nf-naming-code")
+ .setNfcNamingCode("sample-nfc-naming-code")
+ .setNfVendorName("sample-vendor-name")
+ .setReportingEntityId(ByteString.copyFromUtf8("sample-reporting-entity-id"))
+ .setReportingEntityName("sample-reporting-entity-name")
+ .setSourceId(ByteString.copyFromUtf8("sample-source-id"))
+ .setSourceName("sample-source-name")
+ .setTimeZoneOffset("+1")
+ .setVesEventListenerVersion("7.0.2")
+ .build();
+ }
+}