This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOG.debug("[mymofulr][{}], response [{}]", Array(1, 2).asInstanceOf[Array[Object]]) | |
// Note if you don't do the asInstanceOf[Array[Object]] it would simply print the Array.toString as the first item. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Currency { def name: String } | |
case object EUR extends Currency { val name = "EUR" } //etc. | |
case class UnknownCurrency(name: String) extends Currency | |
So now I have the advantage of... | |
trade.ccy match { | |
case EUR => | |
case UnknownCurrency(code) => | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val byteArray: Array[Byte] = Array(1,2) | |
val bos = new BufferedOutputStream(new FileOutputStream(filename)) | |
Stream.continually(bos.write(byteArray)) | |
bos.close() // You may end up with 0 bytes file if not calling close. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalatest._ | |
import akka.testkit._ | |
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
import akka.actor.ActorSystem | |
@RunWith(classOf[JUnitRunner]) | |
class MyActor$Test extends FlatSpec with TestKitBase with ShouldMatchers { | |
implicit lazy val system = ActorSystem() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Your scalatest shoudl extend | |
extends TestKit(ActorSystem("test")) | |
// Then create actor as following | |
val mockedActorRef: ActorRef = TestActorRef(new ModelsRepositoryFetcherActor(MyCaseClassParam("a"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> "[,.\\W]".r findAllIn "hi ther. how," foreach {println _} | |
. | |
, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def someBigText: Column[String] = column[String]("MY_FIELD_NAME", O.DBType("CLOB")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val arbLong: Gen[Long] = { | |
Gen.frequency((20, Arbitrary.arbDouble), (1, Long.MaxValue)).sample.get.arbitrary | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class MyCaseClass(e: SomeEnum, l: Long, d: SomeDouble) | |
def ratiosGen: Gen[MyCaseClass] = for { | |
e <- Gen.oneOf(Seq(State.ALWAYS, State.NONE, State.NEVER, null)) // one of the items. | |
l <- Arbitrary.arbitrary[Long] | |
d <- Arbitrary.arbitrary[Double] | |
} yield MyCaseClass(e, l, d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val listOfObjectsGen: Gen[List[MyCaseClass]] = | |
Gen.containerOf[List, MyCaseClass](myCaseClassGen) |
OlderNewer