Skip to content

Commit

Permalink
Updated kubernetes-client: 6.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Smirnov-Exactpro committed May 28, 2024
1 parent af1edaa commit d0ec7b3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# th2 common library (Java) (5.11.1)
# th2 common library (Java) (5.12.0)

## Usage

Expand Down Expand Up @@ -511,6 +511,10 @@ dependencies {

## Release notes

### 5.12.0-dev

+ Updated kubernetes-client: `6.12.1`

### 5.11.1-dev

+ Add `remove` and `clear` operations to `MapBuilder`
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ dependencies {
implementation 'io.prometheus:simpleclient_httpserver'
implementation 'io.prometheus:simpleclient_log4j2'

implementation("com.squareup.okio:okio:3.8.0") {
implementation("com.squareup.okio:okio:3.4.0") {
because('fix vulnerability in transitive dependency <com.squareup.okhttp3:okhttp>')
}
implementation("com.squareup.okhttp3:okhttp:4.12.0") {
implementation("com.squareup.okhttp3:okhttp:4.11.0") {
because('fix vulnerability in transitive dependency <kubernetes-client>')
}
implementation('com.squareup.okhttp3:logging-interceptor:4.12.0') {
implementation('com.squareup.okhttp3:logging-interceptor:4.11.0') {
because('fix vulnerability in transitive dependency <kubernetes-client>')
}

implementation("io.fabric8:kubernetes-client:6.10.0") {
implementation("io.fabric8:kubernetes-client:6.12.1") {
exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-yaml'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2021 Exactpro (Exactpro Systems Limited)
* Copyright 2020-2024 Exactpro (Exactpro Systems Limited)
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -20,10 +20,12 @@ import com.exactpro.th2.common.schema.strategy.route.json.RoutingStrategyModule
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.exc.MismatchedInputException
import com.fasterxml.jackson.module.kotlin.KotlinFeature
import com.fasterxml.jackson.module.kotlin.KotlinModule
import org.apache.commons.collections4.MultiValuedMap
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import kotlin.test.assertFailsWith

class TestMultiMapDeserializer {

Expand All @@ -32,23 +34,38 @@ class TestMultiMapDeserializer {
private val OBJECT_MAPPER: ObjectMapper = ObjectMapper()

init {
OBJECT_MAPPER.registerModule(KotlinModule())
OBJECT_MAPPER.registerModule(
KotlinModule.Builder()
.withReflectionCacheSize(512)
.configure(KotlinFeature.NullToEmptyCollection, false)
.configure(KotlinFeature.NullToEmptyMap, false)
.configure(KotlinFeature.NullIsSameAsDefault, false)
.configure(KotlinFeature.SingletonSupport, false)
.configure(KotlinFeature.StrictNullChecks, false)
.build()
)

OBJECT_MAPPER.registerModule(RoutingStrategyModule(OBJECT_MAPPER))
}
}

@Test
fun `test negate deserialize`() {
try {
OBJECT_MAPPER.readValue<TestBeanClass>("""{"multimap":"string"}""", TestBeanClass::class.java)
assert(false)
} catch (e: MismatchedInputException) {}
assertFailsWith(
MismatchedInputException::class,
) {
OBJECT_MAPPER.readValue("""{"multimap":"string"}""", TestBeanClass::class.java)
}.also { e ->
assertEquals("""
Unexpected token (null), expected START_ARRAY: Can not deserialize MultiValuedMap. Field is not array or object.
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 13] (through reference chain: com.exactpro.th2.common.util.TestMultiMapDeserializer${"$"}TestBeanClass["multimap"])
""".trimIndent(), e.message)
}
}

@Test
fun `test positive deserialize`() {
val bean = OBJECT_MAPPER.readValue<TestBeanClass>("""{"multimap":[{"fieldName":"test", "value":"value", "operation":"EQUAL"},{"fieldName":"test", "value":"value123", "operation":"EQUAL"}]}""", TestBeanClass::class.java)
val bean = OBJECT_MAPPER.readValue("""{"multimap":[{"fieldName":"test", "value":"value", "operation":"EQUAL"},{"fieldName":"test", "value":"value123", "operation":"EQUAL"}]}""", TestBeanClass::class.java)

val filters = bean.multimap["test"].toList()

Expand All @@ -57,6 +74,6 @@ class TestMultiMapDeserializer {
assertEquals(filters[1].expectedValue,"value123")
}

private data class TestBeanClass(@JsonDeserialize(using = MultiMapFiltersDeserializer::class) val multimap: MultiValuedMap<String, FieldFilterConfiguration>) {}
private data class TestBeanClass(@JsonDeserialize(using = MultiMapFiltersDeserializer::class) val multimap: MultiValuedMap<String, FieldFilterConfiguration>)

}

0 comments on commit d0ec7b3

Please sign in to comment.