2  * ============LICENSE_START=======================================================
 
   3  * dcaegen2-collectors-veshv
 
   4  * ================================================================================
 
   5  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
 
   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.component
 
  22 import org.assertj.core.api.Assertions.assertThat
 
  23 import org.jetbrains.spek.api.Spek
 
  24 import org.jetbrains.spek.api.dsl.describe
 
  25 import org.onap.dcae.collectors.veshv.tests.fakes.HVRANMEAS_TOPIC
 
  26 import org.onap.dcae.collectors.veshv.tests.fakes.basicConfiguration
 
  27 import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain
 
  30  * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
 
  33 object VesHvSpecification : Spek({
 
  34     describe("VES High Volume Collector") {
 
  35         system("should handle multiple HV RAN events") { sut ->
 
  36             sut.configurationProvider.updateConfiguration(basicConfiguration)
 
  37             val messages = sut.handleConnection(vesMessage(Domain.HVRANMEAS), vesMessage(Domain.HVRANMEAS))
 
  40                     .describedAs("should send all events")
 
  44         system("should release memory for each incoming message") { sut ->
 
  45             sut.configurationProvider.updateConfiguration(basicConfiguration)
 
  46             val msgWithInvalidDomain = vesMessage(Domain.OTHER)
 
  47             val msgWithInvalidPayload = invalidVesMessage()
 
  48             val msgWithInvalidFrame = invalidWireFrame()
 
  49             val validMessage = vesMessage(Domain.HVRANMEAS)
 
  51             sut.handleConnection(msgWithInvalidDomain, msgWithInvalidPayload, msgWithInvalidFrame, validMessage)
 
  53             assertThat(msgWithInvalidDomain.refCnt())
 
  54                     .describedAs("message with invalid domain should be released")
 
  56             assertThat(msgWithInvalidPayload.refCnt())
 
  57                     .describedAs("message with invalid payload should be released")
 
  59             assertThat(msgWithInvalidFrame.refCnt())
 
  60                     .describedAs("message with invalid frame should be released")
 
  62             assertThat(validMessage.refCnt())
 
  63                     .describedAs("handled message should be released")
 
  68     describe("message routing") {
 
  69         system("should direct message to a topic by means of routing configuration") { sut ->
 
  70             sut.configurationProvider.updateConfiguration(basicConfiguration)
 
  72             val messages = sut.handleConnection(vesMessage(Domain.HVRANMEAS))
 
  73             assertThat(messages).describedAs("number of routed messages").hasSize(1)
 
  76             assertThat(msg.topic).describedAs("routed message topic").isEqualTo(HVRANMEAS_TOPIC)
 
  77             assertThat(msg.partition).describedAs("routed message partition").isEqualTo(1)
 
  80         system("should drop message if route was not found") { sut ->
 
  81             sut.configurationProvider.updateConfiguration(basicConfiguration)
 
  82             val messages = sut.handleConnection(
 
  83                     vesMessage(Domain.OTHER, "first"),
 
  84                     vesMessage(Domain.HVRANMEAS, "second"),
 
  85                     vesMessage(Domain.HEARTBEAT, "third"))
 
  87             assertThat(messages).describedAs("number of routed messages").hasSize(1)
 
  90             assertThat(msg.topic).describedAs("routed message topic").isEqualTo(HVRANMEAS_TOPIC)
 
  91             assertThat(msg.message.header.eventId).describedAs("routed message eventId").isEqualTo("second")