BadgeClassActor extends BaseActor { private void createBadgeClass(Request actorMessage) { ProjectLogger.log("createBadgeClass called"); try { Response response = badgingService.createBadgeClass(actorMessage); sender().tell(response, self()); } catch (ProjectCommonException e) { ProjectLogger.log("createBadgeClass: exception = ", e); sender().tell(e, self()); } } BadgeClassActor();  BadgeClassActor(BadgingService badgingService); @Override void onReceive(Request request);  }
@Test public void testCreateBadgeClassSuccess() { PowerMockito.when(mockBadgingService.createBadgeClass(actorMessage)).thenReturn(new Response()); actorMessage.setOperation(BadgingActorOperations.CREATE_BADGE_CLASS.getValue()); subject.tell(actorMessage, probe.getRef()); Response response = probe.expectMsgClass(ACTOR_MAX_WAIT_DURATION, Response.class); Assert.assertTrue(null != response); }
@Test public void testCreateBadgeClassFailure() { PowerMockito.when(mockBadgingService.createBadgeClass(actorMessage)) .thenThrow(resourceNotFoundException); actorMessage.setOperation(BadgingActorOperations.CREATE_BADGE_CLASS.getValue()); subject.tell(actorMessage, probe.getRef()); ProjectCommonException exception = probe.expectMsgClass(ACTOR_MAX_WAIT_DURATION, ProjectCommonException.class); Assert.assertTrue(null != exception); }