From e32d91541ffa6c3ec13729032979af8160bdb8dc Mon Sep 17 00:00:00 2001 From: Filip Krzywka Date: Thu, 13 Dec 2018 11:22:29 +0100 Subject: Create component tests skeleton for metrics Change-Id: I5acc919171953a4bb428585a7b8420b3223aa556 Issue-ID: DCAEGEN2-1032 Signed-off-by: Filip Krzywka --- .../dcae/collectors/veshv/tests/utils/messages.kt | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'sources/hv-collector-test-utils/src') diff --git a/sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/messages.kt b/sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/messages.kt index db7777c2..01e11665 100644 --- a/sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/messages.kt +++ b/sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/messages.kt @@ -27,6 +27,7 @@ import org.onap.dcae.collectors.veshv.domain.WireFrameMessage.Companion.RESERVED import org.onap.dcae.collectors.veshv.domain.VesEventDomain import org.onap.dcae.collectors.veshv.domain.VesEventDomain.PERF3GPP import org.onap.dcae.collectors.veshv.domain.VesEventDomain.OTHER +import org.onap.ves.VesEventOuterClass.VesEvent import java.util.UUID.randomUUID @@ -42,11 +43,15 @@ private fun ByteBuf.writeValidWireFrameHeaders() { } fun vesWireFrameMessage(domain: VesEventDomain = OTHER, - id: String = randomUUID().toString()): ByteBuf = + id: String = randomUUID().toString(), + eventFields: ByteString = ByteString.EMPTY): ByteBuf = + vesWireFrameMessage(vesEvent(domain, id, eventFields)) + +fun vesWireFrameMessage(vesEvent: VesEvent) = allocator.buffer().run { writeValidWireFrameHeaders() - val gpb = vesEvent(domain, id).toByteString().asReadOnlyByteBuffer() + val gpb = vesEvent.toByteString().asReadOnlyByteBuffer() writeInt(gpb.limit()) // ves event size in bytes writeBytes(gpb) // ves event as GPB bytes } @@ -70,16 +75,9 @@ fun invalidWireFrame(): ByteBuf = allocator.buffer().run { } fun vesMessageWithPayloadOfSize(payloadSizeBytes: Int, domain: VesEventDomain = PERF3GPP): ByteBuf = - allocator.buffer().run { - writeValidWireFrameHeaders() - - val gpb = vesEvent( - domain = domain, - eventFields = ByteString.copyFrom(ByteArray(payloadSizeBytes)) - ).toByteString().asReadOnlyByteBuffer() - - writeInt(gpb.limit()) // ves event size in bytes - writeBytes(gpb) // ves event as GPB bytes - } + vesWireFrameMessage( + domain = domain, + eventFields = ByteString.copyFrom(ByteArray(payloadSizeBytes)) + ) -- cgit 1.2.3-korg