Skip to content

Update simple deps and formatting #272

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spaces.inImportCurlyBraces = true
indentOperator = spray
unindentTopLevelOperators = true

version=2.5.3
version=2.6.4

2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lazy val commonSettings =
source.close
version.get
},
crossScalaVersions := Seq(currentScalaVersion, "2.12.11", "2.11.12"),
crossScalaVersions := Seq(currentScalaVersion, "2.12.12", "2.11.12"),
scalafmtOnCompile := true,
scalacOptions ++= Seq(
"-unchecked",
Expand Down
2 changes: 0 additions & 2 deletions common/src/main/scala/org/mockito/MockitoAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ private[mockito] trait DoSomething {
* both method doReturn in class Mockito of type (x$1: Any, x$2: Object*)org.mockito.stubbing.Stubber
* and method doReturn in class Mockito of type (x$1: Any)org.mockito.stubbing.Stubber
* match argument types (`Type`)}}}
*
*/
def doReturn[T: ValueClassExtractor](toBeReturned: T, toBeReturnedNext: T*): Stubber =
toBeReturnedNext.foldLeft(Mockito.doAnswer(ScalaReturns(toBeReturned))) {
Expand All @@ -81,7 +80,6 @@ private[mockito] trait DoSomething {
/**
* Delegates to <code>Mockito.doThrow(type: Class[T])</code>
* It provides a nicer API as you can, for instance, do doThrow[Throwable] instead of doThrow(classOf[Throwable])
*
*/
def doThrow[T <: Throwable: ClassTag]: Stubber = Mockito.doThrow(clazz)

Expand Down
3 changes: 2 additions & 1 deletion common/src/main/scala/org/mockito/matchers/AllOf.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.mockito
package matchers

/** Combine multiple matchers using AND
/**
* Combine multiple matchers using AND
*/
case class AllOf[A] private (matchers: List[ArgumentMatcher[A]]) extends ArgumentMatcher[A] {
override def matches(a: A) = matchers.forall(_.matches(a))
Expand Down
28 changes: 10 additions & 18 deletions common/src/main/scala/org/mockito/matchers/AnyMatchers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,109 +4,101 @@ import org.mockito.{ ArgumentMatchers => JavaMatchers }

private[mockito] trait AnyMatchers {

/** List matcher that use Scala List to avoid compile errors like
/**
* List matcher that use Scala List to avoid compile errors like
* Error:(40, 60) type mismatch;
* found : List[String] (in java.util)
* required: List[?] (in scala.collection.immutable)
*
* when trying to do something like ArgumentMatchers.anyList[String]()
*
*/
def anyList[T]: List[T] = JavaMatchers.any[List[T]]()

/** Seq matcher that use Scala Seq to avoid compile errors like
/**
* Seq matcher that use Scala Seq to avoid compile errors like
* Error:(40, 60) type mismatch;
* found : List[String] (in java.util)
* required: Seq[?] (in scala.collection.immutable)
*
* when trying to do something like ArgumentMatchers.anyList[String]()
*
*/
def anySeq[T]: Seq[T] = JavaMatchers.any[Seq[T]]()

/** Iterable matcher that use Scala Iterable to avoid compile errors like
/**
* Iterable matcher that use Scala Iterable to avoid compile errors like
* Error:(40, 60) type mismatch;
* found : Iterable[String] (in java.util)
* required: Iterable[?] (in scala.collection.immutable)
*
* when trying to do something like ArgumentMatchers.anyIterable[String]()
*
*/
def anyIterable[T]: Iterable[T] = JavaMatchers.any[Iterable[T]]()

/** Set matcher that use Scala Set to avoid compile errors like
/**
* Set matcher that use Scala Set to avoid compile errors like
* Error:(40, 60) type mismatch;
* found : Set[String] (in java.util)
* required: Set[?] (in scala.collection.immutable)
*
* when trying to do something like ArgumentMatchers.anySet[String]()
*
*/
def anySet[T]: Set[T] = JavaMatchers.any[Set[T]]()

/** Map matcher that use Scala Map to avoid compile errors like
/**
* Map matcher that use Scala Map to avoid compile errors like
* Error:(40, 60) type mismatch;
* found : Map[String, String] (in java.util)
* required: Map[?] (in scala.collection.immutable)
*
* when trying to do something like ArgumentMatchers.anyMap[String, String]()
*
*/
def anyMap[K, V]: Map[K, V] = JavaMatchers.any[Map[K, V]]()

/**
* Delegates to <code>ArgumentMatchers.anyByte()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place as any[T] would do the job just fine
*
*/
def anyByte: Byte = JavaMatchers.anyByte

/**
* Delegates to <code>ArgumentMatchers.anyBoolean()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place as any[T] would do the job just fine
*
*/
def anyBoolean: Boolean = JavaMatchers.anyBoolean

/**
* Delegates to <code>ArgumentMatchers.anyChar()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place as any[T] would do the job just fine
*
*/
def anyChar: Char = JavaMatchers.anyChar

/**
* Delegates to <code>ArgumentMatchers.anyDouble()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place as any[T] would do the job just fine
*
*/
def anyDouble: Double = JavaMatchers.anyDouble

/**
* Delegates to <code>ArgumentMatchers.anyInt()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place as any[T] would do the job just fine
*
*/
def anyInt: Int = JavaMatchers.anyInt

/**
* Delegates to <code>ArgumentMatchers.anyFloat()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place as any[T] would do the job just fine
*
*/
def anyFloat: Float = JavaMatchers.anyFloat

/**
* Delegates to <code>ArgumentMatchers.anyShort()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place as any[T] would do the job just fine
*
*/
def anyShort: Short = JavaMatchers.anyShort

/**
* Delegates to <code>ArgumentMatchers.anyLong()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place as any[T] would do the job just fine
*
*/
def anyLong: Long = JavaMatchers.anyLong
}
3 changes: 0 additions & 3 deletions common/src/main/scala/org/mockito/matchers/EqMatchers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ private[mockito] trait EqMatchers {
/**
* Delegates to <code>ArgumentMatchers.same()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place
*
*/
def same[T](value: T): T = JavaMatchers.same(value)

/**
* Delegates to <code>ArgumentMatchers.isA(type: Class[T])</code>
* It provides a nicer API as you can, for instance, do isA[String] instead of isA(classOf[String])
*
*/
def isA[T: ClassTag]: T = JavaMatchers.isA(clazz)

/**
* Delegates to <code>ArgumentMatchers.refEq()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place
*
*/
def refEq[T](value: T, excludeFields: String*): T = JavaMatchers.refEq(value, excludeFields: _*)
}
2 changes: 0 additions & 2 deletions common/src/main/scala/org/mockito/matchers/NullMatchers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ private[mockito] trait NullMatchers {
* Delegates to <code>ArgumentMatchers.isNull()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place, but marked as @deprecated as you shouldn't be testing for nulls
* on Scala
*
*/
@deprecated(message = "Using nulls in Scala? you naughty, naughty developer...", since = "0.0.0")
def isNull[T]: T = JavaMatchers.isNull[T]
Expand All @@ -17,7 +16,6 @@ private[mockito] trait NullMatchers {
* Delegates to <code>ArgumentMatchers.isNotNull()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place, but marked as @deprecated as you shouldn't be testing for nulls
* on Scala
*
*/
@deprecated(message = "Using nulls in Scala? you naughty, naughty developer...", since = "0.0.0")
def isNotNull[T]: T = JavaMatchers.isNotNull[T]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class N {
*
* aMock.pepe(4.1)
* aMock.pepe(n > 4) was called
*
*/
def >[N: Numeric](n: N): N = argThat[N](new NumericMatcher(n, ">", _ > _))

Expand All @@ -30,7 +29,6 @@ class N {
*
* aMock.pepe(4)
* aMock.pepe(n >= 4) was called
*
*/
def >=[N: Numeric](n: N): N = argThat[N](new NumericMatcher(n, ">=", _ >= _))

Expand All @@ -39,7 +37,6 @@ class N {
*
* aMock.pepe(3.1)
* aMock.pepe(n < 4) was called
*
*/
def <[N: Numeric](n: N): N = argThat[N](new NumericMatcher(n, "<", _ < _))

Expand All @@ -48,7 +45,6 @@ class N {
*
* aMock.pepe(4)
* aMock.pepe(n <= 4) was called
*
*/
def <=[N: Numeric](n: N): N = argThat[N](new NumericMatcher(n, "<=", _ <= _))

Expand All @@ -58,7 +54,6 @@ class N {
*
* aMock.barDouble(4.999)
* verify(aMock).barDouble(=~(5.0 +- 0.001))
*
*/
def =~[T](spread: Spread[T]): T = ThatMatchers.argThat[T](spread.isWithin _, s"=~($spread)")
}
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/scala/org/mockito/matchers/ProductOf.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.mockito
package matchers

/** The product (2-tuple) of two matchers
/**
* The product (2-tuple) of two matchers
*/
case class ProductOf[A, B] private (ma: ArgumentMatcher[A], mb: ArgumentMatcher[B]) extends ArgumentMatcher[(A, B)] {
override def matches(ab: (A, B)) = ab match { case (a, b) => ma.matches(a) && mb.matches(b) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,24 @@ private[mockito] trait StringThatMatchers {
/**
* Delegates to <code>ArgumentMatchers.matches()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place
*
*/
def matches(regex: String): String = argThat((s: String) => s.matches(regex), s"matches($regex)")

/**
* Delegates to <code>ArgumentMatchers.startsWith()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place
*
*/
def startsWith(prefix: String): String = argThat((s: String) => s.startsWith(prefix), s"startsWith($prefix)")

/**
* Delegates to <code>ArgumentMatchers.contains()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place
*
*/
def contains(substring: String): String = argThat((s: String) => s.contains(substring), s"contains($substring)")

/**
* Delegates to <code>ArgumentMatchers.endsWith()</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place
*
*/
def endsWith(suffix: String): String = argThat((s: String) => s.endsWith(suffix), s"endsWith($suffix)")
}
10 changes: 0 additions & 10 deletions common/src/main/scala/org/mockito/matchers/ThatMatchers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ private[mockito] trait ThatMatchers {
/**
* Delegates to <code>ArgumentMatchers.argThat(matcher)</code>, it's only here so we expose all the `ArgumentMatchers`
* on a single place
*
*/
def argThat[T](matcher: ArgumentMatcher[T]): T = argThat(matcher.matches, matcher.toString)

Expand All @@ -25,63 +24,55 @@ private[mockito] trait ThatMatchers {
* Delegates the call to <code>argThat</code> but using the Scala "primitives", this
* provides avoids an unnecessary implicit conversion that would be necessary if we used
* the Java version
*
*/
def byteThat(matcher: ArgumentMatcher[Byte]): Byte = argThat(matcher)

/**
* Delegates the call to <code>argThat</code> but using the Scala "primitive", this
* provides avoids an unnecessary implicit conversion that would be necessary if we used
* the Java version
*
*/
def booleanThat(matcher: ArgumentMatcher[Boolean]): Boolean = argThat(matcher)

/**
* Delegates the call to <code>argThat</code> but using the Scala "primitive", this
* provides avoids an unnecessary implicit conversion that would be necessary if we used
* the Java version
*
*/
def charThat(matcher: ArgumentMatcher[Char]): Char = argThat(matcher)

/**
* Delegates the call to <code>argThat</code> but using the Scala "primitive", this
* provides avoids an unnecessary implicit conversion that would be necessary if we used
* the Java version
*
*/
def doubleThat(matcher: ArgumentMatcher[Double]): Double = argThat(matcher)

/**
* Delegates the call to <code>argThat</code> but using the Scala "primitive", this
* provides avoids an unnecessary implicit conversion that would be necessary if we used
* the Java version
*
*/
def intThat(matcher: ArgumentMatcher[Int]): Int = argThat(matcher)

/**
* Delegates the call to <code>argThat</code> but using the Scala "primitive", this
* provides avoids an unnecessary implicit conversion that would be necessary if we used
* the Java version
*
*/
def floatThat(matcher: ArgumentMatcher[Float]): Float = argThat(matcher)

/**
* Delegates the call to <code>argThat</code> but using the Scala "primitive", this
* provides avoids an unnecessary implicit conversion that would be necessary if we used
* the Java version
*
*/
def shortThat(matcher: ArgumentMatcher[Short]): Short = argThat(matcher)

/**
* Delegates the call to <code>argThat</code> but using the Scala "primitive", this
* provides avoids an unnecessary conversion that would be necessary used
* the Java version
*
*/
def longThat(matcher: ArgumentMatcher[Long]): Long = argThat(matcher)

Expand All @@ -90,7 +81,6 @@ private[mockito] trait ThatMatchers {
*
* foo.bar(argMatching({ case Baz(n, _) if n > 90 => })) returns "mocked!"
* foo.bar(argMatching({ case Baz(_, "pepe") => })) was called
*
*/
def argMatching[T](pf: PartialFunction[Any, Unit]) = argThat[T](pf.isDefinedAt(_), "argMatching(...)")
}
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/scala/org/mockito/matchers/Transformed.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.mockito
package matchers

/** Matcher tranformed from one type to another with a function to modify the input
/**
* Matcher tranformed from one type to another with a function to modify the input
*
* Technically this is 'contramapped' but that seemed like an unnecessarily jargony name.
*/
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/scala/org/mockito/mockito.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import scala.reflect.ClassTag

package object mockito {

/** Some forms of tagged types don't provide a ClassTag, given that sometimes we only use it to differentiate
/**
* Some forms of tagged types don't provide a ClassTag, given that sometimes we only use it to differentiate
* an InvocationOnMock from anything else, this is a safe default for those methods
*/
private[mockito] def defaultClassTag[T]: ClassTag[T] = ClassTag.AnyRef.asInstanceOf[ClassTag[T]]
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/org/mockito/ArgumentMatchersSugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.mockito.matchers._
* It also renames the "eq" matcher to "eqTo" as in Scala "eq" is a keyword used to do object identity equality
*
* @author Bruno Bonanno
*
*/
trait ArgumentMatchersSugar
extends AnyMatchers
Expand All @@ -37,6 +36,5 @@ trait ArgumentMatchersSugar
* Simple object to allow the usage of the trait without mixing it in
*
* @author Bruno Bonanno
*
*/
object ArgumentMatchersSugar extends ArgumentMatchersSugar
Loading