### Question:
FunctionalityService { public List<FunctionalityWithChildrenDTO> deleteList(Long projectId, List<Long> ids) throws BadRequestException { if (CollectionUtils.isEmpty(ids)) { throw new BadRequestException(Messages.PARAMETER_IS_MISSING, Entities.FUNCTIONALITY, "delete_functionality_list_missing_ids_parameter"); } List<Functionality> functionalitiesToDelete = repository.findByProjectIdAndIdIn(projectId, ids); Boolean thereAreSomeUnknownIds = ids.size() > functionalitiesToDelete.size(); if (thereAreSomeUnknownIds) { throw new NotFoundException(Messages.NOT_FOUND_FUNCTIONALITY_OR_FOLDER, Entities.FUNCTIONALITY); } repository.deleteAll(functionalitiesToDelete); return findAllAsTree(projectId); }  @Transactional(readOnly = true) List<FunctionalityWithChildrenDTO> findAllAsTree(long projectId); FunctionalityDTO update(long projectId, FunctionalityDTO dtoToUpdate); FunctionalityDTO create(Long projectId, NewFunctionalityDTO newDto); void delete(Long projectId, Long id); List<FunctionalityWithChildrenDTO> deleteList(Long projectId, List<Long> ids); FunctionalityDTO move(long projectId, MoveFunctionalityDTO moveRequest); List<FunctionalityWithChildrenDTO> moveList(long projectId, MoveFunctionalitiesDTO moveRequest); List<ScenarioDTO> findScenarios(long projectId, long functionalityId); List<ExporterInfoDTO> listAvailableExporters(); ByteArrayResource generateExport(List<Long> functionalitiesIds, String exportType, Map<String, String> requiredInfos); void importJSONFunctionalities(String projectCode, String jsonFunctionalities);  }### Answer:
@Test(expected = BadRequestException.class) public void deleteList_throwBadRequestException_whenIdsNull() throws BadRequestException { Long projectId = 1L; functionalityService.deleteList(projectId, null); verify(repository, never()).deleteAll(anyIterable()); }
@Test(expected = BadRequestException.class) public void deleteList_throwBadRequestException_whenIdsEmpty() throws BadRequestException { Long projectId = 1L; functionalityService.deleteList(projectId, new ArrayList<>()); verify(repository, never()).deleteAll(anyIterable()); }
@Test(expected = NotFoundException.class) public void deleteList_throwNotFoundException_whenSomeIdsNotFound() throws BadRequestException { Long projectId = 1L; Long functionalityId1 = 11L; Long functionalityId2 = 12L; Long functionalityId3 = 13L; Functionality functionality1 = mock(Functionality.class); Functionality functionality2 = mock(Functionality.class); List<Long> functionalityIds = Arrays.asList(functionalityId1, functionalityId2, functionalityId3); when(repository.findByProjectIdAndIdIn(projectId, functionalityIds)).thenReturn( Arrays.asList(functionality1, functionality2) ); functionalityService.deleteList(projectId, functionalityIds); verify(repository, never()).deleteAll(anyIterable()); }
@Test public void deleteList_deleteFunctionalities_whenAllIdsFound() throws BadRequestException { Long projectId = 1L; Long functionalityId1 = 11L; Long functionalityId2 = 12L; Long functionalityId3 = 13L; Functionality functionality1 = mock(Functionality.class); Functionality functionality2 = mock(Functionality.class); Functionality functionality3 = mock(Functionality.class); List<Long> functionalityIds = Arrays.asList(functionalityId1, functionalityId2, functionalityId3); List<Functionality> functionalitiesToDelete = Arrays.asList(functionality1, functionality2, functionality3); when(repository.findByProjectIdAndIdIn(projectId, functionalityIds)).thenReturn(functionalitiesToDelete); functionalityService.deleteList(projectId, functionalityIds); verify(repository).deleteAll(functionalitiesToDelete); }