@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()); }
@Test public void testGetName() { String name = "name"; when(streamingProfile.getName()).thenReturn(name); assertEquals(name, mapperProfile.getName()); }
@Test public void testGetId() { String id = "id"; when(streamingProfile.getId()).thenReturn(id); assertEquals(id, mapperProfile.getId()); }
@Test public void testIsRunning() { when(mapper.isRunning()).thenReturn(false).thenReturn(true); assertFalse(mapperProfile.isRunning()); assertTrue(mapperProfile.isRunning()); }
@Test public void testStop() { mapperProfile.stop(); verify(streamingProfile).stop(); verify(mapper).stop(); }