/*
 * Copyright (c) 2017 Falko Schumann
 * Released under the terms of the MIT License.
 */

package de.muspellheim;

import com.mysql.jdbc.jdbc2.optional.*;
import org.junit.*;

import javax.sql.*;

public class DDLTest {

    private DataSource dataSource;

    @Before
    public void setUp() throws Exception {
        MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();
        dataSource.setPort(8889);
        dataSource.setUser("root");
        dataSource.setPassword("root");
        this.dataSource = dataSource;
    }

    @Test
    public void testCreateSchema() throws Exception {
        JDBCFacade jdbc = new JDBCFacade(dataSource);
        jdbc.executeDDLCommand(connection -> connection.statement("DROP SCHEMA IF EXISTS oshop").execute());
        jdbc.executeDDLCommand(connection -> connection.statement("CREATE SCHEMA oshop CHARACTER SET utf8 COLLATE utf8_unicode_ci").execute());
    }

}

@@ -176,29 +176,8 @@
 *;%0A%0A
-import javax.sql.*;%0A%0A
 publ
@@ -200,44 +200,8 @@
  %7B%0A%0A
-    private DataSource dataSource;%0A%0A
     
@@ -228,13 +228,20 @@
 oid 
-setUp
+createSchema
 () t
@@ -460,116 +460,8 @@
 %22);%0A
-        this.dataSource = dataSource;%0A    %7D%0A%0A    @Test%0A    public void testCreateSchema() throws Exception %7B
 %0A   
@@ -771,10 +771,2654 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void createTablesKundenverwaltung() throws Exception %7B%0A        MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();%0A        dataSource.setPort(8889);%0A        dataSource.setUser(%22root%22);%0A        dataSource.setPassword(%22root%22);%0A        dataSource.setDatabaseName(%22oshop%22);%0A%0A        JDBCFacade jdbc = new JDBCFacade(dataSource);%0A%0A        jdbc.executeDDLCommand(connection -%3E connection.statement(%0A                %22CREATE TABLE adresse (%22%0A                        + %22adresse_id INT UNSIGNED AUTO_INCREMENT,%22%0A                        + %22strasse VARCHAR(255),%22%0A                        + %22hnr VARCHAR(255),%22%0A                        + %22lkz CHAR(2),%22%0A                        + %22plz CHAR(9),%22%0A                        + %22ort VARCHAR(255),%22%0A                        + %22deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,%22%0A                        + %22PRIMARY KEY(adresse_id)%22%0A                        + %22)%22%0A        ).execute());%0A%0A        jdbc.executeDDLCommand(connection -%3E connection.statement(%0A                %22CREATE TABLE kunde (%22%0A                        + %22kunde_id INT UNSIGNED AUTO_INCREMENT,%22%0A                        + %22nachname VARCHAR(255),%22%0A                        + %22vorname VARCHAR(255),%22%0A                        + %22rechnung_adresse_id INT UNSIGNED,%22%0A                        + %22liefer_adresse_id INT UNSIGNED,%22%0A                        + %22bezahlart INT UNSIGNED NOT NULL DEFAULT 0,%22%0A                        + %22art INT UNSIGNED NOT NULL DEFAULT 0,%22%0A                        + %22deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,%22%0A                        + %22PRIMARY KEY(kunde_id)%22%0A                        + %22)%22%0A        ).execute());%0A%0A        jdbc.executeDDLCommand(connection -%3E connection.statement(%0A                %22CREATE TABLE bank (%22%0A                        + %22bank_id CHAR(12),%22%0A                        + %22bankname VARCHAR(255),%22%0A                        + %22lkz CHAR(2),%22%0A                        + %22deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,%22%0A                        + %22PRIMARY KEY(bank_id)%22%0A                        + %22)%22%0A        ).execute());%0A%0A        jdbc.executeDDLCommand(connection -%3E connection.statement(%0A                %22CREATE TABLE bankverbindung (%22%0A                        + %22kunde_id INT UNSIGNED,%22%0A                        + %22bankverbindung_nr INT UNSIGNED,%22%0A                        + %22bank_id CHAR(12),%22%0A                        + %22kontonummer CHAR(25),%22%0A                        + %22iban CHAR(34),%22%0A                        + %22deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,%22%0A                        + %22PRIMARY KEY(kunde_id, bankverbindung_nr)%22%0A                        + %22)%22%0A        ).execute());%0A    %7D%0A%0A
 %7D%0A

Create tables