Skip to content

Commit

Permalink
Fix some warning produced by the compiler
Browse files Browse the repository at this point in the history
* assertThat(list).asList() → assertThat(list).asInstanceOf(InstanceOfAssertFactories.LIST)
* Suppressed couple of unchecked cast warnings on the jOOQ converters
* Fixed one uncheked cast to checked cast in a jOOQ converter
  • Loading branch information
Huulivoide committed Aug 19, 2024
1 parent 64d09ed commit 7a9e69a
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import org.geolatte.geom.codec.Wkb
import org.geolatte.geom.codec.Wkt
import org.locationtech.jts.io.ParseException

class GeometryConverter(private val geometryType: GeometryType) {
class GeometryConverter(
private val geometryType: GeometryType
) {
fun from(databaseObject: Any?): Geometry<C2D>? =
databaseObject?.let {
try {
Expand All @@ -25,6 +27,6 @@ class GeometryConverter(private val geometryType: GeometryType) {
companion object {
fun to(geom: Geometry<C2D>?): String? = geom?.let { Wkt.toWkt(geom) }

internal fun read(hex: String): Geometry<C2D> = Wkb.fromWkb(ByteBuffer.from(hex)) as Geometry<C2D>
internal fun read(hex: String): Geometry<C2D> = Wkb.fromWkb(ByteBuffer.from(hex)).`as`(C2D::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class LineStringConverter : Converter<Any, LineString<C2D>> {

override fun fromType() = Any::class.java

@Suppress("UNCHECKED_CAST")
override fun toType() = LineString::class.java as Class<LineString<C2D>>

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class PointConverter : Converter<Any, Point<C2D>> {

override fun fromType() = Any::class.java

@Suppress("UNCHECKED_CAST")
override fun toType() = Point::class.java as Class<Point<C2D>>

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import fi.hsl.jore4.mapmatching.test.generators.InfrastructureNodeIdGenerator.in
import fi.hsl.jore4.mapmatching.test.generators.Retry
import fi.hsl.jore4.mapmatching.util.CollectionUtils.filterOutConsecutiveDuplicates
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.InstanceOfAssertFactories
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
Expand All @@ -33,7 +34,7 @@ class NodeSequenceCombinationsCreatorTest {
val nodesToVisit = VisitSingleNode(nodeId)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSize(1)
}
}
Expand All @@ -47,7 +48,7 @@ class NodeSequenceCombinationsCreatorTest {
val nodesToVisit = VisitSingleNode(nodeId)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.isEqualTo(
listOf(
NodeIdSequence(
Expand All @@ -73,7 +74,7 @@ class NodeSequenceCombinationsCreatorTest {
val nodesToVisit = VisitNodesOfSingleLinkUnidirectionally(startNodeId, endNodeId)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSize(1)
}
}
Expand All @@ -87,7 +88,7 @@ class NodeSequenceCombinationsCreatorTest {
val nodesToVisit = VisitNodesOfSingleLinkUnidirectionally(startNodeId, endNodeId)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.isEqualTo(
listOf(
NodeIdSequence(
Expand All @@ -114,7 +115,7 @@ class NodeSequenceCombinationsCreatorTest {
val nodesToVisit = VisitNodesOfSingleLinkBidirectionally(firstNodeId, secondNodeId)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSize(2)
}
}
Expand All @@ -128,7 +129,7 @@ class NodeSequenceCombinationsCreatorTest {
val nodesToVisit = VisitNodesOfSingleLinkBidirectionally(firstNodeId, secondNodeId)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.isEqualTo(
listOf(
NodeIdSequence(
Expand Down Expand Up @@ -173,7 +174,7 @@ class NodeSequenceCombinationsCreatorTest {
)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSizeGreaterThanOrEqualTo(1)
.hasSizeLessThanOrEqualTo(4)
}
Expand Down Expand Up @@ -309,7 +310,7 @@ class NodeSequenceCombinationsCreatorTest {
)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSizeLessThanOrEqualTo(2)
}
}
Expand Down Expand Up @@ -355,7 +356,7 @@ class NodeSequenceCombinationsCreatorTest {
)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSizeLessThanOrEqualTo(2)
}
}
Expand Down Expand Up @@ -401,7 +402,7 @@ class NodeSequenceCombinationsCreatorTest {
)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSizeLessThanOrEqualTo(2)
}
}
Expand Down Expand Up @@ -467,7 +468,7 @@ class NodeSequenceCombinationsCreatorTest {
)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSizeLessThanOrEqualTo(2)
}
}
Expand Down Expand Up @@ -533,7 +534,7 @@ class NodeSequenceCombinationsCreatorTest {
)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSizeGreaterThanOrEqualTo(2)
}
}
Expand Down Expand Up @@ -603,7 +604,7 @@ class NodeSequenceCombinationsCreatorTest {
)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSizeGreaterThanOrEqualTo(2)
}
}
Expand Down Expand Up @@ -673,7 +674,7 @@ class NodeSequenceCombinationsCreatorTest {
)

assertThat(NodeSequenceCombinationsCreator.create(nodesToVisit))
.asList()
.asInstanceOf(InstanceOfAssertFactories.LIST)
.hasSize(4)
}
}
Expand Down
Loading

0 comments on commit 7a9e69a

Please sign in to comment.