### Question:
ConfigurationService { public Configuration getConfigurationById(Long configurationId) { return configurationRepository.findByIdOrThrow(configurationId); }  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 getConfigurationById_expectException() { when(configurationRepository.findByIdOrThrow(42L)).thenThrow(EntityNotFoundException.class); Configuration configuration = configurationService.getConfigurationById(42L); }
@Test public void getConfigurationById_expectConfiguration() { Configuration dbConfiguration = new Configuration(); dbConfiguration.setId(42L); dbConfiguration.setName("name"); dbConfiguration.setValue("3"); when(configurationRepository.findByIdOrThrow(42L)).thenReturn(dbConfiguration); Configuration configuration = configurationService.getConfigurationById(42L); Assert.assertEquals(dbConfiguration.getId(), configuration.getId()); Assert.assertEquals(dbConfiguration.getName(), configuration.getName()); Assert.assertEquals(dbConfiguration.getValue(), configuration.getValue()); }