diff --git a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java index 3b8fe0c..e990724 100644 --- a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java +++ b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java @@ -19,7 +19,6 @@ public class NoAuthProbeService { public void regist(NoAuthProbe noAuthProbe) { - this.noAuthProbeDAO.save(noAuthProbe); } diff --git a/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java b/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java new file mode 100644 index 0000000..5caf085 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java @@ -0,0 +1,34 @@ +package com.loafle.overflow.module.probe.service; + +import com.loafle.overflow.module.domain.model.Domain; +import com.loafle.overflow.module.probe.dao.ProbeDAO; +import com.loafle.overflow.module.probe.model.Probe; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service +public class ProbeService { + + @Autowired + private ProbeDAO probeDAO; + + public void regist(Probe probe) { + this.probeDAO.save(probe); + } + + public List readAllByDomain(Domain domain) { + + return this.probeDAO.findAllByDomain(domain); + } + + public Probe readByProbeKey(String probeKey) { + + return this.probeDAO.findByProbeKey(probeKey); + } + +} diff --git a/src/main/java/com/loafle/overflow/module/probe/service/ProbeTaskService.java b/src/main/java/com/loafle/overflow/module/probe/service/ProbeTaskService.java new file mode 100644 index 0000000..565f5da --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/probe/service/ProbeTaskService.java @@ -0,0 +1,27 @@ +package com.loafle.overflow.module.probe.service; + +import com.loafle.overflow.module.probe.dao.ProbeTaskDAO; +import com.loafle.overflow.module.probe.model.Probe; +import com.loafle.overflow.module.probe.model.ProbeTask; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service +public class ProbeTaskService { + + @Autowired + private ProbeTaskDAO probeTaskDAO; + + public void regist(ProbeTask probeTask) { + this.probeTaskDAO.save(probeTask); + } + + public List readAllByProbe(Probe probe) { + return this.probeTaskDAO.findAllByProbe(probe); + } +} diff --git a/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java b/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java new file mode 100644 index 0000000..fd2f07a --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java @@ -0,0 +1,61 @@ +package com.loafle.overflow.module.probe.service; + +import com.loafle.overflow.module.domain.model.Domain; +import com.loafle.overflow.module.meta.model.MetaProbeStatus; +import com.loafle.overflow.module.probe.model.Probe; +import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import org.junit.Assert; +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 ProbeServiceTest { + + @Autowired + private ProbeService probeService; + + @Test + public void regist() throws Exception { + + Probe probe = new Probe(); + + + probe.setDescription("snoop probe"); + + Domain domain = new Domain(); + domain.setId(1); + + probe.setDomain(domain); + + probe.setEncryptionKey("8c51fa9c5bcc11e7980a080027658d13"); + probe.setProbeKey("899fdd145bcc11e7b611080027658d13"); + + MetaProbeStatus status = new MetaProbeStatus(); + status.setId((short)1); + + probe.setStatus(status); + + this.probeService.regist(probe); + + Assert.assertNotEquals(probe.getId(), 0); + } + + @Test + public void readAllByDomain() throws Exception { + } + + @Test + public void readByProbeKey() throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/probe/service/ProbeTaskServiceTest.java b/src/test/java/com/loafle/overflow/module/probe/service/ProbeTaskServiceTest.java new file mode 100644 index 0000000..7e27885 --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/probe/service/ProbeTaskServiceTest.java @@ -0,0 +1,63 @@ +package com.loafle.overflow.module.probe.service; + +import com.loafle.overflow.module.meta.model.MetaProbeTaskType; +import com.loafle.overflow.module.probe.model.Probe; +import com.loafle.overflow.module.probe.model.ProbeTask; +import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import org.junit.Assert; +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.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class ProbeTaskServiceTest { + + @Autowired + private ProbeTaskService probeTaskService; + + @Test + public void regist() throws Exception { + + ProbeTask probeTask = new ProbeTask(); + + MetaProbeTaskType typeDiscovery = new MetaProbeTaskType(); + typeDiscovery.setId((short)1); + + probeTask.setMetaProbeTaskType(typeDiscovery); + probeTask.setData(""); + + Probe probe = new Probe(); + probe.setId(1); + + probeTask.setProbe(probe); + + this.probeTaskService.regist(probeTask); + + Assert.assertNotEquals(probeTask.getId(), 0); + } + + @Test + public void readAllByProbe() throws Exception { + + regist(); + + Probe probe = new Probe(); + probe.setId(1); + + List probeTasks = this.probeTaskService.readAllByProbe(probe); + + Assert.assertNotEquals(probeTasks.size(), 0 ); + } + +} \ No newline at end of file