diff --git a/mongo/mongo-core/src/main/scala/io/sphere/mongo/format/DefaultMongoFormats.scala b/mongo/mongo-core/src/main/scala/io/sphere/mongo/format/DefaultMongoFormats.scala index a2a8918e..6aecbcb3 100644 --- a/mongo/mongo-core/src/main/scala/io/sphere/mongo/format/DefaultMongoFormats.scala +++ b/mongo/mongo-core/src/main/scala/io/sphere/mongo/format/DefaultMongoFormats.scala @@ -50,7 +50,7 @@ trait DefaultMongoFormats { implicit def optionFormat[@specialized A](implicit f: MongoFormat[A]): MongoFormat[Option[A]] = new MongoFormat[Option[A]] { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ override def toMongoValue(a: Option[A]) = a match { case Some(aa) => f.toMongoValue(aa) case None => MongoNothing @@ -78,7 +78,7 @@ trait DefaultMongoFormats { implicit def vecFormat[@specialized A](implicit f: MongoFormat[A]): MongoFormat[Vector[A]] = new MongoFormat[Vector[A]] { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ override def toMongoValue(a: Vector[A]) = { val m = new BasicBSONList() if (a.nonEmpty) m.addAll(a.map(f.toMongoValue(_).asInstanceOf[AnyRef]).asJavaCollection) @@ -103,7 +103,7 @@ trait DefaultMongoFormats { implicit def listFormat[@specialized A](implicit f: MongoFormat[A]): MongoFormat[List[A]] = new MongoFormat[List[A]] { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ override def toMongoValue(a: List[A]) = { val m = new BasicBSONList() if (a.nonEmpty) m.addAll(a.map(f.toMongoValue(_).asInstanceOf[AnyRef]).asJavaCollection) @@ -128,7 +128,7 @@ trait DefaultMongoFormats { implicit def setFormat[@specialized A](implicit f: MongoFormat[A]): MongoFormat[Set[A]] = new MongoFormat[Set[A]] { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ override def toMongoValue(a: Set[A]) = { val m = new BasicBSONList() if (a.nonEmpty) m.addAll(a.map(f.toMongoValue(_).asInstanceOf[AnyRef]).asJavaCollection) diff --git a/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/BaseMoneyMongoFormatTest.scala b/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/BaseMoneyMongoFormatTest.scala index 27ab0fd0..9638fd06 100644 --- a/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/BaseMoneyMongoFormatTest.scala +++ b/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/BaseMoneyMongoFormatTest.scala @@ -9,7 +9,7 @@ import org.bson.BSONObject import org.scalatest.wordspec.AnyWordSpec import org.scalatest.matchers.should.Matchers -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ class BaseMoneyMongoFormatTest extends AnyWordSpec with Matchers { diff --git a/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/DefaultMongoFormatsTest.scala b/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/DefaultMongoFormatsTest.scala index 15d3673b..00437f8a 100644 --- a/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/DefaultMongoFormatsTest.scala +++ b/mongo/mongo-core/src/test/scala/io/sphere/mongo/format/DefaultMongoFormatsTest.scala @@ -12,7 +12,7 @@ import org.scalatest.matchers.must.Matchers import org.scalatest.wordspec.AnyWordSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ object DefaultMongoFormatsTest { case class User(name: String) @@ -126,7 +126,7 @@ class DefaultMongoFormatsTest } "support Java Locale" in { - Locale.getAvailableLocales.filter(_.toLanguageTag != LangTag.UNDEFINED).foreach { l: Locale => + Locale.getAvailableLocales.filter(_.toLanguageTag != LangTag.UNDEFINED).foreach { l => localeFormat.fromMongoValue(localeFormat.toMongoValue(l)).toLanguageTag must be( l.toLanguageTag) } diff --git a/util/dependencies.sbt b/util/dependencies.sbt index 6417ca83..68f1ae8a 100644 --- a/util/dependencies.sbt +++ b/util/dependencies.sbt @@ -2,6 +2,6 @@ libraryDependencies ++= Seq( "com.typesafe.scala-logging" %% "scala-logging" % "3.9.4", "joda-time" % "joda-time" % "2.12.7", "org.joda" % "joda-convert" % "2.2.3", - "org.typelevel" %% "cats-core" % "2.10.0", + ("org.typelevel" % "cats-core" % "2.10.0").cross(CrossVersion.binary), "org.json4s" %% "json4s-scalap" % "4.0.7" ) diff --git a/util/src/main/scala/Money.scala b/util/src/main/scala/Money.scala index 7b627050..b3ffdac7 100644 --- a/util/src/main/scala/Money.scala +++ b/util/src/main/scala/Money.scala @@ -64,8 +64,8 @@ object BaseMoney { def requireSameCurrency(m1: BaseMoney, m2: BaseMoney): Unit = require(m1.currency eq m2.currency, s"${m1.currency} != ${m2.currency}") - def toScalaRoundingMode(mode: java.math.RoundingMode): RoundingMode = - BigDecimal.RoundingMode(mode.ordinal()) + def toScalaRoundingMode(mode: java.math.RoundingMode): RoundingMode.Value = + BigDecimal.RoundingMode(mode.ordinal) implicit def baseMoneyMonoid(implicit c: Currency, mode: RoundingMode): Monoid[BaseMoney] = new Monoid[BaseMoney] { @@ -90,7 +90,7 @@ object BaseMoney { * @param currency * The currency of the amount. */ -case class Money private (centAmount: Long, currency: Currency) +case class Money private[util] (centAmount: Long, currency: Currency) extends BaseMoney with Ordered[Money] { import Money._ @@ -263,6 +263,7 @@ object Money { } def apply(amount: BigDecimal, currency: Currency): Money = { + println("this is called") require( amount.scale == currency.getDefaultFractionDigits, "The scale of the given amount does not match the scale of the provided currency." + diff --git a/util/src/test/scala/DomainObjectsGen.scala b/util/src/test/scala/DomainObjectsGen.scala index 97536bfd..b654f020 100644 --- a/util/src/test/scala/DomainObjectsGen.scala +++ b/util/src/test/scala/DomainObjectsGen.scala @@ -4,7 +4,7 @@ import java.util.Currency import org.scalacheck.Gen -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ object DomainObjectsGen { diff --git a/util/src/test/scala/HighPrecisionMoneySpec.scala b/util/src/test/scala/HighPrecisionMoneySpec.scala index e8a539b2..68493174 100644 --- a/util/src/test/scala/HighPrecisionMoneySpec.scala +++ b/util/src/test/scala/HighPrecisionMoneySpec.scala @@ -9,12 +9,13 @@ import org.scalatest.matchers.must.Matchers import scala.collection.mutable.ArrayBuffer import scala.language.postfixOps +import scala.math.BigDecimal class HighPrecisionMoneySpec extends AnyFunSpec with Matchers with ScalaCheckDrivenPropertyChecks { import HighPrecisionMoney.ImplicitsString._ import HighPrecisionMoney.ImplicitsStringPrecise._ - implicit val defaultRoundingMode = BigDecimal.RoundingMode.HALF_EVEN + implicit val defaultRoundingMode: BigDecimal.RoundingMode.Value = BigDecimal.RoundingMode.HALF_EVEN val Euro: Currency = Currency.getInstance("EUR") diff --git a/util/src/test/scala/MoneySpec.scala b/util/src/test/scala/MoneySpec.scala index 718d6e19..7d4c1a4a 100644 --- a/util/src/test/scala/MoneySpec.scala +++ b/util/src/test/scala/MoneySpec.scala @@ -5,12 +5,13 @@ import org.scalatest.matchers.must.Matchers import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import scala.language.postfixOps +import scala.math.BigDecimal class MoneySpec extends AnyFunSpec with Matchers with ScalaCheckDrivenPropertyChecks { import Money.ImplicitsDecimal._ import Money._ - implicit val mode = BigDecimal.RoundingMode.UNNECESSARY + implicit val mode: BigDecimal.RoundingMode.Value = BigDecimal.RoundingMode.UNNECESSARY def euroCents(cents: Long): Money = EUR(0).withCentAmount(cents)