Hi Avi,

in order to switch out the actual HTTP part you’ll have to configure your Actor 
with this part, e.g. by providing a function “HttpRequest => 
Future[HttpResponse]” or a “Flow[HttpRequest, HttpResponse, _]” or similar. 
Then in your production code you plug in the HTTP client pool and in your tests 
you can simply stub it out by a function that provides canned answers.

Regards,

Roland

> 1 jun 2015 kl. 02:52 skrev Avi Levi <[email protected]>:
> 
> Thank you Konrad .
> I am not sure I got you. 
> IIUC you suggest to create an "external" service actor that will accept 
> messages and rout them to the proper external API and will send the response 
> back . if that is correct then again how can I test it ? the testkit allow me 
> to test incoming requests to my API .
> I might didn't explain myself correctly or I am missing something .
> my actor needs to call some external api . something like this :
> class MyActor extends Actor {
> def receive = {
> case GetCities(countryCode:String) => //do http request from external system 
> to get the cities 
>  }
> }  
> 
> 
> 
> 
> 
> 2015-06-01 1:00 GMT+03:00 Konrad Malawski <[email protected] 
> <mailto:[email protected]>>:
> I agree with Giovanni's hints here - your "domain actors" should talk using 
> your "domain language" (the messages).
> Of course you can always just create an HttpRequest message (see http model 
> in the docs) if you want to send that,
> however I'd recommend to test the http things more for the routing and 
> checking if the proper domain message is sent 
> as reaction to such http request (check out our routing testkit: 
> https://github.com/akka/akka/blob/release-2.3-dev/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/ScalatestRouteTestSpec.scala
>  
> <https://github.com/akka/akka/blob/release-2.3-dev/akka-http-testkit/src/test/scala/akka/http/scaladsl/testkit/ScalatestRouteTestSpec.scala>
>  ), and then test domain things with normal domain messages.
> 
> On Mon, May 25, 2015 at 9:53 AM, Giovanni Alberto Caporaletti 
> <[email protected] <mailto:[email protected]>> wrote:
> Try to separate your login between internal business actors that you can unit 
> test and a gateway sub-system to connect to external systems. 
> The gateway would translate all the connection logic from the external domain 
> to your internal domain, including errors and other possible states.  You 
> could need to handle state and/or any kind of retry logic/failure 
> compensation etc.
> 
> The external system (http) would appear as a message-driven actor to your 
> bounded context, speaking your domain language, thus being unit testable.
> The gateway subsystem will be independently integration-tested. You could 
> have a mock http server in your integration tests to verify the external 
> calls and the translation.
> 
> Cheers
> G
> 
> 
> On Sunday, 24 May 2015 10:52:10 UTC+2, Avi wrote:
> Hi ,
> I have an actor that is sending outbound http request.
> I would like top  test that actor ,is there an option to mock that call ? 
> what is the correct way for doing that ? 
> 
> Best
> Avi
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/akka-user 
> <http://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> 
> -- 
> Cheers,
> Konrad 'ktoso' Malawski
> Akka <http://akka.io/> @ Typesafe <http://typesafe.com/>
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <https://groups.google.com/group/akka-user>
> --- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Akka User List" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/akka-user/-rsD467ADC4/unsubscribe 
> <https://groups.google.com/d/topic/akka-user/-rsD467ADC4/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/akka-user 
> <http://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/akka-user 
> <http://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.



Dr. Roland Kuhn
Akka Tech Lead
Typesafe <http://typesafe.com/> – Reactive apps on the JVM.
twitter: @rolandkuhn
 <http://twitter.com/#!/rolandkuhn>

-- 
>>>>>>>>>>      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