@Test public void testStartRuntimeException() throws ProfileActionException { doThrow(new RuntimeException()).when(mapper).run(); mapperProfile.start(executorService); verify(mapper).run(); verify(mutableProfileStatus).setProfileState(ProfileState.FINISHED_ERRORS); }
@Test public void testStart() throws ProfileActionException { mapperProfile.start(executorService); verify(mapper).run(); verify(mutableProfileStatus).setProfileState(ProfileState.FINISHED_SUCCESSFULLY); verify(mutableProfileStatus).setStatusMessages(eq(new ArrayList<ProfileStatusMessage>())); }
@Test public void testStartProfileActionException() throws ProfileActionException { ProfileActionException profileActionException = mock(ProfileActionException.class); ProfileStatusMessage message = mock(ProfileStatusMessage.class); when(profileActionException.getProfileStatusMessage()).thenReturn(message); doThrow(profileActionException).when(mapper).run(); mapperProfile.start(executorService); verify(mapper).run(); verify(mutableProfileStatus).setProfileState(ProfileState.FINISHED_ERRORS); ArgumentCaptor<ProfileActionExceptionWrapper> captor = ArgumentCaptor.forClass(ProfileActionExceptionWrapper.class); verify(mutableProfileStatus).setOperationError(captor.capture()); assertEquals(message, captor.getValue().getMessage()); }