I am new to entire ecosystem including `Scala`, `Akka` and `ScalaTest` 

I am working on a problem where my `Actor` gives call to external system. 

    case object LogProcessRequest
    
    class LProcessor extends Actor {
      val log = Logging(context.system, this)
    
      def receive = {
        case LogProcessRequest =>
          log.debug("starting log processing")
          LogReaderDisruptor main(Array())
      }
    }

The `LogReaderDisruptor main(Array())` is a `Java` class that does many 
other things.  

The test I have currently looks like  

    class LProcessorSpec extends UnitTestSpec("testSystem") {
    
      "A mocked log processor" should {
        "be called" in  {
          val logProcessorActor = system.actorOf(Props[LProcessor])
          logProcessorActor ! LogProcessRequest
        }
      }
    }

where `UnitTestSpec` looks like (and inspired from [here][1]) 

    import akka.actor.ActorSystem
    import akka.testkit.{ImplicitSender, TestKit}
    import org.scalatest.matchers.MustMatchers
    import org.scalatest.{BeforeAndAfterAll, WordSpecLike}
    
    abstract class UnitTestSpec(name: String)
      extends TestKit(ActorSystem(name))
      with WordSpecLike
      with MustMatchers
      with BeforeAndAfterAll
      with ImplicitSender {
    
      override def afterAll() {
        system.shutdown()
      }
    }


**Question**   

- How can I mock the call to `LogReaderDisruptor main(Array())` and verify 
that it was called?  

I am coming from `Java`, `JUnit`, `Mockito` land and something that I would 
have done here would be  

    doNothing().when(logReaderDisruptor).main(Matchers.<String>anyVararg())
    verify(logReaderDisruptor, times(1)).main(Matchers.<String>anyVararg())

I am not sure how to translate that with ScalaTest here.  

Also, This code may not be idiomatic, since I am very new and learning

  [1]: http://www.superloopy.io/articles/2013/scalatest-with-akka.html

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to