ApiMethodAnnotationConfig { public void setAuthLevelIfSpecified(AuthLevel authLevel) { if (authLevel != AuthLevel.UNSPECIFIED) { config.setAuthLevel(authLevel); } } 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 testSetAuthLevelIfSpecified() throws Exception { for (AuthLevel authLevel : AuthLevel.values()) { if (authLevel == AuthLevel.UNSPECIFIED) { continue; } annotationConfig.setAuthLevelIfSpecified(authLevel); assertEquals(authLevel, config.getAuthLevel()); } }
@Test public void testSetAuthLevelIfSpecified_unspecified() throws Exception { annotationConfig.setAuthLevelIfSpecified(AuthLevel.UNSPECIFIED); assertEquals(AuthLevel.NONE, config.getAuthLevel()); Mockito.when(apiClassConfig.getAuthLevel()).thenReturn(AuthLevel.REQUIRED); assertEquals(AuthLevel.REQUIRED, config.getAuthLevel()); annotationConfig.setAuthLevelIfSpecified(AuthLevel.REQUIRED); assertEquals(AuthLevel.REQUIRED, config.getAuthLevel()); annotationConfig.setAuthLevelIfSpecified(AuthLevel.UNSPECIFIED); assertEquals(AuthLevel.REQUIRED, config.getAuthLevel()); }