Waiter extends AbstractLoggingActor { public static Props props() { return Props.create(Waiter.class, Waiter::new); } Waiter(); @Override Receive createReceive(); static Props props();  }
@Test public void sendingServeCoffeeShouldResultInPrepareCoffeeToBarista() { new JavaTestKit(system) {{ ActorRef barista = getRef(); TestProbe guest = new TestProbe(system); ActorRef waiter = system.actorOf(Waiter.props(barista)); waiter.tell(new Waiter.ServeCoffee(new Coffee.Akkaccino()), guest.ref()); expectMsgEquals(new Barista.PrepareCoffee(new Coffee.Akkaccino(), guest.ref())); }}; }
@Test public void sendingServeCoffeeShouldResultInCoffeeServedResponse() { new JavaTestKit(system) {{ ActorRef waiter = system.actorOf(Waiter.props()); waiter.tell(new Waiter.ServeCoffee(new Coffee.Akkaccino()), getRef()); expectMsgEquals(new Waiter.CoffeeServed(new Coffee.Akkaccino())); }}; }