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;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
/**
@ -14,6 +13,12 @@ public class Domain {
private String name;
private Date createDate;
public Domain() {
}
public Domain(long id) {
this.id = id;
}
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {

View File

@ -1,5 +1,7 @@
package com.loafle.overflow.module.domain.model;
import com.loafle.overflow.module.member.model.Member;
import javax.persistence.*;
import java.sql.Timestamp;
@ -11,6 +13,8 @@ import java.sql.Timestamp;
public class DomainMember {
private long id;
private Timestamp createDate;
private Member member;
private Domain domain;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@ -32,4 +36,24 @@ public class DomainMember {
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 (
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;
import com.loafle.overflow.AppConfig;
import com.loafle.overflow.JdbcConfiguration;
import com.loafle.overflow.module.infra.dao.InfraDAO;
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;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
public class JPAInfraDAOTest {
@Autowired
private InfraDAO repo;
@Test
public void create() {
}
}
//package com.loafle.overflow.infra.dao;
//
//import com.loafle.overflow.AppConfig;
//import com.loafle.overflow.JdbcConfiguration;
//import com.loafle.overflow.meta.dao.MetaInfraTypeDAO;
//import com.loafle.overflow.meta.model.MetaInfraType;
//import com.loafle.overflow.module.infra.dao.InfraDAO;
//import com.loafle.overflow.module.infra.dao.InfraHostDAO;
//import com.loafle.overflow.module.infra.dao.InfraOSDAO;
//import com.loafle.overflow.module.infra.model.Infra;
//import com.loafle.overflow.module.infra.model.InfraHost;
//import com.loafle.overflow.module.infra.model.InfraOS;
//import org.junit.After;
//import org.junit.Before;
//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.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.setName("snoop's domain");
domain.setName("overFlow's 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.JdbcConfiguration;
import com.loafle.overflow.module.domain.model.Domain;
import com.loafle.overflow.module.domain.model.DomainMember;
import com.loafle.overflow.module.member.model.Member;
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;
@ -15,12 +18,16 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
public class DomainMemberDAOTest {
@Autowired
private DomainMemberDAO repo;
@Test
public void testCreate() {
DomainMember domainMember = new DomainMember();
domainMember.setDomain(new Domain(1));
domainMember.setMember(new Member(1));
repo.save(domainMember);
}
}