ApiMethodAnnotationConfig { public void setAudiencesIfSpecified(String[] audiences) { if (!AnnotationUtil.isUnspecified(audiences)) { config.setAudiences(Arrays.asList(audiences)); } } ApiMethodAnnotationConfig(ApiMethodConfig config); ApiMethodConfig getConfig(); void setNameIfNotEmpty(String name); void setDescriptionIfNotEmpty(String description); void setPathIfNotEmpty(String path); void setHttpMethodIfNotEmpty(String httpMethod); void setAuthLevelIfSpecified(AuthLevel authLevel); void setScopesIfSpecified(String[] scopes); void setAudiencesIfSpecified(String[] audiences); void setIssuerAudiencesIfSpecified(ApiIssuerAudienceConfig issuerAudiences); void setClientIdsIfSpecified(String[] clientIds); void setAuthenticatorsIfSpecified(Class<? extends Authenticator>[] authenticators); void setPeerAuthenticatorsIfSpecified(
      Class<? extends PeerAuthenticator>[] peerAuthenticators); void setIgnoredIfSpecified(AnnotationBoolean ignored); void setApiKeyRequiredIfSpecified(AnnotationBoolean apiKeyRequired); void setMetricCosts(ApiMetricCost[] metricCosts);  }
@Test public void testSetAudiencesIfSpecified() throws Exception { String[] audiences = { "foo", "bar" }; annotationConfig.setAudiencesIfSpecified(audiences); assertEquals(Arrays.asList(audiences), config.getAudiences()); }
@Test public void testSetAudiencesIfSpecified_empty() throws Exception { String[] empty = {}; annotationConfig.setAudiencesIfSpecified(empty); assertEquals(Collections.emptyList(), config.getAudiences()); String[] audiences = {"bleh", "more bleh"}; annotationConfig.setAudiencesIfSpecified(audiences); annotationConfig.setAudiencesIfSpecified(empty); assertEquals(Collections.emptyList(), config.getAudiences()); }
@Test public void testSetAudiencesIfSpecified_unspecified() throws Exception { testDefaults(); annotationConfig.setAudiencesIfSpecified(null); testDefaults(); String[] unspecified = {Api.UNSPECIFIED_STRING_FOR_LIST}; annotationConfig.setAudiencesIfSpecified(unspecified); testDefaults(); String[] audiences = {"bleh", "more bleh"}; annotationConfig.setAudiencesIfSpecified(audiences); annotationConfig.setAudiencesIfSpecified(unspecified); assertEquals(Arrays.asList(audiences), config.getAudiences()); }