### Question:
OkrBranchService { public void delete(Long id, User user) { OkrBranch okrBranch = okrBranchRepository.findByIdOrThrow(id); okrBranchRepository.delete(okrBranch); logger.info("Deleted OkrBranch with id: " + id); activityService.createActivity(user, okrBranch, Action.DELETED); } @Autowired  OkrBranchService(
      OkrBranchRepository okrBranchRepository, ActivityService activityService); OkrBranch findById(Long id); OkrBranch create(OkrBranch okrBranch, User user); OkrBranch update(long branchId, OkrBranch okrBranch, User user); void delete(Long id, User user);  }### Answer:
@Test public void delete_expectedEntityNotFoundExceptionIfThereIsNoSuchEntity() { long id = 444L; when(okrBranchRepository.findByIdOrThrow(id)).thenThrow(EntityNotFoundException.class); okrBranch.setId(id); try { okrBranchService.delete(id, mockedUser); Assert.fail(); } catch (Exception ex) { assertThat( "Should only throw EntityNotFoundException.", ex, instanceOf(EntityNotFoundException.class)); } verify(okrBranchRepository).findByIdOrThrow(id); }
@Test public void delete_expectEntityShouldBeDeleted() { okrBranchService.delete(okrBranchId, mockedUser); verify(okrBranchRepository).delete(okrBranch); }