Skip to content

Commit 2148cea

Browse files
committed
Fix & silence warnings
1 parent 5b277ec commit 2148cea

File tree

11 files changed

+28
-13
lines changed

11 files changed

+28
-13
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinAnnotationIntrospector.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
145145
it.getter.javaMethod == this.member
146146
}
147147

148+
@Suppress("UNCHECKED_CAST")
148149
private fun AnnotatedMethod.getCorrespondingSetter(): KMutableProperty1.Setter<out Any, Any?>? {
149150
val mutableProperty = member.declaringClass.kotlin.declaredMemberProperties.find {
150151
when (it) {

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/PropertyRequirednessTests.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class TestPropertyRequiredness {
1414

1515
private data class TestParamClass(val foo: String = "bar")
1616

17+
@Suppress("UNUSED_PARAMETER")
1718
private class TestClass {
1819
fun setA(value: Int): Unit {}
1920
fun setB(value: Int = 5): Unit {}
@@ -190,4 +191,4 @@ class TestPropertyRequiredness {
190191

191192
private fun BeanDescription.isRequired(propertyName: String): Boolean =
192193
this.findProperties().find { it.name == propertyName }!!.isRequired
193-
}
194+
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github114.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class TestGithub114 {
5757
fun testCallByFunctionalityWithCompanionObjects() {
5858
val v = Nada.Companion::foo
5959
assertEquals("OK 42", v.callBy(mapOf()))
60-
val v2 = FooWithStaticCreator.Companion::createFromJson.javaMethod!!.kotlinFunction!!
60+
// val v2 = FooWithStaticCreator.Companion::createFromJson.javaMethod!!.kotlinFunction!!
6161
// println(v2.callBy(mapOf(v2.parameters.first() to FooWithStaticCreator, v2.parameters.drop(1).first() to "asdf")))
6262
}
6363

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github120.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package com.fasterxml.jackson.module.kotlin.test.github
33
import com.fasterxml.jackson.annotation.JsonCreator
44
import com.fasterxml.jackson.annotation.JsonValue
55
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
6-
import junit.framework.Assert.assertEquals
76
import org.junit.Test
7+
import kotlin.test.assertEquals
88

99
class TestGithub120 {
1010
data class Foo @JsonCreator(mode = JsonCreator.Mode.DELEGATING) constructor (
@@ -27,4 +27,4 @@ class TestGithub120 {
2727
val fromString = om.readValue(asString, Bar::class.java)
2828
assertEquals(bar, fromString)
2929
}
30-
}
30+
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github145.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
77
import com.fasterxml.jackson.module.kotlin.readValue
88
import org.junit.Test
99

10+
@Suppress("UNUSED_VARIABLE")
1011
class TestGithub145 {
1112
private val objectMapper = jacksonObjectMapper()
1213

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github149.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
77
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
88
import org.junit.Test
99

10+
@Suppress("UNUSED_VARIABLE")
1011
class TestGithub149 {
1112

1213
class Foo(val name: String, attributes: List<FooAtt>) {
@@ -83,4 +84,4 @@ class TestGithub149 {
8384
val value = mapper.readValue(s, Car::class.java)
8485
// print(value)
8586
}
86-
}
87+
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github158.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
44
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
55
import com.fasterxml.jackson.module.kotlin.readValue
66
import org.junit.Test
7+
import kotlin.test.assertEquals
78

89
class TestGithub158 {
910
enum class SampleImpl constructor(override val value: String): Sample {
@@ -21,9 +22,11 @@ class TestGithub158 {
2122
fun testEnumSerDeser() {
2223
val mapper = jacksonObjectMapper()
2324

24-
val json = mapper.writeValueAsString(SampleContainer(SampleImpl.One))
25-
println(json)
26-
val obj = mapper.readValue<SampleContainer>(json)
25+
val original = SampleContainer(SampleImpl.One)
2726

27+
val json = mapper.writeValueAsString(original)
28+
// println(json)
29+
val obj = mapper.readValue<SampleContainer>(json)
30+
assertEquals(original, obj)
2831
}
29-
}
32+
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github161.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class TestGithub161 {
1717
val json = """{"foo":17}"""
1818
val objectMapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true)
1919
try {
20-
val foo = objectMapper.readValue(json, Foo::class.java)
20+
objectMapper.readValue(json, Foo::class.java)
2121
fail("Expected an error on the missing primitive value")
2222
} catch (ex: MismatchedInputException) {
2323
// success
2424
}
2525
}
26-
}
26+
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github168.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@ import com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException
55
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
66
import com.fasterxml.jackson.module.kotlin.readValue
77
import org.junit.Test
8+
import kotlin.test.assertEquals
89

910
class TestGithub168 {
11+
@Suppress("UNUSED_PARAMETER")
1012
class TestClass(@JsonProperty(value = "foo", required = true) foo: String?, val baz: String)
1113

1214
@Test
1315
fun testIfRequiredIsReallyRequiredWhenNullused() {
1416
val obj = jacksonObjectMapper().readValue<TestClass>("""{"foo":null,"baz":"whatever"}""")
17+
assertEquals("whatever", obj.baz)
1518
}
1619

1720
@Test(expected = MissingKotlinParameterException::class)
1821
fun testIfRequiredIsReallyRequiredWhenAbsent() {
1922
val obj = jacksonObjectMapper().readValue<TestClass>("""{"baz":"whatever"}""")
23+
assertEquals("whatever", obj.baz)
2024
}
2125

2226
@Test
2327
fun testIfRequiredIsReallyRequiredWhenVauePresent() {
2428
val obj = jacksonObjectMapper().readValue<TestClass>("""{"foo":"yay!","baz":"whatever"}""")
29+
assertEquals("whatever", obj.baz)
2530
}
26-
}
31+
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/Github138.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TestGithub138 {
2727
val xml = """<sms Phone="435242423412" Id="43234324">Lorem ipsum</sms>"""
2828
val xmlMapper = XmlMapper().registerKotlinModule()
2929
expectFailure<InvalidDefinitionException>("GitHub #138 has been fixed!") {
30-
val jsms = xmlMapper.readValue<Sms>(xml)
30+
xmlMapper.readValue<Sms>(xml)
3131
}
3232
}
3333
}

0 commit comments

Comments
 (0)