use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testBasicEndpoint.
@Test
public void testBasicEndpoint() throws Exception {
ApiConfig config = createConfig(Endpoint0.class);
annotationReader.loadEndpointClass(serviceContext, Endpoint0.class, config);
assertEquals("api", config.getName());
assertEquals(0, config.getApiClassConfig().getMethods().size());
annotationReader.loadEndpointMethods(serviceContext, Endpoint0.class, config.getApiClassConfig().getMethods());
assertEquals(1, config.getApiClassConfig().getMethods().size());
ApiMethodConfig method = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Endpoint0.class.getMethod("getFoo", String.class)));
validateMethod(method, "Endpoint0.getFoo", "foo/{id}", ApiMethod.HttpMethod.GET, DEFAULT_SCOPES, DEFAULT_AUDIENCES, DEFAULT_CLIENTIDS, null, null);
}
use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testSimpleOverloadEndpoint.
@Test
public void testSimpleOverloadEndpoint() throws Exception {
ApiConfig config = createConfig(SimpleOverloadEndpoint.class);
annotationReader.loadEndpointMethods(serviceContext, SimpleOverloadEndpoint.class, config.getApiClassConfig().getMethods());
ApiMethodConfig method1 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(SimpleOverloadEndpoint.class.getMethod("foo", Integer.class)));
assertEquals("api.foos.fn", method1.getName());
ApiMethodConfig method2 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(SimpleOverloadEndpoint.class.getSuperclass().getMethod("foo", String.class)));
assertEquals("api.foos.base", method2.getName());
}
use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testCollectionCovarianceEndpoint.
@Test
public void testCollectionCovarianceEndpoint() throws Exception {
ApiConfig config = createConfig(CollectionCovarianceEndpoint.class);
annotationReader.loadEndpointMethods(serviceContext, CollectionCovarianceEndpoint.class, config.getApiClassConfig().getMethods());
ApiMethodConfig method1 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(CollectionCovarianceEndpoint.class.getMethod("foo", List.class)));
assertEquals("api.foos.fn", method1.getName());
ApiMethodConfig method2 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(CollectionCovarianceEndpoint.class.getSuperclass().getMethod("foo", Collection.class)));
assertEquals("api.foos.base", method2.getName());
}
use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testEndpointWithInheritance.
@Test
public void testEndpointWithInheritance() throws Exception {
ApiConfig config = createConfig(Endpoint3.class);
annotationReader.loadEndpointClass(serviceContext, Endpoint3.class, config);
annotationReader.loadEndpointMethods(serviceContext, Endpoint3.class, config.getApiClassConfig().getMethods());
validateEndpoint1(config, Endpoint3.class);
String[] defaultScopes = { "ss0", "ss1 ss2" };
String[] defaultAudiences = { "aa0", "aa1" };
String[] defaultClientIds = { "cc0", "cc1" };
ApiMethodConfig getBar = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Endpoint3.class.getMethod("getBar", String.class)));
validateMethod(getBar, "Endpoint3.getBar", "bar/{id}", ApiMethod.HttpMethod.GET, defaultScopes, defaultAudiences, defaultClientIds, ImmutableList.of(PassAuthenticator.class), ImmutableList.of(PassPeerAuthenticator.class));
assertEquals(1, getBar.getParameterConfigs().size());
validateParameter(getBar.getParameterConfigs().get(0), "id", false, null, String.class);
}
use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testDeepGenericHierarchyFailEndpoint.
@Test
public void testDeepGenericHierarchyFailEndpoint() throws Exception {
ApiConfig config = createConfig(DeepGenericHierarchyFailEndpoint.class);
annotationReader.loadEndpointMethods(serviceContext, DeepGenericHierarchyFailEndpoint.class, config.getApiClassConfig().getMethods());
ApiMethodConfig method1 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(DeepGenericHierarchyFailEndpoint.class, DeepGenericHierarchyFailEndpoint.class.getMethod("foo", String.class, Integer.class, Collection.class)));
assertEquals("DeepGenericHierarchyFailEndpoint.foo", method1.getName());
ApiMethodConfig method2 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(DeepGenericHierarchyFailEndpoint.class, DeepGenericHierarchyFailEndpoint.class.getSuperclass().getSuperclass().getSuperclass().getMethod("foo", Object.class, Object.class, Object.class)));
assertEquals("Endpoint3.foo", method2.getName());
}
Aggregations