Java Code Examples for com.google.api.server.spi.config.AnnotationBoolean#TRUE

The following examples show how to use com.google.api.server.spi.config.AnnotationBoolean#TRUE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiConfigValidatorTest.java    From endpoints-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidateMethods_ignoredMethod() throws Exception {
  final class Bean {

  }
  @Api
  final class Endpoint {
    @ApiMethod(ignored = AnnotationBoolean.TRUE)
    public void thisShouldBeIgnored(Bean resource1, Bean resource2) {
    }
  }
  ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Endpoint.class);
  // If this passes validation, then no error will be thrown. Otherwise, the validator will
  // complain that the method has two resources.
  validator.validate(config);
}
 
Example 2
Source File: JsonConfigWriterTest.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that ignored methods aren't written to config.
 */
@Test
public void ignoredMethod() throws Exception {
  final class Endpoint {
    @ApiMethod(ignored = AnnotationBoolean.TRUE)
    public void thisShouldBeIgnored() {
    }
  }

  new ApiConfigAnnotationReader().loadEndpointMethods(
      serviceContext, Endpoint.class, apiConfig.getApiClassConfig().getMethods());
  for (String config : writer.writeConfig(Collections.singleton(apiConfig)).values()) {
    assertThat(config).doesNotContain("thisShouldBeIgnored");
  }
}
 
Example 3
Source File: ApiConfigAnnotationReaderTest.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testLevelOverridingWithClassOverrides() throws Exception {
  @ApiClass(
      scopes = {"s0c", "s1c"},
      audiences = {"a0c", "a1c"},
      clientIds = {"c0c", "c1c"},
      resource = "resource2",
      useDatastoreForAdditionalConfig = AnnotationBoolean.TRUE
  )
  final class Test extends SimpleLevelOverridingInheritedApi {
  }

  ApiConfig config = createConfig(Test.class);
  annotationReader.loadEndpointClass(serviceContext, Test.class, config);
  assertEquals("resource2", config.getApiClassConfig().getResource());
  assertTrue(config.getApiClassConfig().getUseDatastore());

  annotationReader.loadEndpointMethods(serviceContext, Test.class,
      config.getApiClassConfig().getMethods());

  ApiMethodConfig noOverrides =
      config.getApiClassConfig().getMethods().get(methodToEndpointMethod(
          SimpleLevelOverridingApi.class.getMethod("noOverrides")));
  assertEquals(toScopeExpression("s0c", "s1c"), noOverrides.getScopeExpression());
  assertEquals(Lists.newArrayList("a0c", "a1c"), noOverrides.getAudiences());
  assertEquals(Lists.newArrayList("c0c", "c1c"), noOverrides.getClientIds());

  ApiMethodConfig overrides =
      config.getApiClassConfig().getMethods().get(methodToEndpointMethod(
          SimpleLevelOverridingApi.class.getMethod("overrides")));
  assertEquals(toScopeExpression("s0b", "s1b"), overrides.getScopeExpression());
  assertEquals(Lists.newArrayList("a0b", "a1b"), overrides.getAudiences());
  assertEquals(Lists.newArrayList("c0b", "c1b"), overrides.getClientIds());
}
 
Example 4
Source File: ApiAnnotationConfig.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
public void setIsAbstractIfSpecified(AnnotationBoolean isAbstract) {
  if (isAbstract == AnnotationBoolean.TRUE) {
    config.setIsAbstract(true);
  } else if (isAbstract == AnnotationBoolean.FALSE) {
    config.setIsAbstract(false);
  }
}
 
Example 5
Source File: ApiAnnotationConfig.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
public void setIsDefaultVersionIfSpecified(AnnotationBoolean defaultVersion) {
  if (defaultVersion == AnnotationBoolean.TRUE) {
    config.setIsDefaultVersion(true);
  } else if (defaultVersion == AnnotationBoolean.FALSE) {
    config.setIsDefaultVersion(false);
  }
}
 
Example 6
Source File: ApiAnnotationConfig.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
public void setIsDiscoverableIfSpecified(AnnotationBoolean discoverable) {
  if (discoverable == AnnotationBoolean.TRUE) {
    config.setIsDiscoverable(true);
  } else if (discoverable == AnnotationBoolean.FALSE) {
    config.setIsDiscoverable(false);
  }
}
 
Example 7
Source File: ConferenceQueryForm.java    From ud859 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns an Objectify Query object for the specified filters.
 *
 * @return an Objectify Query.
 */
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public Query<Conference> getQuery() {
    // First check the feasibility of inequality filters.
    checkFilters();
    Query<Conference> query = ofy().load().type(Conference.class);
    if (inequalityFilter == null) {
        // Order by name.
        query = query.order("name");
    } else {
        // If we have any inequality filters, order by the field first.
        query = query.order(inequalityFilter.field.getFieldName());
        query = query.order("name");
    }
    for (Filter filter : this.filters) {
        // Applies filters in order.
        if (filter.field.fieldType == FieldType.STRING) {
            query = query.filter(String.format("%s %s", filter.field.getFieldName(),
                    filter.operator.getQueryOperator()), filter.value);
        } else if (filter.field.fieldType == FieldType.INTEGER) {
            query = query.filter(String.format("%s %s", filter.field.getFieldName(),
                    filter.operator.getQueryOperator()), Integer.parseInt(filter.value));
        }
    }
    LOG.info(query.toString());
    return query;
}
 
Example 8
Source File: ConferenceQueryForm.java    From ud859 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns an Objectify Query object for the specified filters.
 *
 * @return an Objectify Query.
 */
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public Query<Conference> getQuery() {
    // First check the feasibility of inequality filters.
    checkFilters();
    Query<Conference> query = ofy().load().type(Conference.class);
    if (inequalityFilter == null) {
        // Order by name.
        query = query.order("name");
    } else {
        // If we have any inequality filters, order by the field first.
        query = query.order(inequalityFilter.field.getFieldName());
        query = query.order("name");
    }
    for (Filter filter : this.filters) {
        // Applies filters in order.
        if (filter.field.fieldType == FieldType.STRING) {
            query = query.filter(String.format("%s %s", filter.field.getFieldName(),
                    filter.operator.getQueryOperator()), filter.value);
        } else if (filter.field.fieldType == FieldType.INTEGER) {
            query = query.filter(String.format("%s %s", filter.field.getFieldName(),
                    filter.operator.getQueryOperator()), Integer.parseInt(filter.value));
        }
    }
    LOG.info(query.toString());
    return query;
}
 
Example 9
Source File: ApiClassAnnotationConfig.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
public void setUseDatastoreIfSpecified(AnnotationBoolean useDatastore) {
  if (useDatastore == AnnotationBoolean.TRUE) {
    config.setUseDatastore(true);
  } else if (useDatastore == AnnotationBoolean.FALSE) {
    config.setUseDatastore(false);
  }
}
 
Example 10
Source File: AnnotationApiConfigGeneratorTest.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testAbstract() throws Exception {
  @Api(isAbstract = AnnotationBoolean.TRUE)
  class Test {}

  String apiConfigSource = g.generateConfig(Test.class).get("myapi-v1.api");
  ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
  assertTrue(root.get("abstract").asBoolean());
}
 
Example 11
Source File: ApiMethodAnnotationConfig.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
public void setIgnoredIfSpecified(AnnotationBoolean ignored) {
  if (ignored == AnnotationBoolean.TRUE) {
    config.setIgnored(true);
  } else if (ignored == AnnotationBoolean.FALSE) {
    config.setIgnored(false);
  }
}
 
Example 12
Source File: Conference.java    From ud859 with GNU General Public License v3.0 4 votes vote down vote up
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public String getOrganizerUserId() {
    return organizerUserId;
}
 
Example 13
Source File: ApiAnnotationIntrospectorTest.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@Override
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public String getFoo() {
  return foo;
}
 
Example 14
Source File: Conference.java    From ud859 with GNU General Public License v3.0 4 votes vote down vote up
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public String getOrganizerUserId() {
    return organizerUserId;
}
 
Example 15
Source File: Foo.java    From appengine-tck with Apache License 2.0 4 votes vote down vote up
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public int getY() {
    return y;
}
 
Example 16
Source File: Conference.java    From ud859 with GNU General Public License v3.0 4 votes vote down vote up
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public String getOrganizerUserId() {
    return organizerUserId;
}
 
Example 17
Source File: ApiAnnotationIntrospector.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
private ApiResourceProperty findAnnotation(Annotated a) {
  ApiResourceProperty annotation = a.getAnnotation(ApiResourceProperty.class);
  return annotation != null && annotation.ignored() != AnnotationBoolean.TRUE ? annotation : null;
}
 
Example 18
Source File: ApiAnnotationIntrospector.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasIgnoreMarker(AnnotatedMember member) {
  ApiResourceProperty apiProperty = member.getAnnotation(ApiResourceProperty.class);
  return apiProperty != null && apiProperty.ignored() == AnnotationBoolean.TRUE;
}
 
Example 19
Source File: Echo.java    From java-docs-samples with Apache License 2.0 2 votes vote down vote up
/**
 * Echoes the received message back. If n is a non-negative integer, the message is copied that
 * many times in the returned message.
 *
 * <p>Note that name is specified and will override the default name of "{class name}.{method
 * name}". For example, the default is "echo.echo".
 *
 * <p>Note that httpMethod is not specified. This will default to a reasonable HTTP method
 * depending on the API method name. In this case, the HTTP method will default to POST.
 */
// [START echo_api_key]
@ApiMethod(name = "echo_api_key", path = "echo_api_key", apiKeyRequired = AnnotationBoolean.TRUE)
public Message echoApiKey(Message message, @Named("n") @Nullable Integer n) {
  return doEcho(message, n);
}
 
Example 20
Source File: Echo.java    From java-docs-samples with Apache License 2.0 2 votes vote down vote up
/**
 * Echoes the received message back. If n is a non-negative integer, the message is copied that
 * many times in the returned message.
 *
 * Note that name is specified and will override the default name of "{class name}.{method
 * name}". For example, the default is "echo.echo".
 *
 * Note that httpMethod is not specified. This will default to a reasonable HTTP method
 * depending on the API method name. In this case, the HTTP method will default to POST.
 */
@ApiMethod(name = "echo_api_key", path = "echo_api_key", apiKeyRequired = AnnotationBoolean.TRUE)
public Message echoApiKey(Message message, @Named("n") @Nullable Integer n) {
  return doEcho(message, n);
}