This commit is contained in:
insanity 2017-06-26 12:38:03 +09:00
parent 39f4ac1b6f
commit 73a4601ebd
3 changed files with 21 additions and 12 deletions

View File

@ -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;
}

View File

@ -207,3 +207,6 @@ INSERT INTO public.infra_machine (id,create_date,meta,probe_id) VALUES (
INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES (
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);

View File

@ -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<Target> list = repo.findAllByProbe(p);
Assert.assertNotNull(list);
}