try
intercept[DBException] {
categoryDAO.insert(catFixture).futureValue
categoryDAO.insert(catFixture).futureValue
}
firstly, futureValue converted from future
returned from categoryDAO.insert
implicit def convertScalaFuture[T](scalaFuture: scala.concurrent.Future[T]): FutureConcept[T] =
new FutureConcept[T] {
def eitherValue: Option[Either[Throwable, T]] =
scalaFuture.value.map {
case Success(o) => Right(o)
case Failure(e) => Left(e)
}
then, in futureValue
case Some(Left(e)) =>
throw new TestFailedException(
sde => Some {
if (e.getMessage == null)
Resources("futureReturnedAnException", e.getClass.getName)
else
Resources("futureReturnedAnExceptionWithMessage", e.getClass.getName, e.getMessage)
},
Some(e),
getStackDepthFun("Futures.scala", methodName, adjustment)
)
always throw TestFailedException & TestFailedException's fields are not awailable.