### Question:
CategoryServiceImpl implements CategoryService { @Override public Long deleteById(Long id) { log.info(LogMessage.IN_DELETE_BY_ID, id); Category category = findById(id); if (!category.getPlaces().isEmpty()) { throw new BadRequestException(ErrorMessage.NOT_SAVE_DELETION); } categoryRepo.delete(category); return id; }  @Override Category save(CategoryDto dto); @Override Category save(Category category); @Override List<Category> findAll(); @Override Category findById(Long id); @Override Category update(Long id, Category category); @Override Long deleteById(Long id); @Override Category findByName(String name); @Override List<CategoryDto> findAllCategoryDto();  }### Answer:
@Test public void deleteByIdTest() { when(categoryRepo.findById(anyLong())).thenReturn(Optional.of(new Category())); assertEquals(new Long(1), categoryService.deleteById(1L)); }
@Test(expected = NotFoundException.class) public void deleteByIdGivenIdNullThenThrowException() { categoryService.deleteById(null); }