### Question:
FeatureFlagService extends AbstractService { public ProjectFeatureFlag updateProjectFeatureFlag(final ProjectFeatureFlag flag) { notNull(flag, "flag"); notEmpty(flag.getUri(), "flag.uri"); try { restTemplate.put(flag.getUri(), flag); return getProjectFeatureFlag(flag.getUri()); } catch (GoodDataException | RestClientException e) { throw new GoodDataException("Unable to update project feature flag: " + flag, e); } } FeatureFlagService(final RestTemplate restTemplate, final GoodDataSettings settings); FeatureFlags listFeatureFlags(final Project project); ProjectFeatureFlags listProjectFeatureFlags(final Project project); ProjectFeatureFlag getProjectFeatureFlag(final Project project, final String featureFlagName); ProjectFeatureFlag createProjectFeatureFlag(final Project project, final ProjectFeatureFlag flag); ProjectFeatureFlag updateProjectFeatureFlag(final ProjectFeatureFlag flag); void deleteProjectFeatureFlag(final ProjectFeatureFlag flag); static final UriTemplate PROJECT_FEATURE_FLAG_TEMPLATE; static final UriTemplate PROJECT_FEATURE_FLAGS_TEMPLATE; static final UriTemplate AGGREGATED_FEATURE_FLAGS_TEMPLATE; }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void whenNullFlagThenUpdateProjectFeatureFlagShouldThrow() throws Exception { service.updateProjectFeatureFlag(null); }
@Test(expectedExceptions = GoodDataException.class) public void whenEmptyResponseThenUpdateProjectFeatureFlagShouldThrow() throws Exception { when(projectFeatureFlag.getUri()).thenReturn(PROJECT_FEATURE_FLAG_URI); when(restTemplate.getForObject(PROJECT_FEATURE_FLAG_URI, ProjectFeatureFlag.class)).thenReturn(null); service.updateProjectFeatureFlag(projectFeatureFlag); }
@Test(expectedExceptions = GoodDataException.class) public void whenClientErrorResponseThenUpdateProjectFeatureFlagShouldThrow() throws Exception { when(projectFeatureFlag.getUri()).thenReturn(PROJECT_FEATURE_FLAG_URI); when(restTemplate.getForObject(PROJECT_FEATURE_FLAG_URI, ProjectFeatureFlag.class)) .thenThrow(new RestClientException("")); service.updateProjectFeatureFlag(projectFeatureFlag); }