diff --git a/src/main/java/com/loafle/overflow/module/target/model/Target.java b/src/main/java/com/loafle/overflow/module/target/model/Target.java index 362a967..91e6c89 100644 --- a/src/main/java/com/loafle/overflow/module/target/model/Target.java +++ b/src/main/java/com/loafle/overflow/module/target/model/Target.java @@ -4,7 +4,7 @@ import com.loafle.overflow.module.infra.model.Infra; import com.loafle.overflow.module.probe.model.Probe; import javax.persistence.*; -import java.sql.Timestamp; +import java.util.Date; /** * Created by root on 17. 6. 22. @@ -14,7 +14,7 @@ import java.sql.Timestamp; public class Target { private long id; - private Timestamp createDate; + private Date createDate; private Probe probe; private Infra infra; @@ -28,13 +28,13 @@ public class Target { this.id = id; } - + @Temporal(TemporalType.TIMESTAMP) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) - public Timestamp getCreateDate() { + public Date getCreateDate() { return createDate; } - public void setCreateDate(Timestamp createDate) { + public void setCreateDate(Date createDate) { this.createDate = createDate; } diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index e096f97..6982c75 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -206,4 +206,7 @@ INSERT INTO public.infra_machine (id,create_date,meta,probe_id) VALUES ( 0,'2017-06-26 12:12:11.698',NULL,1); INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES ( -1,0,'2017-06-26 12:12:11.809',1); \ No newline at end of file +1,0,'2017-06-26 12:12:11.809',1); + +INSERT INTO public.target (id,create_date,infra_id,probe_id) VALUES ( +1,'2017-06-26 12:37:22.854',1,1); \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/target/dao/TargetDAOTest.java b/src/test/java/com/loafle/overflow/module/target/dao/TargetDAOTest.java index 33f6bc9..1a3ec1c 100644 --- a/src/test/java/com/loafle/overflow/module/target/dao/TargetDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/target/dao/TargetDAOTest.java @@ -5,17 +5,16 @@ import com.loafle.overflow.JdbcConfiguration; import com.loafle.overflow.module.infra.model.Infra; import com.loafle.overflow.module.probe.model.Probe; import com.loafle.overflow.module.target.model.Target; -import org.junit.Ignore; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.sql.Timestamp; import java.util.Date; +import java.util.List; -@Ignore @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) public class TargetDAOTest { @@ -23,11 +22,10 @@ public class TargetDAOTest { @Autowired private TargetDAO repo; - @Test public void create() { Target t = new Target(); - t.setCreateDate(new Timestamp(new Date().getTime())); + t.setCreateDate(new Date()); Infra i = new Infra(); i.setId(1); @@ -39,8 +37,16 @@ public class TargetDAOTest { t.setInfra(i); t.setProbe(p); - Target ret = repo.save(t); + repo.save(t); + } + @Test + public void list() { + + Probe p = new Probe(); + p.setId(1); + List list = repo.findAllByProbe(p); + Assert.assertNotNull(list); }