@Test public void testBuildCharacterInformationForNonExistingCharacter() { when(characterDao.searchById(1L)).thenReturn(null); CharacterInformation characterInfo = movieInfo.buildCharacterInfoById(1L); verify(characterDao, times(1)).searchById(1L); verify(charInfoBuilder, times(0)).buildCharacterInformation(null); assertNull(characterInfo); }
@Test public void testBuildCharacterInformationForExistingCharacter() { Character testCharacter = getTestCharacter(1L, "TEST CHAR", getTestDialogue("Test dialogue...", "Under tests!")); when(characterDao.searchById(1L)).thenReturn(testCharacter); when(charInfoBuilder.buildCharacterInformation(testCharacter)) .thenReturn(new CharacterInformation()); CharacterInformation characterInfo = movieInfo.buildCharacterInfoById(1L); verify(characterDao, times(1)).searchById(1L); verify(charInfoBuilder, times(1)).buildCharacterInformation(testCharacter); assertNotNull(characterInfo); }