Search in sources :

Example 16 with ResourceType

use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.

the class TableJdbcResourceTypeTest method path.

@Test
public void path() {
    final ResourceType table = new TableJdbcResourceType(dataSource);
    assertEquals(2, table.path().size());
    assertEquals("schema", table.path().get(0));
    assertEquals("table", table.path().get(1));
}
Also used : ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) Test(org.junit.Test)

Example 17 with ResourceType

use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.

the class ColumnJdbcResourceTypeTest method path.

@Test
public void path() {
    final ResourceType column = new ColumnJdbcResourceType(dataSource);
    assertEquals(3, column.path().size());
    assertEquals("schema", column.path().get(0));
    assertEquals("table", column.path().get(1));
    assertEquals("column", column.path().get(2));
}
Also used : ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) Test(org.junit.Test)

Example 18 with ResourceType

use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.

the class FkJdbcResourceTypeTest method read.

@Test
public void read() {
    final ResourceType fk = new FkJdbcResourceType(dataSource);
    final Stream<DbResource> foreignKeys = fk.read(new SqlPlaceholdersWrapper(new DbUri("fk", asList("*"))));
    assertEquals(1, foreignKeys.count());
}
Also used : SqlPlaceholdersWrapper(com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) DbResource(com.github.mgramin.sqlboot.model.resource.DbResource) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) Test(org.junit.Test)

Example 19 with ResourceType

use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.

the class ChildTableJdbcResourceTypeTest method read.

@Test
public void read() {
    final ResourceType pk = new ChildTableJdbcResourceType(dataSource);
    final Stream<DbResource> primaryKeys = pk.read(new SqlPlaceholdersWrapper(new DbUri("child_table", asList("*"))));
    assertEquals(1, primaryKeys.count());
}
Also used : SqlPlaceholdersWrapper(com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) DbResource(com.github.mgramin.sqlboot.model.resource.DbResource) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) Test(org.junit.Test)

Example 20 with ResourceType

use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.

the class SqlResourceTypeTest method read2.

@Test
public void read2() {
    final String sql = "select * from (select table_schema as \"@table_schema\", table_name as \"@table_name\", column_name as \"@column_name\"" + "from information_schema.columns)";
    ResourceType type = new WhereWrapper(new SqlResourceType(new JdbcSqlQuery(dataSource, new GroovyTemplateGenerator(sql)), asList("column")));
    assertEquals(8, type.read(new DbUri("column/main_schema.users")).count());
}
Also used : DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) JdbcSqlQuery(com.github.mgramin.sqlboot.sql.impl.JdbcSqlQuery) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) GroovyTemplateGenerator(com.github.mgramin.sqlboot.template.generator.impl.GroovyTemplateGenerator) WhereWrapper(com.github.mgramin.sqlboot.model.resource_type.wrappers.list.WhereWrapper) Test(org.junit.Test)

Aggregations

ResourceType (com.github.mgramin.sqlboot.model.resource_type.ResourceType)22 Test (org.junit.Test)18 DbUri (com.github.mgramin.sqlboot.model.uri.impl.DbUri)16 SqlPlaceholdersWrapper (com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper)14 DbResource (com.github.mgramin.sqlboot.model.resource.DbResource)13 JdbcSqlQuery (com.github.mgramin.sqlboot.sql.impl.JdbcSqlQuery)4 GroovyTemplateGenerator (com.github.mgramin.sqlboot.template.generator.impl.GroovyTemplateGenerator)4 FsResourceTypes (com.github.mgramin.sqlboot.model.resource_type.impl.composite.FsResourceTypes)3 Uri (com.github.mgramin.sqlboot.model.uri.Uri)3 ProcedureJdbcResourceType (com.github.mgramin.sqlboot.model.resource_type.impl.jdbc.schema.procedure.ProcedureJdbcResourceType)2 WhereWrapper (com.github.mgramin.sqlboot.model.resource_type.wrappers.list.WhereWrapper)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ResponseEntity (org.springframework.http.ResponseEntity)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 BootException (com.github.mgramin.sqlboot.exceptions.BootException)1 DbConnectionList (com.github.mgramin.sqlboot.model.connection.DbConnectionList)1 MarkdownFile (com.github.mgramin.sqlboot.model.resource_type.impl.composite.md.MarkdownFile)1 SchemaJdbcResourceType (com.github.mgramin.sqlboot.model.resource_type.impl.jdbc.schema.SchemaJdbcResourceType)1