@bearrito, I am very new to Scala/Akka world, coming from Java background. 
I had trouble understanding your statement about 

Split your processing from the actor portion


This seems like a interesting advice, could you please explain what you 
mean with it?

Thanks a lot
+ Harit
On Tuesday, May 26, 2015 at 6:13:05 PM UTC-7, bearrito wrote:
>
> Split your processing from the actor portion.
>
> Use a trait or pass the processor in using DI.
>
> On Tuesday, May 26, 2015 at 6:56:16 PM UTC-4, Harit Himanshu wrote:
>>
>> 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 [email protected].
To post to this group, send email to [email protected].
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