diff --git a/src/main/java/com/loafle/overflow/module/domain/service/DomainMemberService.java b/src/main/java/com/loafle/overflow/module/domain/service/DomainMemberService.java new file mode 100644 index 0000000..04bc3b8 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/domain/service/DomainMemberService.java @@ -0,0 +1,21 @@ +package com.loafle.overflow.module.domain.service; + +import com.loafle.overflow.module.domain.dao.DomainMemberDAO; +import com.loafle.overflow.module.domain.model.DomainMember; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service +public class DomainMemberService { + + @Autowired + private DomainMemberDAO domainMemberDAO; + + public void regist(DomainMember domainMember) { + this.domainMemberDAO.save(domainMember); + } + +} diff --git a/src/main/java/com/loafle/overflow/module/domain/service/DomainService.java b/src/main/java/com/loafle/overflow/module/domain/service/DomainService.java new file mode 100644 index 0000000..88eecf9 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/domain/service/DomainService.java @@ -0,0 +1,20 @@ +package com.loafle.overflow.module.domain.service; + +import com.loafle.overflow.module.domain.dao.DomainDAO; +import com.loafle.overflow.module.domain.model.Domain; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service +public class DomainService { + + @Autowired + private DomainDAO domainDAO; + + public void regist(Domain domain) { + this.domainDAO.save(domain); + } +} diff --git a/src/main/resources/database.properties b/src/main/resources/database.properties index fc3beda..0b6c454 100644 --- a/src/main/resources/database.properties +++ b/src/main/resources/database.properties @@ -1,4 +1,4 @@ -datasource.url=jdbc:postgresql://192.168.1.103:5432/overflow +datasource.url=jdbc:postgresql://192.168.1.209:5432/overflow datasource.username=overflow datasource.password=qwer5795 datasource.driver-class-name=org.postgresql.Driver diff --git a/src/test/java/com/loafle/overflow/module/domain/service/DomainMemberServiceTest.java b/src/test/java/com/loafle/overflow/module/domain/service/DomainMemberServiceTest.java new file mode 100644 index 0000000..c1eb3f0 --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/domain/service/DomainMemberServiceTest.java @@ -0,0 +1,49 @@ +package com.loafle.overflow.module.domain.service; + +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 com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import org.junit.Assert; +import org.junit.Ignore; +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 static org.junit.Assert.*; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class DomainMemberServiceTest { + + @Autowired + private DomainMemberService domainMemberService; + + @Ignore + @Test + public void regist() throws Exception { + + DomainMember domainMember = new DomainMember(); + + Domain domain = new Domain(); + domain.setId(1); + + Member member = new Member(); + member.setId(1); + + domainMember.setDomain(domain); + domainMember.setMember(member); + + this.domainMemberService.regist(domainMember); + + Assert.assertNotEquals(domainMember.getId(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/domain/service/DomainServiceTest.java b/src/test/java/com/loafle/overflow/module/domain/service/DomainServiceTest.java new file mode 100644 index 0000000..1565997 --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/domain/service/DomainServiceTest.java @@ -0,0 +1,39 @@ +package com.loafle.overflow.module.domain.service; + +import com.loafle.overflow.module.domain.model.Domain; +import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import org.junit.Assert; +import org.junit.Ignore; +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 static org.junit.Assert.*; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class DomainServiceTest { + + @Autowired + private DomainService domainService; + + @Ignore + @Test + public void regist() throws Exception { + + Domain domain = new Domain(); + + domain.setName("overFlow's domain22"); + + this.domainService.regist(domain); + + Assert.assertNotEquals(domain.getId(), 0); + } + +} \ No newline at end of file