android: false
autoCorrect: true
ChainWrapping:
- active: true
+ active: false
autoCorrect: true
CommentSpacing:
active: true
active: true
autoCorrect: true
ParameterListWrapping:
- active: true
+ active: false
autoCorrect: true
indentSize: 4
SpacingAroundColon:
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^'
MatchingDeclarationName:
- active: true
+ active: false
MemberNameEqualsClassName:
active: false
ignoreOverriddenFunction: true
UnusedImports:
active: false
UnusedPrivateMember:
- active: false
- allowedNames: "(_|ignored|expected)"
+ active: true
+ allowedNames: "(_.*|ignored|expected)"
UseDataClass:
active: false
excludeAnnotatedClasses: ""
fun consulConfigurationProvider(configurationProviderParams: ConfigurationProviderParams): ConfigurationProvider =
ConsulConfigurationProvider(httpAdapter(), configurationProviderParams)
- fun httpAdapter(): HttpAdapter = HttpAdapter(HttpClient.create())
+ private fun httpAdapter(): HttpAdapter = HttpAdapter(HttpClient.create())
}
-
import org.slf4j.LoggerFactory
import reactor.core.publisher.Mono
import reactor.netty.http.client.HttpClient
-import java.lang.IllegalStateException
-import java.nio.charset.Charset
/**
* @author Jakub Dudycz <jakub.dudycz@nokia.com>
.responseSingle { response, content ->
if (response.status().codeClass() == HttpStatusClass.SUCCESS)
content.asString()
- else
- Mono.error(IllegalStateException("$url ${response.status().code()} ${response.status().reasonPhrase()}"))
+ else {
+ val errorMessage = "$url ${response.status().code()} ${response.status().reasonPhrase()}"
+ Mono.error(IllegalStateException(errorMessage))
+ }
}
.doOnError {
logger.error("Failed to get resource on path: $url (${it.localizedMessage})")
}
fun withFixedPartitioning(num: Int = 0) {
- partitioning = { _ -> num }
+ partitioning = { num }
}
fun build() = Route(domain, targetTopic, partitioning)
import org.jetbrains.spek.api.dsl.it
import org.onap.dcae.collectors.veshv.domain.VesEventDomain.PERF3GPP
import org.onap.dcae.collectors.veshv.domain.WireFrameEncoder
-import org.onap.dcae.collectors.veshv.domain.WireFrameMessage
import org.onap.dcae.collectors.veshv.tests.fakes.CountingSink
import org.onap.dcae.collectors.veshv.tests.fakes.basicConfiguration
import org.onap.dcae.collectors.veshv.tests.utils.commonHeader
-import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageGenerator
import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParameters
import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType.VALID
import org.onap.dcae.collectors.veshv.ves.message.generator.factory.MessageGeneratorFactory
import reactor.math.sum
import java.security.MessageDigest
import java.time.Duration
-import java.util.Random
+import java.util.*
import kotlin.system.measureTimeMillis
/**
private fun shouldValidatePayloads(parameters: List<MessageParameters>) =
parameters.all { it.messageType == MessageType.FIXED_PAYLOAD }
-
- private fun validateHeaders(actual: List<VesEventOuterClass.VesEvent>, expected: List<VesEventOuterClass.VesEvent>): Boolean {
+ private fun validateHeaders(actual: List<VesEventOuterClass.VesEvent>,
+ expected: List<VesEventOuterClass.VesEvent>): Boolean {
val consumedHeaders = actual.map { it.commonEventHeader }
val generatedHeaders = expected.map { it.commonEventHeader }
return generatedHeaders == consumedHeaders
}
-
private fun generateEvents(parameters: List<MessageParameters>): IO<List<VesEventOuterClass.VesEvent>> =
messageGenerator.createMessageFlux(parameters)
.map(WireFrameMessage::payload)
return KafkaSource(KafkaReceiver.create(createReceiverOptions(bootstrapServers, topics)))
}
- fun createReceiverOptions(bootstrapServers: String, topics: Set<String>): ReceiverOptions<ByteArray, ByteArray>? {
+ fun createReceiverOptions(bootstrapServers: String,
+ topics: Set<String>): ReceiverOptions<ByteArray, ByteArray>? {
val props = mapOf<String, Any>(
ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG to bootstrapServers,
ConsumerConfig.CLIENT_ID_CONFIG to "hv-collector-dcae-app-simulator",
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.describe
import org.jetbrains.spek.api.dsl.it
-import org.jetbrains.spek.api.dsl.on
import reactor.kafka.receiver.ReceiverRecord
*/
package org.onap.dcae.collectors.veshv.domain
-import com.google.protobuf.MessageLite
import io.netty.buffer.ByteBuf
import java.nio.charset.Charset
}
}
+ @Suppress("ReturnCount")
private fun parsePayloadFrame(byteBuf: ByteBuf): Either<WireFrameDecodingError, WireFrameMessage> {
val versionMajor = byteBuf.readUnsignedByte()
val versionMinor = byteBuf.readUnsignedByte()
val payload = ByteData.readFrom(byteBuf, payloadSize)
return Right(WireFrameMessage(payload, versionMajor, versionMinor, payloadTypeRaw, payloadSize))
-
}
}
*/
package org.onap.dcae.collectors.veshv.domain
-
/**
* Wire frame structure is presented bellow using ASN.1 notation. Please note that official supported specification
* should be available on
NettyServerHandle(ctx.bindNow())
}
- private fun readinessHandler(req: HttpServerRequest, resp: HttpServerResponse) =
+ private fun readinessHandler(_req: HttpServerRequest, resp: HttpServerResponse) =
healthDescription.get().run {
resp.status(status.httpResponseStatus.number).sendString(Flux.just(status.toString(), "\n", message))
}
- private fun livenessHandler(req: HttpServerRequest, resp: HttpServerResponse) =
+ private fun livenessHandler(_req: HttpServerRequest, resp: HttpServerResponse) =
resp.status(HttpResponseStatus.NOT_IMPLEMENTED).sendString(Mono.just("Not implemented yet"))
-
}
)
val listenPort = cmdLine.intValue(LISTEN_PORT).bind()
val idleTimeoutSec = cmdLine.longValue(IDLE_TIMEOUT_SEC, DefaultValues.IDLE_TIMEOUT_SEC)
- val maxPayloadSizeBytes = cmdLine.intValue(MAXIMUM_PAYLOAD_SIZE_BYTES, DefaultValues.MAX_PAYLOAD_SIZE_BYTES)
+ val maxPayloadSizeBytes = cmdLine.intValue(MAXIMUM_PAYLOAD_SIZE_BYTES,
+ DefaultValues.MAX_PAYLOAD_SIZE_BYTES)
val dummyMode = cmdLine.hasOption(DUMMY_MODE)
val security = createSecurityConfiguration(cmdLine).bind()
val configurationProviderParams = createConfigurationProviderParams(cmdLine).bind()
override fun serverStartedMessage(handle: ServerHandle) =
"HighVolume VES Collector is up and listening on ${handle.host}:${handle.port}"
-}
\ No newline at end of file
+}
}
}
- protected open fun createSslContextWithConfiguredCerts(secConfig: SecurityConfiguration): Option<SslContextBuilder> =
+ protected open fun createSslContextWithConfiguredCerts(
+ secConfig: SecurityConfiguration
+ ): Option<SslContextBuilder> =
secConfig.keys.map { keys ->
when (keys) {
is JdkKeys -> jdkContext(keys)
*/
package org.onap.dcae.collectors.veshv.ssl.boundary
-import arrow.core.Left
-import arrow.core.Option
-import arrow.core.Right
import arrow.core.Some
import arrow.core.toOption
import io.netty.handler.ssl.ClientAuth
import arrow.core.Option
import arrow.core.Try
import arrow.core.flatMap
-import arrow.core.getOrElse
import org.apache.commons.cli.CommandLine
import org.apache.commons.cli.CommandLineParser
import org.apache.commons.cli.Options
-import org.onap.dcae.collectors.veshv.utils.arrow.fromNullablesChain
import java.io.File
import java.nio.file.Path
import java.nio.file.Paths
*/
package org.onap.dcae.collectors.veshv.utils.logging
-import org.slf4j.LoggerFactory
import kotlin.reflect.KClass
+import org.slf4j.LoggerFactory
+@Suppress("TooManyFunctions")
class Logger(val logger: org.slf4j.Logger) {
constructor(clazz: KClass<out Any>) : this(LoggerFactory.getLogger(clazz.java))
constructor(name: String) : this(LoggerFactory.getLogger(name))
}
}
-
//
// DEBUG
//
}
}
-
//
// INFO
//
logger.info(message)
}
-
fun info(messageProvider: () -> String) {
if (logger.isInfoEnabled) {
logger.info(messageProvider())
logger.info(message, t)
}
-
fun info(t: Throwable, messageProvider: () -> String) {
if (logger.isInfoEnabled) {
logger.info(messageProvider(), t)
}
}
-
//
// WARN
//
}
}
-
//
// ERROR
//
logger.error(message)
}
-
fun error(message: String, t: Throwable) {
logger.error(message, t)
}
*/
package org.onap.dcae.collectors.veshv.utils.logging
-import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
Try {
request
.map { it.asJsonObject() }
- .map {
+ .map { json ->
val commonEventHeader = commonEventHeaderParser
- .parse(it.getJsonObject("commonEventHeader"))
+ .parse(json.getJsonObject("commonEventHeader"))
.fold({ throw IllegalStateException("Invalid common header") }, ::identity)
- val messageType = MessageType.valueOf(it.getString("messageType"))
- val messagesAmount = it.getJsonNumber("messagesAmount")?.longValue()
- ?: throw NullPointerException("\"messagesAmount\" could not be parsed from message.")
+ val messageType = MessageType.valueOf(json.getString("messageType"))
+ val messagesAmount = json.getJsonNumber("messagesAmount")?.longValue()
+ ?: throw NullPointerException("\"messagesAmount\" could not be parsed.")
MessageParameters(commonEventHeader, messageType, messagesAmount)
}
}.toEither().mapLeft { ex ->
ex.message ?: "Unable to parse message parameters",
Option.fromNullable(ex))
}
-
}
.toString()
.toByteArray()
)
-
}
fun assertFailed(result: Option<CommonEventHeader>) =
result.fold({}, { fail() })
-fun jsonObject(json: ByteArrayInputStream) = Json.createReader(json).readObject()
\ No newline at end of file
+fun jsonObject(json: ByteArrayInputStream) = Json.createReader(json).readObject()!!
\ No newline at end of file
*/
package org.onap.dcae.collectors.veshv.ves.message.generator.impl
+import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
-import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.dsl.on
-import org.onap.dcae.collectors.veshv.ves.message.generator.impl.PayloadGenerator
object PayloadGeneratorTest : Spek({
fun validMessagesParametesJson() = Json
.createReader(validMessageParameters.reader())
- .readArray()
+ .readArray()!!
fun invalidMessagesParametesJson() = Json
.createReader(invalidMessageParameters.reader())
- .readArray()
+ .readArray()!!
import org.onap.dcae.collectors.veshv.utils.commandline.intValue
import org.onap.dcae.collectors.veshv.utils.commandline.stringValue
-
/**
* @author Jakub Dudycz <jakub.dudycz@nokia.com>
* @since June 2018
val listenPort = cmdLine.intValue(LISTEN_PORT).bind()
val vesHost = cmdLine.stringValue(VES_HV_HOST).bind()
val vesPort = cmdLine.intValue(VES_HV_PORT).bind()
- val maxPayloadSizeBytes = cmdLine.intValue(MAXIMUM_PAYLOAD_SIZE_BYTES, WireFrameMessage.DEFAULT_MAX_PAYLOAD_SIZE_BYTES)
+ val maxPayloadSizeBytes = cmdLine.intValue(MAXIMUM_PAYLOAD_SIZE_BYTES,
+ WireFrameMessage.DEFAULT_MAX_PAYLOAD_SIZE_BYTES)
SimulatorConfiguration(
listenPort,
maxPayloadSizeBytes,
createSecurityConfiguration(cmdLine).bind())
}.fix()
-
-
}
import org.onap.dcae.collectors.veshv.simulators.xnf.impl.StatusOngoing
import org.onap.dcae.collectors.veshv.simulators.xnf.impl.StatusSuccess
import org.onap.dcae.collectors.veshv.tests.utils.waitUntilSucceeds
-import java.time.Duration
import java.util.*
import java.util.concurrent.Executors
<arg value="onap-detekt-config.yml"/>
<arg value="--filters"/>
<arg value=".*/target/.*,.*/resources/.*"/>
- <arg value="--output"/>
- <arg value="${basedir}/target/reports"/>
- <arg value="--output-name"/>
- <arg value="detekt-report"/>
+ <arg value="--report"/>
+ <arg value="detekt-report:${basedir}/target/reports"/>
<arg value="--baseline"/>
<arg value="${basedir}/target/reports/baseline.xml"/>
</java>
<dependency>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-cli</artifactId>
- <version>1.0.0.RC7</version>
+ <version>1.0.0-RC11</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>