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 vesEventListenerVersion: String = "7.0.2"
37 ): VesEventOuterClass.VesEvent = vesEvent(
38 commonHeader(domain, id, vesEventListenerVersion),
42 fun vesEvent(commonEventHeader: CommonEventHeader,
43 eventFields: ByteString = ByteString.EMPTY): VesEventOuterClass.VesEvent =
44 VesEventOuterClass.VesEvent.newBuilder()
45 .setCommonEventHeader(commonEventHeader)
46 .setEventFields(eventFields)
49 fun commonHeader(domain: VesEventDomain = PERF3GPP,
50 id: String = randomUUID().toString(),
51 vesEventListenerVersion: String = "7.0.2",
52 priority: Priority = Priority.NORMAL
53 ): CommonEventHeader =
54 CommonEventHeader.newBuilder()
55 .setVersion("sample-version")
56 .setDomain(domain.domainName)
58 .setPriority(priority)
60 .setEventName("sample-event-name")
61 .setEventType("sample-event-type")
62 .setStartEpochMicrosec(120034455)
63 .setLastEpochMicrosec(120034455)
64 .setNfNamingCode("sample-nf-naming-code")
65 .setNfcNamingCode("sample-nfc-naming-code")
66 .setNfVendorName("vendor-name")
67 .setReportingEntityId(ByteString.copyFromUtf8("sample-reporting-entity-id"))
68 .setReportingEntityName("sample-reporting-entity-name")
69 .setSourceId(ByteString.copyFromUtf8("sample-source-id"))
70 .setSourceName("sample-source-name")
71 .setTimeZoneOffset("+1")
72 .setVesEventListenerVersion(vesEventListenerVersion)
75 fun vesEventBytes(commonHeader: CommonEventHeader, byteString: ByteString = ByteString.EMPTY): ByteData =
76 vesEvent(commonHeader, byteString).toByteData()
78 fun MessageLite.toByteData(): ByteData = ByteData(toByteArray())