summaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-test-utils/src
diff options
context:
space:
mode:
authorFilip Krzywka <filip.krzywka@nokia.com>2018-12-13 11:22:29 +0100
committerJakub Dudycz <jakub.dudycz@nokia.com>2018-12-14 10:58:22 +0100
commite32d91541ffa6c3ec13729032979af8160bdb8dc (patch)
tree9db481acbba5d6379576fe6eeb0eeee1ae7cc8e4 /sources/hv-collector-test-utils/src
parentd178c6dc0bcaf739d48f47191a20d8335a291883 (diff)
Create component tests skeleton for metrics
Change-Id: I5acc919171953a4bb428585a7b8420b3223aa556 Issue-ID: DCAEGEN2-1032 Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'sources/hv-collector-test-utils/src')
-rw-r--r--sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/messages.kt24
1 files changed, 11 insertions, 13 deletions
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))
+ )