use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testDeepInheritanceCycleDetection.
@Test
public void testDeepInheritanceCycleDetection() throws Exception {
// Nest the classes, so Java doesn't get upset about declaration/reference order.
@ApiReference(Test1.Test2.class)
@Api(name = "Test1")
final class Test1 {
@ApiReference(Test2.Test3.class)
final class Test2 {
@ApiReference(Test3.Test4.class)
@Api(name = "Test3")
final class Test3 {
@ApiReference(Test4.Test5.class)
final class Test4 {
@ApiReference(Test5.Test6.class)
@Api(name = "Test5")
final class Test5 {
@ApiReference(Test6.Test7.class)
final class Test6 {
@ApiReference(Test7.Test8.class)
@Api(name = "Test7")
final class Test7 {
@ApiReference(Test1.class)
final class Test8 {
}
}
}
}
}
}
}
}
try {
ApiConfig config = createConfig(Test1.class);
annotationReader.loadEndpointClass(serviceContext, Test1.class, config);
fail();
} catch (CyclicApiInheritanceException e) {
// Expected.
}
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testReadParametersInApiNamespace.
@Test
public void testReadParametersInApiNamespace() throws Exception {
@Api
class ValidNamespaceDefault {
}
ApiConfig config = createConfig(ValidNamespaceDefault.class);
annotationReader.loadEndpointClass(serviceContext, ValidNamespaceDefault.class, config);
@Api(namespace = @ApiNamespace(ownerDomain = "domain", ownerName = ""))
class BadNamespaceEmptyName {
}
config = createConfig(BadNamespaceEmptyName.class);
annotationReader.loadEndpointClass(serviceContext, BadNamespaceEmptyName.class, config);
assertEquals("domain", config.getNamespaceConfig().getOwnerDomain());
@Api(namespace = @ApiNamespace(ownerDomain = "", ownerName = "name"))
class BadNamespaceEmptyDomain {
}
config = createConfig(BadNamespaceEmptyDomain.class);
annotationReader.loadEndpointClass(serviceContext, BadNamespaceEmptyDomain.class, config);
assertEquals("name", config.getNamespaceConfig().getOwnerName());
@Api(namespace = @ApiNamespace(ownerDomain = "domain", ownerName = "name"))
class ValidNamespaceEmptyPackage {
}
config = createConfig(ValidNamespaceEmptyPackage.class);
annotationReader.loadEndpointClass(serviceContext, ValidNamespaceEmptyPackage.class, config);
assertEquals("domain", config.getNamespaceConfig().getOwnerDomain());
assertEquals("name", config.getNamespaceConfig().getOwnerName());
@Api(namespace = @ApiNamespace(ownerDomain = "domain", ownerName = "name", packagePath = "package"))
class ValidNamespaceFullySpecified {
}
config = createConfig(ValidNamespaceFullySpecified.class);
annotationReader.loadEndpointClass(serviceContext, ValidNamespaceFullySpecified.class, config);
assertEquals("domain", config.getNamespaceConfig().getOwnerDomain());
assertEquals("name", config.getNamespaceConfig().getOwnerName());
assertEquals("package", config.getNamespaceConfig().getPackagePath());
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testKnownParameterizedType.
@Test
public void testKnownParameterizedType() throws Exception {
@Api
class Bar<T1> {
@SuppressWarnings("unused")
public void bar(T1 t1) {
}
}
class Foo extends Bar<Integer> {
}
ApiConfig config = createConfig(Foo.class);
annotationReader.loadEndpointMethods(serviceContext, Foo.class, config.getApiClassConfig().getMethods());
ApiParameterConfig parameter = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Foo.class.getSuperclass().getDeclaredMethod("bar", Object.class))).getParameterConfigs().get(0);
assertEquals(ApiParameterConfig.Classification.API_PARAMETER, parameter.getClassification());
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testFullySpecializedDateEndpoint.
@Test
public void testFullySpecializedDateEndpoint() throws Exception {
ApiConfig config = createConfig(RestfulResourceEndpointBase.FullySpecializedEndpoint.class);
annotationReader.loadEndpointMethods(serviceContext, RestfulResourceEndpointBase.FullySpecializedEndpoint.class, config.getApiClassConfig().getMethods());
assertEquals(6, config.getApiClassConfig().getMethods().size());
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testDeepGenericHierarchySuccessEndpoint.
@Test
public void testDeepGenericHierarchySuccessEndpoint() throws Exception {
ApiConfig config = createConfig(DeepGenericHierarchySuccessEndpoint.class);
annotationReader.loadEndpointMethods(serviceContext, DeepGenericHierarchySuccessEndpoint.class, config.getApiClassConfig().getMethods());
assertEquals(1, config.getApiClassConfig().getMethods().size());
assertNotNull(config.getApiClassConfig().getMethods().get(methodToEndpointMethod(DeepGenericHierarchySuccessEndpoint.class.getMethod("foo", String.class, Integer.class, Boolean.class))));
}
Aggregations