package fr.jbrunet.app.awesome.db;

import fr.jbrunet.app.awesome.pojos.Foo;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.logging.PrintStreamLog;

import java.util.Date;
import java.util.UUID;

/**
 * Created by Julien BRUNET on 27/10/2014.
 */
public class FooDAOTest {

    private DBI dbi;
    private FooDAO foo;

    @Before
    public void setup() {
        //dbi = new DBI("jdbc:h2:./database" + UUID.randomUUID());
        dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID());
        dbi.setSQLLog(new PrintStreamLog(System.out));
        foo = dbi.open(FooDAO.class);
        foo.createTable();
    }

    @After
    public void teardown() {
        foo.close();
    }

    @Test
    public void FooCRUD() {

        //Create
        Long id = foo.create(new Foo(null, "label", "description", new Date(), false));
        Assert.assertNotNull(id);

        //Read
        Foo f = foo.searchById(id);
        Assert.assertNotNull(f);
        Assert.assertEquals(f.getLabel(), "label");
    }
}

@@ -590,16 +590,18 @@
         
+//
 dbi.setS
@@ -813,17 +813,31 @@
 FooC
-RUD
+reateAndSearchById
 () %7B%0A
-%0A
     
@@ -864,16 +864,17 @@
  Long id
+1
  = foo.c
@@ -894,21 +894,143 @@
 (null, %22
-label
+foo1%22, %22description%22, new Date(), false));%0A        Assert.assertNotNull(id1);%0A        Long id2 = foo.create(new Foo(null, %22foo2
 %22, %22desc
@@ -1091,16 +1091,17 @@
 tNull(id
+2
 );%0A%0A    
@@ -1124,16 +1124,17 @@
    Foo f
+1
  = foo.s
@@ -1145,16 +1145,17 @@
 hById(id
+1
 );%0A     
@@ -1179,16 +1179,17 @@
 otNull(f
+1
 );%0A     
@@ -1212,16 +1212,17 @@
 Equals(f
+1
 .getLabe
@@ -1231,13 +1231,137 @@
 ), %22
-label
+foo1%22);%0A%0A        Foo f2 = foo.searchById(id2);%0A        Assert.assertNotNull(f2);%0A        Assert.assertEquals(f2.getLabel(), %22foo2
 %22);%0A

Update first Unit tests