use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaTest method testDefaultSchemaWithProperties.
@Test
public void testDefaultSchemaWithProperties() {
ResourceSchema schema = ResourceSchema.builderForType(Integer.class).addProperty("foo", ResourcePropertySchema.of(TypeToken.of(Float.class))).addProperty("bar", ResourcePropertySchema.of(TypeToken.of(Double.class))).build();
assertThat(schema.getProperties().keySet()).containsExactly("foo", "bar");
assertEquals(Float.class, schema.getProperties().get("foo").getJavaType());
assertEquals(Double.class, schema.getProperties().get("bar").getJavaType());
}
use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaTest method testBuilderWithResource.
@Test
public void testBuilderWithResource() {
ResourceSchema originalSchema = ResourceSchema.builderForType(Integer.class).addProperty("foo", ResourcePropertySchema.of(TypeToken.of(Float.class))).build();
ResourceSchema.Builder newSchemaBuilder = ResourceSchema.builderWithSchema(originalSchema);
assertEquals(originalSchema, newSchemaBuilder.build());
newSchemaBuilder.addProperty("bar", ResourcePropertySchema.of(TypeToken.of(Double.class)));
newSchemaBuilder.setName("Number");
assertThat(newSchemaBuilder.build().getProperties().keySet()).containsExactly("foo", "bar");
assertEquals(newSchemaBuilder.build().getName(), "Number");
}
use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaTest method testDefaultSchemaWithAlternateName.
@Test
public void testDefaultSchemaWithAlternateName() {
ResourceSchema schema = ResourceSchema.builderForType(Integer.class).setName("Number").build();
assertEquals("Number", schema.getName());
assertEquals(Integer.class, schema.getType());
}
use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaTest method testDuplicateProperties.
@Test
public void testDuplicateProperties() {
try {
ResourceSchema schema = ResourceSchema.builderForType(Integer.class).addProperty("foo", ResourcePropertySchema.of(TypeToken.of(Float.class))).addProperty("foo", ResourcePropertySchema.of(TypeToken.of(Double.class))).build();
fail("Expected " + IllegalArgumentException.class);
} catch (IllegalArgumentException e) {
// expected
}
}
use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaProviderTest method testBeanPropertyWithGetterAndSetter.
@Test
public void testBeanPropertyWithGetterAndSetter() throws Exception {
ResourceSchema schema = getResourceSchema(Bean.class);
assertThat(schema.getProperties().keySet()).containsExactly("date");
assertEquals(Date.class, schema.getProperties().get("date").getJavaType());
}
Aggregations