@@ -0,0 +1,2570 @@
+package com.arielslf.belajar.java.pelatihan.dao;%0A%0Aimport com.arielslf.belajar.java.pelatihan.PelatihanApplication;%0Aimport com.arielslf.belajar.java.pelatihan.entity.Peserta;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.util.Date;%0Aimport javax.sql.DataSource;%0Aimport org.junit.After;%0Aimport org.junit.Assert;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.SpringApplicationConfiguration;%0Aimport org.springframework.test.context.jdbc.Sql;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0A%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@SpringApplicationConfiguration(classes = PelatihanApplication.class)%0A@Sql(%0A        executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,%0A        scripts = %22/data/peserta.sql%22%0A)%0Apublic class PesertaDaoTest %7B%0A    %0A    @Autowired%0A    private PesertaDao pd;%0A    %0A    @Autowired%0A    private DataSource ds;%0A    %0A    %0A    @After%0A    public void hapusData() throws SQLException%7B%0A        String sql = %22delete from peserta where email = 'peserta001@gmail.com'%22;%0A             try (java.sql.Connection c = ds.getConnection()) %7B%0A                 c.createStatement().executeUpdate(sql);%0A             %7D%0A        %0A    %7D%0A    %0A    @Test%0A    public void testInsert() throws SQLException%7B%0A        Peserta p = new Peserta();%0A        p.setNama(%22Peserta 001%22);%0A        p.setEmail(%22peserta001@gmail.com%22);%0A        p.setTanggalLahir(new Date());%0A        %0A        pd.save(p);%0A        %0A      %0A        %0A        String sql = %22select count(*) as jumlah%22%0A                + %22 from peserta %22%0A                + %22 where email = 'peserta001@gmail.com'%22;%0A        %0A        try (java.sql.Connection c = ds.getConnection()) %7B%0A            ResultSet rs = c.createStatement().executeQuery(sql);%0A            Assert.assertTrue(rs.next());%0A            %0A            %0A            Long jumlahRow = rs.getLong(%22jumlah%22);%0A            Assert.assertEquals(1L, jumlahRow.longValue());%0A        %7D%0A        %0A    %7D%0A    %0A    @Test%0A    public void testHitung()%7B%0A        Long jumlah = pd.count();%0A        Assert.assertEquals(3L, jumlah.longValue());%0A    %7D%0A    %0A    %0A    @Test%0A    public void testCariById()%7B%0A        Peserta p = pd.findOne(%22aa1%22);%0A        %0A        Assert.assertNotNull(p);%0A        Assert.assertEquals(%22Peserta Test 001%22, p.getNama());%0A        Assert.assertEquals(%22peserta.test.001@gmail.com%22, p.getEmail());%0A        %0A        Peserta px = pd.findOne(%22xx%22);%0A        Assert.assertNull(px);%0A        %0A    %7D%0A    %0A    %0A%0A    %0A    %0A    %0A%7D%0A

implement query untuk table sesi