2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018 NOKIA
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dcae.collectors.veshv.tests.utils
23 import com.google.protobuf.ByteString
24 import com.google.protobuf.MessageLite
25 import org.onap.dcae.collectors.veshv.domain.ByteData
26 import org.onap.dcae.collectors.veshv.domain.VesEventDomain
27 import org.onap.dcae.collectors.veshv.domain.VesEventDomain.PERF3GPP
28 import org.onap.ves.VesEventOuterClass
29 import org.onap.ves.VesEventOuterClass.CommonEventHeader
30 import org.onap.ves.VesEventOuterClass.CommonEventHeader.Priority
31 import java.util.UUID.randomUUID
33 fun vesEvent(domain: VesEventDomain = PERF3GPP,
34 id: String = randomUUID().toString(),
35 eventFields: ByteString = ByteString.EMPTY
36 ): VesEventOuterClass.VesEvent = vesEvent(commonHeader(domain, id), eventFields)
38 fun vesEvent(commonEventHeader: CommonEventHeader,
39 eventFields: ByteString = ByteString.EMPTY): VesEventOuterClass.VesEvent =
40 VesEventOuterClass.VesEvent.newBuilder()
41 .setCommonEventHeader(commonEventHeader)
42 .setEventFields(eventFields)
45 fun commonHeader(domain: VesEventDomain = PERF3GPP,
46 id: String = randomUUID().toString(),
47 priority: Priority = Priority.NORMAL,
48 vesEventListenerVersion: String = "7.0.2"): CommonEventHeader =
49 CommonEventHeader.newBuilder()
50 .setVersion("sample-version")
51 .setDomain(domain.domainName)
53 .setPriority(priority)
55 .setEventName("sample-event-name")
56 .setEventType("sample-event-type")
57 .setStartEpochMicrosec(120034455)
58 .setLastEpochMicrosec(120034455)
59 .setNfNamingCode("sample-nf-naming-code")
60 .setNfcNamingCode("sample-nfc-naming-code")
61 .setNfVendorName("vendor-name")
62 .setReportingEntityId(ByteString.copyFromUtf8("sample-reporting-entity-id"))
63 .setReportingEntityName("sample-reporting-entity-name")
64 .setSourceId(ByteString.copyFromUtf8("sample-source-id"))
65 .setSourceName("sample-source-name")
66 .setTimeZoneOffset("+1")
67 .setVesEventListenerVersion(vesEventListenerVersion)
70 fun vesEventBytes(commonHeader: CommonEventHeader, byteString: ByteString = ByteString.EMPTY): ByteData =
71 vesEvent(commonHeader, byteString).toByteData()
73 fun MessageLite.toByteData(): ByteData = ByteData(toByteArray())