use of com.google.api.server.spi.config.model.ApiConfig 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.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testEndpointNoApiAnnotation.
@Test
public void testEndpointNoApiAnnotation() throws Exception {
ApiConfig config = createConfig(Object.class);
try {
annotationReader.loadEndpointClass(serviceContext, Object.class, config);
fail("No @Api annotation should've caused reader to fail.");
} catch (ApiConfigException expected) {
assertEquals("class java.lang.Object has no @Api annotation.", expected.getMessage());
}
}
use of com.google.api.server.spi.config.model.ApiConfig 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.ApiConfig 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.ApiConfig 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