use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method schemaFromAnnotation.
@Test
void schemaFromAnnotation() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").build();
Table<SchemaInAnnotation> result = database.table(SchemaInAnnotation.class);
assertThat(result.qualifiedName(), is("ANNOTATION_SCHEMA.SCHEMA_IN_ANNOTATION"));
}
use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method givenAnnotationWithoutSchemaButSchemaOnParentThenParentIsUsed.
@Test
void givenAnnotationWithoutSchemaButSchemaOnParentThenParentIsUsed() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").build();
Table<NameInAnnotationAndSchemaInParentAnnotation> result = database.table(NameInAnnotationAndSchemaInParentAnnotation.class);
assertThat(result.qualifiedName(), is("ANNOTATION_SCHEMA.DERIVED_NAME_IN_ANNOTATION"));
}
use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method schemaFromBuilder.
@Test
void schemaFromBuilder() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").table(SchemaInAnnotation.class, t -> t.schema("BUILDER_SCHEMA")).build();
Table<SchemaInAnnotation> result = database.table(SchemaInAnnotation.class);
assertThat(result.qualifiedName(), is("BUILDER_SCHEMA.SCHEMA_IN_ANNOTATION"));
}
use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method schemaFromParentAnnotation.
@Test
void schemaFromParentAnnotation() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").build();
Table<SchemaInParentAnnotation> result = database.table(SchemaInParentAnnotation.class);
assertThat(result.qualifiedName(), is("ANNOTATION_SCHEMA.SCHEMA_IN_PARENT_ANNOTATION"));
}
use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method notInsertableFromBuilder.
@Test
void notInsertableFromBuilder() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").table(NoAnnotations.class, t -> t.column(NoAnnotations::updateTime, c -> c.insertable(false))).build();
String insertSql = database.table(NoAnnotations.class).columns().flatMap(Column::insertColumnSql).collect(joining(", "));
assertThat(database.table(NoAnnotations.class).column(NoAnnotations::id).insertable(), is(true));
assertThat(database.table(NoAnnotations.class).column(NoAnnotations::name).insertable(), is(true));
assertThat(database.table(NoAnnotations.class).column(NoAnnotations::updateTime).insertable(), is(false));
assertThat(database.table(NoAnnotations.class).column(NoAnnotations::insertTime).insertable(), is(true));
assertThat(insertSql, is("ID, NAME, INSERT_TIME"));
}
Aggregations