init sql
This commit is contained in:
parent
39f4ac1b6f
commit
73a4601ebd
|
@ -4,7 +4,7 @@ import com.loafle.overflow.module.infra.model.Infra;
|
||||||
import com.loafle.overflow.module.probe.model.Probe;
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.sql.Timestamp;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by root on 17. 6. 22.
|
* Created by root on 17. 6. 22.
|
||||||
|
@ -14,7 +14,7 @@ import java.sql.Timestamp;
|
||||||
public class Target {
|
public class Target {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private Timestamp createDate;
|
private Date createDate;
|
||||||
private Probe probe;
|
private Probe probe;
|
||||||
private Infra infra;
|
private Infra infra;
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@ public class Target {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||||
public Timestamp getCreateDate() {
|
public Date getCreateDate() {
|
||||||
return createDate;
|
return createDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreateDate(Timestamp createDate) {
|
public void setCreateDate(Date createDate) {
|
||||||
this.createDate = createDate;
|
this.createDate = createDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
0,'2017-06-26 12:12:11.698',NULL,1);
|
||||||
|
|
||||||
INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES (
|
INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES (
|
||||||
1,0,'2017-06-26 12:12:11.809',1);
|
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);
|
|
@ -5,17 +5,16 @@ import com.loafle.overflow.JdbcConfiguration;
|
||||||
import com.loafle.overflow.module.infra.model.Infra;
|
import com.loafle.overflow.module.infra.model.Infra;
|
||||||
import com.loafle.overflow.module.probe.model.Probe;
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
import com.loafle.overflow.module.target.model.Target;
|
import com.loafle.overflow.module.target.model.Target;
|
||||||
import org.junit.Ignore;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
||||||
public class TargetDAOTest {
|
public class TargetDAOTest {
|
||||||
|
@ -23,11 +22,10 @@ public class TargetDAOTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TargetDAO repo;
|
private TargetDAO repo;
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void create() {
|
public void create() {
|
||||||
Target t = new Target();
|
Target t = new Target();
|
||||||
t.setCreateDate(new Timestamp(new Date().getTime()));
|
t.setCreateDate(new Date());
|
||||||
|
|
||||||
Infra i = new Infra();
|
Infra i = new Infra();
|
||||||
i.setId(1);
|
i.setId(1);
|
||||||
|
@ -39,8 +37,16 @@ public class TargetDAOTest {
|
||||||
t.setInfra(i);
|
t.setInfra(i);
|
||||||
t.setProbe(p);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user