This commit is contained in:
insanity 2017-06-26 11:28:48 +09:00
parent 46e7247336
commit b21bcdf939
6 changed files with 135 additions and 29 deletions

View File

@ -1,7 +1,6 @@
package com.loafle.overflow.module.domain.model; package com.loafle.overflow.module.domain.model;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
/** /**
@ -14,6 +13,12 @@ public class Domain {
private String name; private String name;
private Date createDate; private Date createDate;
public Domain() {
}
public Domain(long id) {
this.id = id;
}
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() { public long getId() {

View File

@ -1,5 +1,7 @@
package com.loafle.overflow.module.domain.model; package com.loafle.overflow.module.domain.model;
import com.loafle.overflow.module.member.model.Member;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -11,6 +13,8 @@ import java.sql.Timestamp;
public class DomainMember { public class DomainMember {
private long id; private long id;
private Timestamp createDate; private Timestamp createDate;
private Member member;
private Domain domain;
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy= GenerationType.IDENTITY)
@ -32,4 +36,24 @@ public class DomainMember {
this.createDate = createDate; this.createDate = createDate;
} }
@ManyToOne
@JoinColumn(name = "MEMBER_ID", nullable = false)
public Member getMember() {
return member;
}
public void setMember(Member member) {
this.member = member;
}
@ManyToOne
@JoinColumn(name = "DOMAIN_ID", nullable = false)
public Domain getDomain() {
return domain;
}
public void setDomain(Domain domain) {
this.domain = domain;
}
} }

View File

@ -180,3 +180,17 @@ INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,vers
INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES (
16,'2017-06-25 16:59:59.522',2,4,2); 16,'2017-06-25 16:59:59.522',2,4,2);
--
--
--
--
--
INSERT INTO public."member" (id,company_name,create_date,email,"name",phone,pw,pw_salt,status_id) VALUES (
1,'loafle','2017-06-26 11:07:27.625','overflow@loafle.com','overFlow','000-000-0000','qwer5795','abcdabcdabcdabcd',2);
INSERT INTO public."domain" (id,create_date,"name") VALUES (
1,'2017-06-26 11:25:44.866','overFlow''s domain');
INSERT INTO public.domain_member (id,create_date,domain_id,member_id) VALUES (
1,'2017-06-26 11:27:43.023',1,1);

View File

@ -1,26 +1,82 @@
package com.loafle.overflow.infra.dao; //package com.loafle.overflow.infra.dao;
//
import com.loafle.overflow.AppConfig; //import com.loafle.overflow.AppConfig;
import com.loafle.overflow.JdbcConfiguration; //import com.loafle.overflow.JdbcConfiguration;
import com.loafle.overflow.module.infra.dao.InfraDAO; //import com.loafle.overflow.meta.dao.MetaInfraTypeDAO;
import org.junit.Test; //import com.loafle.overflow.meta.model.MetaInfraType;
import org.junit.runner.RunWith; //import com.loafle.overflow.module.infra.dao.InfraDAO;
import org.springframework.beans.factory.annotation.Autowired; //import com.loafle.overflow.module.infra.dao.InfraHostDAO;
import org.springframework.test.context.ContextConfiguration; //import com.loafle.overflow.module.infra.dao.InfraOSDAO;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; //import com.loafle.overflow.module.infra.model.Infra;
//import com.loafle.overflow.module.infra.model.InfraHost;
@RunWith(SpringJUnit4ClassRunner.class) //import com.loafle.overflow.module.infra.model.InfraOS;
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) //import org.junit.After;
public class JPAInfraDAOTest { //import org.junit.Before;
//import org.junit.Test;
@Autowired //import org.junit.runner.RunWith;
private InfraDAO repo; //import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.test.context.ContextConfiguration;
//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@Test //
public void create() { //import java.util.Date;
//
} //@RunWith(SpringJUnit4ClassRunner.class)
//@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
//public class JPAInfraDAOTest {
} //
// @Autowired
// private InfraDAO infraRepo;
// @Autowired
// private MetaInfraTypeDAO infraTypeRepo;
// @Autowired
// private InfraHostDAO infraHostRepo;
// @Autowired
// private InfraOSDAO infraOSRepo;
//
// @Before
// public void setUp() throws Exception {
//// MetaInfraType type1 = new MetaInfraType();
//// type1.setName("HOST");
//// type1.setCreateDate(new Date());
////
//// MetaInfraType type2 = new MetaInfraType();
//// type2.setName("MACHINE");
//// type2.setCreateDate(new Date());
////
//// MetaInfraType type3 = new MetaInfraType();
//// type3.setName("SERVICE");
//// type3.setCreateDate(new Date());
////
//// infraTypeRepo.save(type1);
//// infraTypeRepo.save(type2);
//// infraTypeRepo.save(type3);
////
//// InfraOS os = new InfraOS();
//// os.setCreateDate(new Date());
////
//// InfraHost host = new InfraHost();
//// host.setIp(111111);
//// host.setMac(22222222);
//// host.setCreateDate(new Date());
//// host.setOs();
////
//// infraHostRepo.save(host);
// }
//
// @After
// public void tearDown() throws Exception {
// Infra infra = new Infra();
// infra.setCreateDate(new Date());
// MetaInfraType t = new MetaInfraType();
// t.setId(1);
// infra.setType(t);
// infra.setChildId();
// }
//
// @Test
// public void create() {
// Infra infra = new Infra();
// }
//
//
//}

View File

@ -25,7 +25,7 @@ public class DomainDAOTest {
Domain domain = new Domain(); Domain domain = new Domain();
domain.setName("snoop's domain"); domain.setName("overFlow's domain");
this.domainDAO.save(domain); this.domainDAO.save(domain);

View File

@ -2,9 +2,12 @@ package com.loafle.overflow.module.domain.dao;
import com.loafle.overflow.AppConfig; import com.loafle.overflow.AppConfig;
import com.loafle.overflow.JdbcConfiguration; import com.loafle.overflow.JdbcConfiguration;
import com.loafle.overflow.module.domain.model.Domain;
import com.loafle.overflow.module.domain.model.DomainMember; import com.loafle.overflow.module.domain.model.DomainMember;
import com.loafle.overflow.module.member.model.Member;
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.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ -15,12 +18,16 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) @ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
public class DomainMemberDAOTest { public class DomainMemberDAOTest {
@Autowired
private DomainMemberDAO repo;
@Test @Test
public void testCreate() { public void testCreate() {
DomainMember domainMember = new DomainMember(); DomainMember domainMember = new DomainMember();
domainMember.setDomain(new Domain(1));
domainMember.setMember(new Member(1));
repo.save(domainMember);
} }
} }