Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/migrering til kotlin 9.21 #29

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
buildscript {
ext {
kotlinVersion = '1.9.21'
springBootVersion = '3.1.5'
springKafkaVersion = '3.0.12'
archunitVersion = '1.2.1'
Expand All @@ -20,6 +21,8 @@ buildscript {
plugins {
id "org.springframework.boot" version "$springBootVersion"
id "io.spring.dependency-management" version "1.1.4"
id "org.jetbrains.kotlin.plugin.allopen" version "$kotlinVersion"
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion"
}

apply from: "buildSrc/ep-module.gradle"
Expand Down Expand Up @@ -87,18 +90,4 @@ dependencies {
// Architecture tests
testImplementation ("com.tngtech.archunit:archunit:${archunitVersion}")

}

test {
// set heap size for the test JVM(s)
minHeapSize = "128m"
maxHeapSize = "512m"

// set JVM arguments for the test JVM(s)
failFast = true
testLogging {
exceptionFormat "full"
events "started", "skipped", "passed", "failed"
showStandardStreams true
}
}
}
8 changes: 3 additions & 5 deletions buildSrc/ep-module.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
kotlinVersion = '1.9.10'
kotlinVersion = '1.9.21'
}
repositories {
mavenCentral()
Expand All @@ -14,13 +14,11 @@ buildscript {
classpath "se.patrikerdes:gradle-use-latest-versions-plugin:0.2.18"
classpath "org.owasp:dependency-check-gradle:8.1.0"
classpath "com.adarshr:gradle-test-logger-plugin:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
}
}

apply plugin: org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
apply plugin: org.jetbrains.kotlin.allopen.gradle.SpringGradleSubplugin
//apply plugin: org.jetbrains.kotlin.allopen.gradle.SpringGradleSubplugin
apply plugin: com.github.benmanes.gradle.versions.VersionsPlugin
apply plugin: se.patrikerdes.UseLatestVersionsPlugin
apply plugin: org.owasp.dependencycheck.gradle.DependencyCheckPlugin
Expand Down Expand Up @@ -71,7 +69,7 @@ compileTestKotlin {

test {
useJUnitPlatform()
failFast = true
failFast = false
testlogger {
theme 'mocha' // task level
showFullStackTraces true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,13 @@ class StatistikkListener(
private val latch = CountDownLatch(1)
private val latchMottatt = CountDownLatch(1)

private lateinit var opprettMeldingMetric: MetricsHelper.Metric
private lateinit var sedMottattMeldingMetric: MetricsHelper.Metric
private lateinit var sedSedSendMeldingtMetric: MetricsHelper.Metric
private var opprettMeldingMetric: MetricsHelper.Metric = metricsHelper.init("consumeOpprettMelding")
private var sedMottattMeldingMetric: MetricsHelper.Metric = metricsHelper.init("consumeSedMottatt")
private var sedSedSendMeldingtMetric: MetricsHelper.Metric = metricsHelper.init("consumeSedSendtMelding")

fun getLatch() = latch
fun getLatchMottatt() = latchMottatt
init {
opprettMeldingMetric = metricsHelper.init("consumeOpprettMelding")
sedMottattMeldingMetric = metricsHelper.init("consumeSedMottatt")
sedSedSendMeldingtMetric = metricsHelper.init("consumeSedSendtMelding")
}

@KafkaListener(
containerFactory = "kafkaListenerContainerFactory",
topics = ["\${kafka.statistikk-inn.topic}"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.springframework.retry.annotation.EnableRetry
@Profile("integrationtest")
@SpringBootApplication
@EnableRetry
class StatistikkApplicationIntegration
open class StatistikkApplicationIntegration

fun main(args: Array<String>) {
runApplication<StatistikkApplicationIntegration>(*args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package no.nav.eessi.pensjon.statistikk.integrationtest

import com.ninjasquad.springmockk.MockkBean
import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import io.mockk.spyk
import no.nav.eessi.pensjon.gcp.GcpStorageService
import no.nav.eessi.pensjon.statistikk.listener.StatistikkListener
import no.nav.eessi.pensjon.statistikk.services.StatistikkPublisher
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient
import org.apache.hc.client5.http.impl.classic.HttpClients
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder
import org.apache.hc.client5.http.io.HttpClientConnectionManager
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder
import org.apache.hc.client5.http.ssl.TrustAllStrategy
import org.apache.hc.core5.ssl.SSLContexts
import org.apache.hc.core5.ssl.TrustStrategy
import org.junit.jupiter.api.AfterEach
Expand Down Expand Up @@ -44,7 +44,10 @@ const val STATISTIKK_TOPIC_MOTATT = "eessi-pensjon-statistikk-sed-mottatt"
private var mockServerPort = PortFactory.findFreePort()
private lateinit var mockServer: ClientAndServer

abstract class IntegrationBase() {
abstract class IntegrationBase {

@MockkBean
lateinit var gcpStorageService: GcpStorageService

@Autowired
lateinit var statistikkListener: StatistikkListener
Expand Down Expand Up @@ -115,20 +118,15 @@ abstract class IntegrationBase() {
}

@TestConfiguration
class TestConfig {
open class TestConfig {

@Bean
fun statistikkPublisher(): StatistikkPublisher {
open fun statistikkPublisher(): StatistikkPublisher {
return spyk(StatistikkPublisher(mockk(relaxed = true), "bogusTopic"))
}

@Bean
fun gcpStorageService(): GcpStorageService {
return mockk()
}

@Bean
fun euxClientCredentialsResourceRestTemplate(templateBuilder: RestTemplateBuilder): RestTemplate {
open fun euxClientCredentialsResourceRestTemplate(): RestTemplate {
val acceptingTrustStrategy = TrustStrategy { _: Array<X509Certificate?>?, _: String? -> true }

val sslcontext: SSLContext = SSLContexts.custom()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import java.time.Duration
@EnableKafka
@Profile("integrationtest")
@Configuration
class IntegrationtestConfig(
open class IntegrationtestConfig(
@param:Value("\${spring.embedded.kafka.brokers}") private val bootstrapServers: String) {

@Bean
fun producerFactory(): ProducerFactory<String, String> {
open fun producerFactory(): ProducerFactory<String, String> {
val configMap: MutableMap<String, Any> = HashMap()
populerCommonConfig(configMap)
configMap[ProducerConfig.CLIENT_ID_CONFIG] = "eessi-pensjon-statistikk"
Expand All @@ -35,7 +35,7 @@ class IntegrationtestConfig(
}

@Bean
fun kafkaConsumerFactory(): ConsumerFactory<String, String> {
open fun kafkaConsumerFactory(): ConsumerFactory<String, String> {
val configMap: MutableMap<String, Any> = HashMap()
populerCommonConfig(configMap)
configMap[ConsumerConfig.CLIENT_ID_CONFIG] = "eessi-pensjon-statistikk"
Expand All @@ -48,7 +48,7 @@ class IntegrationtestConfig(
}

@Bean
fun sedKafkaListenerContainerFactory(): ConcurrentKafkaListenerContainerFactory<String, String>? {
open fun sedKafkaListenerContainerFactory(): ConcurrentKafkaListenerContainerFactory<String, String>? {
return ConcurrentKafkaListenerContainerFactory<String, String>().apply {
consumerFactory = kafkaConsumerFactory()
containerProperties.ackMode = ContainerProperties.AckMode.MANUAL
Expand All @@ -57,12 +57,12 @@ class IntegrationtestConfig(
}

@Bean
fun kafkaTemplate(): KafkaTemplate<String, String> {
open fun kafkaTemplate(): KafkaTemplate<String, String> {
return KafkaTemplate(producerFactory())
}

@Bean
fun kafkaListenerContainerFactory(): ConcurrentKafkaListenerContainerFactory<String, String>? {
open fun kafkaListenerContainerFactory(): ConcurrentKafkaListenerContainerFactory<String, String>? {
return ConcurrentKafkaListenerContainerFactory<String, String>().apply {
consumerFactory = kafkaConsumerFactory()
containerProperties.ackMode = ContainerProperties.AckMode.MANUAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.springframework.test.context.ActiveProfiles
@EmbeddedKafka(
topics = [STATISTIKK_TOPIC]
)
class SedOgBucHendelserIntegrationTest : IntegrationBase() {
open class SedOgBucHendelserIntegrationTest : IntegrationBase() {

@MockkBean
lateinit var euxService: EuxService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.springframework.test.context.ContextConfiguration
@WebMvcTest(StatistikkListener::class)
@ContextConfiguration(classes = [StatistikkListenerTest.StatistikkListenerTestConfig::class, StatistikkApplicationIntegration::class])
@AutoConfigureMockMvc
internal class StatistikkListenerTest{
open class StatistikkListenerTest{

@Autowired
lateinit var hendelsesAggregeringsService: HendelsesAggregeringsService
Expand All @@ -41,13 +41,13 @@ internal class StatistikkListenerTest{
assertEquals(formatertDato, result)
}
@TestConfiguration
class StatistikkListenerTestConfig {
open class StatistikkListenerTestConfig {
@Bean
fun hendelsesAggregeringsService(): HendelsesAggregeringsService {
open fun hendelsesAggregeringsService(): HendelsesAggregeringsService {
return HendelsesAggregeringsService(mockk(), mockk())
}
@Bean
fun statistikkListener(): StatistikkListener {
open fun statistikkListener(): StatistikkListener {
return StatistikkListener(hendelsesAggregeringsService(), mockk(relaxed = true), "SPRING_PROFILES_ACTIVE")
}
}
Expand Down