### Question:
FlagService { public void removeFlag(Long id) throws FlagNotFoundException { getFlag(id); flagRepository.delete(id); } @Autowired  FlagService(FlagRepository flagRepository); List<Flag> getFlags(); Flag getFlag(Long id); Flag addFlag(Flag flag); void removeFlag(Long id); void updateFlag(Flag flag);  }### Answer:
@Test public void canDeleteFlag() throws FlagNotFoundException { final Long id = randomLong(); when(repository.findOne(id)).thenReturn(new Flag(id, randomString(), 10, false)); flagService.removeFlag(id); verify(repository).delete(id); }
@Test public void cannotDeleteFlagThatDoesNotExist() { final Long id = randomLong(); when(repository.findOne(id)).thenReturn(null); expectException(() -> flagService.removeFlag(id), FlagNotFoundException.class, id.toString(), "successfully deleted"); }