### Question:
ConfigurationService { public void deleteConfigurationById(Long configurationId, User user) { Configuration configuration = configurationRepository.findByIdOrThrow(configurationId); logger.info( "Deleted configuration " + configuration.getName() + " (id: " + configuration.getId() + ")"); activityService.createActivity(user, configuration, Action.DELETED); configurationRepository.delete(configuration); }  Collection<Configuration> getAllConfigurations(); Configuration getConfigurationById(Long configurationId); Configuration getConfigurationByName(String name); Configuration createConfiguration(Configuration configuration, User user); Configuration updateConfigurationById(Configuration configuration, User user); void deleteConfigurationById(Long configurationId, User user);  }### Answer:
@Test(expected = EntityNotFoundException.class) public void deleteConfigurationById_expectEntityNotFoundException() { when(configurationRepository.findByIdOrThrow(42L)).thenThrow(EntityNotFoundException.class); configurationService.deleteConfigurationById(42L, mockedUser); }
@Test public void deleteConfigurationById_shouldDeleteEntity() { Configuration dbConfiguration = new Configuration(); dbConfiguration.setId(42L); dbConfiguration.setName("name"); dbConfiguration.setValue("3"); when(configurationRepository.findByIdOrThrow(dbConfiguration.getId())) .thenReturn(dbConfiguration); configurationService.deleteConfigurationById(dbConfiguration.getId(), mockedUser); verify(configurationRepository, times(1)).delete(dbConfiguration); }