Are there any Matchers available for the Faktor-IPS MessageList? - faktor-ips

I'm using hamcrest in JUnit-Tests. For the Java collections classes there are Matchers like hasSize available. Are there any Matchers available for the Faktor-IPS org.faktorips.runtime.MessageList?

There are specific matchers for org.faktorips.runtime.MessageList in de.faktorzehn.commons.ips.test.matcher.IpsMatchers available.
Unfortunately this is not part of Faktor-IPS.

With the upcoming release 21.12 (RC3 Release Notes), a new package faktorips-testsupport is released on Maven central, which includes Matchers for Messages, MessageLists and ValueSets.

Related

Cross-building Scala libraries

I would like to cross-build some of my Bazel targets to Scala 2.12 and 2.13. As a further point of complexity, I need to be able to express cross-target dependencies (eg. some 2.13 target may have a Bazel dependency on a 2.12 target).
Note: this isn't a regular library dependency (eg. with the dependency 2.12-built JAR showing up on the class path when compiling the 2.13 JAR), as that would almost surely result in issues due to having two incompatible versions of the Scala standard library on the class path. Rather, this is just a case where I need the dependency JAR built so I can use it in some integration tests in the 2.13 target.
What I've found online so far...
This issue from rules_scala seems it doesn't support baking the Scala version into the target and instead you have to pick the Scala version globally.
This Databricks post has a cross-building section that is exactly what I think I would like (eg. one target generated per library per supported Scala version), but the snippets in that post don't seem to be backed by any runnable Bazel code.
This later post by Databricks also hints at a cross_scala_lib rule, but also doesn't have any accompanying code.

value should is not a member of String - Scala2.10

I want to cross compile my project across different Scala versions (2.10, 2.11, 2.12). I get this error message while compiling specs for 2.10 only. 2.11 and 2.12 work fine:
value should is not a member of String
Spec class looks as follows:
class ClassNameSpec extends WordSpec with Matchers {
// ...
}
I have also tried changing WordSpec to FlatSpec and still getting same error.
Using gradle - build.gradle has following related dependencies:
classpath 'gradle.plugin.com.github.maiflai:gradle-scalatest:0.19'
compile "org.scala-lang:scala-library:${scalaVersion}"
compile "org.scalactic:scalactic${scalaVersionSuffix}:3.0.5"
testRuntime 'org.pegdown:pegdown:1.4.2'
How can I make WordSpec or FlatSpec with Matchers work for Scala2.10? If not, what's the best work around?

nimbus-jose-jwt Plugin Type Not Found Error

I am trying to compile code sample from this book (Play Framework Cookbook 2nd Edition) for JWT with nimbus-jose-jwt.
However it said Plugin trait type not found during compilation. I checked API documentation, Plugin is available at play.api package.
import play.api.{Logger, Play, Application, Plugin}
class JWTPlugin #Inject() (app: Application) extends Plugin {...}
I tried DI version with and without
routesGenerator := InjectedRoutesGenerator at build.sbt with same error.
nimbus-jose-jwt version: 3.8.2. Tried with latest 4.22, with same error.
scala: 2.11.8
play: 2.5.4
Appreciate any pointer. Thanks.
play.api.Plugin has been removed in Play 2.5.x. You can turn the plugin into a Module instead as described here: https://www.playframework.com/documentation/2.5.x/PluginsToModules
But the easiest solution is to turn the JWTPlugin class into a plain Scala object (e.g. JWTUtil), remove the onStart and onStop methods, remove the "private val jwt" declarations/assigments from all files in the example and call the sign() and verify() methods on the JWTUtil object instead.
Maybe you need some more minor modifications that I have forgotten, but anyway, the example works for me when the JWT implementation doesn't inherit from play.api.Plugin.

Scalatest and scalamock - dependency trouble involving SuiteMixin

I'm trying to setup my project to use scalatest and scalamock.
I'm using scala version 2.10.0.
However, I cant seem to get the dependencies right.
I've started with this code:
class ControllerTest extends org.scalatest.FunSuite
with org.scalamock.scalatest.MockFactory {}
I've tried two combinations of versions:
1)
org.scalatest : scalatest_2.10 : 1.9.1
org.scalamock: scalamock-scalatest-support_2.10 : 3.0.1
This is what I get:
scala: bad symbolic reference.
A signature in MockFactory.class refers to type SuiteMixin in package org.scalatest which is not available.
It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling MockFactory.class.
Note: in the scalamock documentation, the artifact id is specified without the trailing _2.10, but maven couldn't find any artifact named like this. Also, I couldn't find on their site what scalatest version should be used with scalamock.
2)
org.scalatest : scalatest_2.10 : 1.9.1
org.scalamock: scalamock-scalatest-support_2.10.0-RC5: 3.0-M8
The compiler says:
scala: overriding method nestedSuites in trait SuiteMixin of type => scala.collection.immutable.IndexedSeq[org.scalatest.Suite];
method nestedSuites in trait Suite of type => List[org.scalatest.Suite] has incompatible type
class ControllerTest extends FunSuite with MockFactory {
and
scala: class ControllerTest needs to be abstract, since:
it has 5 unimplemented members.
/** As seen from class ControllerTest, the missing signatures are as follows.
* For convenience, these are usable as stub implementations.
*/
def rerunner: Option[String] = ???
def run(testName: Option[String],args: org.scalatest.Args): org.scalatest.Status = ???
protected def runNestedSuites(args: org.scalatest.Args): org.scalatest.Status = ???
protected def runTest(testName: String,args: org.scalatest.Args): org.scalatest.Status = ???
protected def runTests(testName: Option[String],args: org.scalatest.Args): org.scalatest.Status = ???
So, what's up with this SuiteMixin trait?
If I use scalatest-support_2.10.0-RC5:3.0-M8, it appears to exist in scalatest lib.
If I use scalatest-support_2.10:3.0.1, it seems to have gone from said scalatest lib.
What kind of sorcery is this? And, more importantly, what version combination should I use to make it work?
Thanks!
If you have this dependency
"org.scalamock" %% "scalamock-scalatest-support" % "3.0.1" % "test"
It will automatically download the correct version of scalatest. In this case it's
org.scalatest#scalatest_2.10;2.0.M5b!scalatest_2.10.jar
In most cases where one library depends upon another you just add only that one library as dependency. Sbt-like tools will get the other dependencies.
EECOLOR's answer is correct. To elaborate, the cause of the problem was that the ScalaMock version you chose was compiled against a later version of ScalaTest (2.0.M5b) than the one you were explicitly trying to use (1.9.1).

Relation between Akka and scala.actors in 2.10

The Scala 2.10 release notes says this: "Akka Actors now part of the distribution. The original Scala actors are now deprecated."
The latest Akka library ("Akka 2.1.0 for Scala 2.10") mentions the following dependency:
com.typesafe.akka:akka-actor_2.10:2.1.0
and the following examples:
import akka.actor.Actor
class MyActor extends Actor {..}
val system = ActorSystem("MySystem")
My project includes these libraries:
org.scala-lang:scala-library:2.10.0
org.scala-lang:scala-actors:2.10.0
In my classpath, I have no package called "akka". I do see instead scala.actors, but it doesn't seem deprecated.
So, in which way are Akka Actors "part of the distribution"?
If this is, indeed, the case, then am I still supposed to add the "akka-actor_2.10" library as a dependency? If so, do I use akka.Actor or the non-deprecated scala.actors.Actor ?
In scala 2.9.2 scala actors was part of scala-library.jar.
If you download a scala-2.10.0 distribution it there are no actors in scala-library and both akka-actors.jar and scala-actors.jar are supplied.
The latter is present for backwards compatibility and will be removed in a future major release.
akka-actors is the replacement and what you should use for any new development (and look to move anything using scala-actors across when possible).
If you have no current code in your project using actors you should probably reconfigure your project's dependencies to remove org.scala-lang:scala-actors:2.10.0 and instead depend on com.typesafe.akka:akka-actors_2.10:2.1.0 if you want to use actors.
I am not sure why there's no deprecation annotation on the classes in scala-actors in 2.10.0 but I believe it's to be added in 2.10.1.
You can find more info on the migration guide.