### Question:
FeatureFlagService extends AbstractService { public ProjectFeatureFlag getProjectFeatureFlag(final Project project, final String featureFlagName) { notNull(project, "project"); notEmpty(featureFlagName, "featureFlagName"); try { final ProjectFeatureFlag flag = getProjectFeatureFlag(getProjectFeatureFlagUri(project, featureFlagName)); if (flag == null) { throw new GoodDataException("empty response from API call"); } return flag; } catch (GoodDataException | RestClientException e) { throw new GoodDataException("Unable to get project feature flag: " + featureFlagName, 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 whenNullKeyThenGetProjectFeatureFlagShouldThrow() throws Exception { service.getProjectFeatureFlag(project, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void whenNullProjectThenGetProjectFeatureFlagShouldThrow() throws Exception { service.getProjectFeatureFlag(null, FLAG_NAME); }
@Test(expectedExceptions = GoodDataException.class) public void whenEmptyResponseThenGetProjectFeatureFlagShouldThrow() throws Exception { when(restTemplate.getForObject(PROJECT_FEATURE_FLAG_URI, ProjectFeatureFlag.class)).thenReturn(null); service.getProjectFeatureFlag(project, FLAG_NAME); }
@Test(expectedExceptions = GoodDataException.class) public void whenClientErrorResponseThenGetProjectFeatureFlagShouldThrow() throws Exception { when(restTemplate.getForObject(PROJECT_FEATURE_FLAG_URI, ProjectFeatureFlag.class)) .thenThrow(new RestClientException("")); service.getProjectFeatureFlag(project, FLAG_NAME); }