Skip to content

Commit

Permalink
Reduced non-Stream deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
OddKristensen committed Jul 7, 2024
1 parent 16c49b6 commit a90acd7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import io.circe.testing.CodecTests
import io.circe.tests.CirceMunitSuite
import java.util.Currency
import org.scalacheck._
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

final class JavaCurrencySuite extends CirceMunitSuite {
import JavaCurrencySuite._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ class ArraySeqSuite extends CirceMunitSuite {

property("decoding an arraySeq should specialise the array type where a class tag is available") {
forAll { intArray: Array[Int] =>
val jsonArray = Json.arr(intArray.map(_.asJson): _*)
val jsonArray = Json.arr(intArray.map(_.asJson).toIndexedSeq: _*)

jsonArray.as[ArraySeq[Int]].map(_.getClass) ?= Right(classOf[ArraySeq.ofInt])
}
}

property("decoding an arraySeq should not specialise the array type where no class tag is available") {
forAll { intArray: Array[Int] =>
val jsonArray = Json.arr(intArray.map(_.asJson): _*)
val jsonArray = Json.arr(intArray.map(_.asJson).toIndexedSeq: _*)

decodeArraySeqWithoutClassTag[Int](jsonArray).map(_.getClass) ?= Right(
classOf[ArraySeq.ofRef[_]].asInstanceOf[Class[_ <: ArraySeq[Int]]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class DecoderSuite extends CirceMunitSuite with LargeNumberDecoderTestsMunit {

property("at should accumulate errors") {
forAll { (k: String, x: Boolean, xs: List[Boolean], m: Map[String, Int]) =>
val json = m.mapValues(_.asJson).toMap.updated(k, (x :: xs).asJson).asJson
val json = m.view.mapValues(_.asJson).toMap.updated(k, (x :: xs).asJson).asJson
val actual = Decoder[List[Int]].at(k).decodeAccumulating(json.hcursor).leftMap(_.size)
actual ?= Validated.invalid(xs.size + 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import java.time._
import org.scalacheck._
import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.Prop._
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

case class JavaTimeCaseClass(foo: Duration, bar: Option[LocalTime], baz: List[ZoneId])

Expand Down Expand Up @@ -95,10 +95,7 @@ class JavaTimeCodecSuite extends CirceMunitSuite {
val decodingResult = Decoder[ZoneId].decodeJson(Json.fromString(s))

assert(decodingResult.isLeft)
assert(decodingResult.swap.right.get.reason match {
case DecodingFailure.Reason.CustomReason(_) => true
case _ => false
})
assert(decodingResult.swap.exists(_.reason.isInstanceOf[DecodingFailure.Reason.CustomReason]))
}
)
}
Expand Down Expand Up @@ -281,10 +278,7 @@ class JavaTimeCodecSuite extends CirceMunitSuite {
val decodingResult = Decoder[ZoneOffset].apply(invalidJson.hcursor)

assert(decodingResult.isLeft)
assert(decodingResult.swap.right.get.reason match {
case DecodingFailure.Reason.CustomReason(_) => true
case _ => false
})
assert(decodingResult.swap.exists(_.reason.isInstanceOf[DecodingFailure.Reason.CustomReason]))
assert(decodingResult.swap.exists(_.message.contains(invalidText)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class JsonObjectSuite extends CirceMunitSuite {

property("filterKeys should be consistent with Map#filterKeys") {
forAll { (value: JsonObject, pred: String => Boolean) =>
value.filterKeys(pred).toMap ?= value.toMap.filterKeys(pred).toMap
value.filterKeys(pred).toMap ?= value.toMap.view.filterKeys(pred).toMap
}
}

Expand Down

0 comments on commit a90acd7

Please sign in to comment.