From b21bcdf9399950b3fc00871fc175f2f179ec2dc5 Mon Sep 17 00:00:00 2001 From: insanity Date: Mon, 26 Jun 2017 11:28:48 +0900 Subject: [PATCH] init.sql --- .../overflow/module/domain/model/Domain.java | 7 +- .../module/domain/model/DomainMember.java | 24 ++++ src/main/resources/init.sql | 14 +++ .../overflow/infra/dao/JPAInfraDAOTest.java | 108 +++++++++++++----- .../module/domain/dao/DomainDAOTest.java | 2 +- .../domain/dao/DomainMemberDAOTest.java | 9 +- 6 files changed, 135 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/loafle/overflow/module/domain/model/Domain.java b/src/main/java/com/loafle/overflow/module/domain/model/Domain.java index 88200cd..7186d8a 100644 --- a/src/main/java/com/loafle/overflow/module/domain/model/Domain.java +++ b/src/main/java/com/loafle/overflow/module/domain/model/Domain.java @@ -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() { diff --git a/src/main/java/com/loafle/overflow/module/domain/model/DomainMember.java b/src/main/java/com/loafle/overflow/module/domain/model/DomainMember.java index 0f172d4..1254e63 100644 --- a/src/main/java/com/loafle/overflow/module/domain/model/DomainMember.java +++ b/src/main/java/com/loafle/overflow/module/domain/model/DomainMember.java @@ -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; + } } diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index efce6d2..1a986c2 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -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); \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/infra/dao/JPAInfraDAOTest.java b/src/test/java/com/loafle/overflow/infra/dao/JPAInfraDAOTest.java index b2c7bbe..514bedc 100644 --- a/src/test/java/com/loafle/overflow/infra/dao/JPAInfraDAOTest.java +++ b/src/test/java/com/loafle/overflow/infra/dao/JPAInfraDAOTest.java @@ -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() { - - } - - -} \ No newline at end of file +//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(); +// } +// +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/domain/dao/DomainDAOTest.java b/src/test/java/com/loafle/overflow/module/domain/dao/DomainDAOTest.java index 4a5a729..ee68fee 100644 --- a/src/test/java/com/loafle/overflow/module/domain/dao/DomainDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/domain/dao/DomainDAOTest.java @@ -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); diff --git a/src/test/java/com/loafle/overflow/module/domain/dao/DomainMemberDAOTest.java b/src/test/java/com/loafle/overflow/module/domain/dao/DomainMemberDAOTest.java index 135629b..3c6d5ec 100644 --- a/src/test/java/com/loafle/overflow/module/domain/dao/DomainMemberDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/domain/dao/DomainMemberDAOTest.java @@ -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); } } \ No newline at end of file