### Question:
SeverityService { public List<SeverityDTO> getSeveritiesWithAll(long projectId) { final List<Severity> severities = repository.findAllByProjectIdOrderByPosition(projectId); severities.add(Severity.ALL); return mapper.toDto(severities); }  List<SeverityDTO> getSeveritiesWithAll(long projectId); String getDefaultSeverityCode(List<SeverityDTO> severities); SeverityDTO create(long projectId, SeverityDTO dtoToCreate); UpsertResultDTO<SeverityDTO> createOrUpdate(long projectId, SeverityDTO dtoToCreateOrUpdate); @Transactional(readOnly = true) List<SeverityDTO> findAll(long projectId); void delete(long projectId, String code);  }### Answer:
@Test public void getSeveritiesWithAll_ShouldCallRepositoryFindAllByOrderByPosition_WhenCalled() { long aProjectId = 42; cut.getSeveritiesWithAll(aProjectId); verify(severityRepository, only()).findAllByProjectIdOrderByPosition(aProjectId); }
@Test public void getSeveritiesWithAll_ShouldAddTheAllSpecialSeverity_WhenCalled() { long aProjectId = 42; List<Severity> severities = new ArrayList<>(); severities.add(new Severity()); when(severityRepository.findAllByProjectIdOrderByPosition(aProjectId)).thenReturn(severities); cut.getSeveritiesWithAll(aProjectId); assertThat(severities.get(1)).isSameAs(Severity.ALL); }
@Test public void getSeveritiesWithAll_ShouldCallMapperWithResultOfRepositoryFindAllByOrderByPosition_WhenCalled() { long aProjectId = 42; List<Severity> severities = new ArrayList<>(); when(severityRepository.findAllByProjectIdOrderByPosition(aProjectId)).thenReturn(severities); cut.getSeveritiesWithAll(aProjectId); verify(severityMapper, only()).toDto(severities); }
@Test public void getSeveritiesWithAll_ShouldReturnMapperResult_WhenCalled() { long aProjectId = 42; List<SeverityDTO> severityDTOs = Collections.singletonList(new SeverityDTO()); when(severityMapper.toDto(anyCollection())).thenReturn(severityDTOs); assertThat(cut.getSeveritiesWithAll(aProjectId)).isSameAs(severityDTOs); }