package com.github.arteam.jdit;

import com.github.arteam.jdit.annotations.DBIHandle;
import com.github.arteam.jdit.annotations.DataSet;
import com.github.arteam.jdit.annotations.JditProperties;
import com.github.arteam.jdit.annotations.TestedSqlObject;
import com.github.arteam.jdit.domain.PlayerSqlObject;
import com.google.common.collect.ImmutableList;
import org.jdbi.v3.core.Handle;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Date;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;

@JditProperties("jdit-mysql.properties")
@RunWith(DBIRunner.class)
public class MySqlDbTest {

    private static final DateTimeFormatter fmt = ISODateTimeFormat.date().withZoneUTC();

    @TestedSqlObject
    private PlayerSqlObject playerDao;

    @DBIHandle
    private Handle handle;

    @Test
    @DataSet("playerDao/getInitials.sql")
    public void testCreatePlayer() {
        Long playerId = playerDao.createPlayer("Joel", "Edmunson",
                date("1993-06-28"), 193, 94);
        assertEquals(playerId.longValue(), 2L);

        Map<String, Object> row = handle.select("select * from players where id=?", 2)
                .mapToMap()
                .findOnly();
        assertEquals(row.get("id"), 2);
        assertEquals(row.get("first_name"), "Joel");
        assertEquals(row.get("last_name"), "Edmunson");
        assertEquals(row.get("weight"), 94);
        assertEquals(row.get("height"), 193);
        assertEquals(row.get("birth_date").toString(), "1993-06-28");
    }

    @Test
    @DataSet("playerDao/getInitials.sql")
    public void testCreateAnotherPlayer() {
        Long playerId = playerDao.createPlayer("Nail", "Yakupov",
                date("1993-10-06"), 178, 75);
        assertEquals(playerId.longValue(), 2L);

        Map<String, Object> row = handle.select("select * from players where id=?", 2)
                .mapToMap()
                .findOnly();
        assertEquals(row.get("id"), 2);
        assertEquals(row.get("first_name"), "Nail");
        assertEquals(row.get("last_name"), "Yakupov");
        assertEquals(row.get("weight"), 75);
        assertEquals(row.get("height"), 178);
        assertEquals(row.get("birth_date").toString(), "1993-10-06");
    }

    @Test
    @DataSet("playerDao/getInitials.sql")
    public void testGetLastNames() {
        List<String> lastNames = playerDao.getLastNames();
        assertEquals(lastNames, ImmutableList.of("Tarasenko"));
    }

    private static Date date(String textDate) {
        return fmt.parseDateTime(textDate).toDate();
    }
}

@@ -72,2727 +72,121 @@
 ons.
-DBIHandle;%0Aimport com.github.arteam.jdit.annotations.DataSet;%0Aimport com.github.arteam.jdit.annotations.JditProperties;%0Aimport com.github.arteam.jdit.annotations.TestedSqlObject;%0Aimport com.github.arteam.jdit.domain.PlayerSqlObject;%0Aimport com.google.common.collect.ImmutableList;%0Aimport org.jdbi.v3.core.Handle;%0Aimport org.joda.time.format.DateTimeFormatter;%0Aimport org.joda.time.format.ISODateTimeFormat;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Ignore;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0A%0Aimport java.util.Date;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assume.assumeTrue;%0A%0A@JditProperties(%22jdit-mysql.properties%22)%0A@RunWith(DBIRunner.class)%0Apublic class MySqlDbTest %7B%0A%0A    private static final DateTimeFormatter fmt = ISODateTimeFormat.date().withZoneUTC();%0A%0A    @TestedSqlObject%0A    private PlayerSqlObject playerDao;%0A%0A    @DBIHandle%0A    private Handle handle;%0A%0A    @Test%0A    @DataSet(%22playerDao/getInitials.sql%22)%0A    public void testCreatePlayer() %7B%0A        Long playerId = playerDao.createPlayer(%22Joel%22, %22Edmunson%22,%0A                date(%221993-06-28%22), 193, 94);%0A        assertEquals(playerId.longValue(), 2L);%0A%0A        Map%3CString, Object%3E row = handle.select(%22select * from players where id=?%22, 2)%0A                .mapToMap()%0A                .findOnly();%0A        assertEquals(row.get(%22id%22), 2);%0A        assertEquals(row.get(%22first_name%22), %22Joel%22);%0A        assertEquals(row.get(%22last_name%22), %22Edmunson%22);%0A        assertEquals(row.get(%22weight%22), 94);%0A        assertEquals(row.get(%22height%22), 193);%0A        assertEquals(row.get(%22birth_date%22).toString(), %221993-06-28%22);%0A    %7D%0A%0A    @Test%0A    @DataSet(%22playerDao/getInitials.sql%22)%0A    public void testCreateAnotherPlayer() %7B%0A        Long playerId = playerDao.createPlayer(%22Nail%22, %22Yakupov%22,%0A                date(%221993-10-06%22), 178, 75);%0A        assertEquals(playerId.longValue(), 2L);%0A%0A        Map%3CString, Object%3E row = handle.select(%22select * from players where id=?%22, 2)%0A                .mapToMap()%0A                .findOnly();%0A        assertEquals(row.get(%22id%22), 2);%0A        assertEquals(row.get(%22first_name%22), %22Nail%22);%0A        assertEquals(row.get(%22last_name%22), %22Yakupov%22);%0A        assertEquals(row.get(%22weight%22), 75);%0A        assertEquals(row.get(%22height%22), 178);%0A        assertEquals(row.get(%22birth_date%22).toString(), %221993-10-06%22);%0A    %7D%0A%0A    @Test%0A    @DataSet(%22playerDao/getInitials.sql%22)%0A    public void testGetLastNames() %7B%0A        List%3CString%3E lastNames = playerDao.getLastNames();%0A        assertEquals(lastNames, ImmutableList.of(%22Tarasenko%22));%0A    %7D%0A%0A    private static Date date(String textDate) %7B%0A        return fmt.parseDateTime(textDate).toDate();%0A    %7D
+JditProperties;%0A%0A@JditProperties(%22jdit-mysql.properties%22)%0Apublic class MySqlDbTest extends AlternateDatabaseTest %7B
 %0A%7D%0A

Make MySqlDbTest extending AlternateDatabaseTest as other tests