From f7742f4be85fc01c971ba4af444f955709129ab0 Mon Sep 17 00:00:00 2001 From: snoop Date: Thu, 27 Jul 2017 20:12:36 +0900 Subject: [PATCH] fixed probe, infra --- .../module/infra/model/InfraMachine.java | 12 +- .../overflow/module/probe/model/Probe.java | 140 +++++++++++------- .../service/TargetDiscoveryService.java | 2 +- src/main/resources/init.sql | 103 +++++++------ .../infra/service/InfraHostServiceTest.java | 50 +++++++ .../service/InfraMachineServiceTest.java | 43 ++++++ .../infra/service/InfraOSServiceTest.java | 50 +++++++ .../infra/service/InfraServiceTest.java | 60 ++++++++ .../probe/service/ProbeServiceTest.java | 25 +++- 9 files changed, 369 insertions(+), 116 deletions(-) create mode 100644 src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/module/infra/service/InfraMachineServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/module/infra/service/InfraOSServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/module/infra/service/InfraServiceTest.java diff --git a/src/main/java/com/loafle/overflow/module/infra/model/InfraMachine.java b/src/main/java/com/loafle/overflow/module/infra/model/InfraMachine.java index ea5a846..101fbf6 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/InfraMachine.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/InfraMachine.java @@ -12,7 +12,7 @@ import java.util.Date; @Table(name = "INFRA_MACHINE", schema = "public", catalog = "postgres") public class InfraMachine { private long id; - private Probe probe; + private String meta; private Date createDate; @@ -32,16 +32,6 @@ public class InfraMachine { this.id = id; } - @ManyToOne - @JoinColumn(name = "PROBE_ID", nullable = false) - public Probe getProbe() { - return probe; - } - - public void setProbe(Probe probe) { - this.probe = probe; - } - @Basic @Column(name = "META", nullable = true, length = 255) public String getMeta() { diff --git a/src/main/java/com/loafle/overflow/module/probe/model/Probe.java b/src/main/java/com/loafle/overflow/module/probe/model/Probe.java index 962109b..e38c891 100644 --- a/src/main/java/com/loafle/overflow/module/probe/model/Probe.java +++ b/src/main/java/com/loafle/overflow/module/probe/model/Probe.java @@ -1,6 +1,8 @@ package com.loafle.overflow.module.probe.model; import com.loafle.overflow.module.domain.model.Domain; +import com.loafle.overflow.module.infra.model.InfraHost; +import com.loafle.overflow.module.member.model.Member; import com.loafle.overflow.module.meta.model.MetaProbeStatus; import javax.persistence.*; @@ -12,17 +14,8 @@ import java.util.Date; @Entity @Table(name = "PROBE", schema = "public", catalog = "postgres") public class Probe { - private long id; - private MetaProbeStatus status; - private String description; - private Date createDate; - private Date lastPollingDate; - private Date nextPollingDate; - private Domain domain; - private String probeKey; - private String encryptionKey; - /* + /* domain Domain target count int sensor count int @@ -39,6 +32,26 @@ encryptionKey String status (Meta) */ + private long id; + private MetaProbeStatus status; + private String description; + private Date createDate; + + private Domain domain; + private String probeKey; + private String encryptionKey; + +// private Date lastPollingDate; +// private Date nextPollingDate; + + private int targetCount; + private int sensorCount; + private String displayName; + private String cidr; + private Date authorizedDate; + private Member authorizedMember; + private InfraHost infraHost; + @Id @GeneratedValue(strategy= GenerationType.IDENTITY) public long getId() { @@ -79,26 +92,6 @@ status (Meta) this.createDate = createDate; } - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "LAST_POLLING_DATE", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") - public Date getLastPollingDate() { - return lastPollingDate; - } - - public void setLastPollingDate(Date lastPollingDate) { - this.lastPollingDate = lastPollingDate; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "NEXT_POLLING_DATE", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") - public Date getNextPollingDate() { - return nextPollingDate; - } - - public void setNextPollingDate(Date nextPollingDate) { - this.nextPollingDate = nextPollingDate; - } - @ManyToOne @JoinColumn(name = "DOMAIN_ID", nullable = false) public Domain getDomain() { @@ -129,28 +122,69 @@ status (Meta) this.encryptionKey = encryptionKey; } -// @Override -// public boolean equals(Object o) { -// if (this == o) return true; -// if (o == null || getClass() != o.getClass()) return false; -// -// Probe tblProbe = (Probe) o; -// -// if (id != tblProbe.id) return false; -// if (domain != tblProbe.domain) return false; -// if (status != null ? !status.equals(tblProbe.status) : tblProbe.status != null) return false; -// if (description != null ? !description.equals(tblProbe.description) : tblProbe.description != null) -// return false; -// if (createDate != null ? !createDate.equals(tblProbe.createDate) : tblProbe.createDate != null) return false; -// if (lastPollingDate != null ? !lastPollingDate.equals(tblProbe.lastPollingDate) : tblProbe.lastPollingDate != null) -// return false; -// if (nextPollingDate != null ? !nextPollingDate.equals(tblProbe.nextPollingDate) : tblProbe.nextPollingDate != null) -// return false; -// if (probeKey != null ? !probeKey.equals(tblProbe.probeKey) : tblProbe.probeKey != null) return false; -// if (encryptionKey != null ? !encryptionKey.equals(tblProbe.encryptionKey) : tblProbe.encryptionKey != null) -// return false; -// -// return true; -// } + @Column(name = "TARGET_COUNT", nullable = false) + public int getTargetCount() { + return targetCount; + } + public void setTargetCount(int targetCount) { + this.targetCount = targetCount; + } + + @Column(name = "SENSOR_COUNT", nullable = false) + public int getSensorCount() { + return sensorCount; + } + + public void setSensorCount(int sensorCount) { + this.sensorCount = sensorCount; + } + + @Column(name = "DISPLAY_NAME") + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + @Column(name = "CIDR") + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "AUTHORIZED_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) + public Date getAuthorizedDate() { + return authorizedDate; + } + + public void setAuthorizedDate(Date authorizedDate) { + this.authorizedDate = authorizedDate; + } + + @ManyToOne + @JoinColumn(name = "MEMBER_ID", nullable = false) + public Member getAuthorizedMember() { + return authorizedMember; + } + + public void setAuthorizedMember(Member authorizedMember) { + this.authorizedMember = authorizedMember; + } + + @ManyToOne + @JoinColumn(name = "HOST_ID", nullable = false) + public InfraHost getInfraHost() { + return infraHost; + } + + public void setInfraHost(InfraHost infraHost) { + this.infraHost = infraHost; + } } diff --git a/src/main/java/com/loafle/overflow/module/target/service/TargetDiscoveryService.java b/src/main/java/com/loafle/overflow/module/target/service/TargetDiscoveryService.java index 1a43b68..92df65c 100644 --- a/src/main/java/com/loafle/overflow/module/target/service/TargetDiscoveryService.java +++ b/src/main/java/com/loafle/overflow/module/target/service/TargetDiscoveryService.java @@ -48,7 +48,7 @@ public class TargetDiscoveryService { for(Host host : hosts) { InfraMachine infraMachine = new InfraMachine(); - infraMachine.setProbe(probe); +// infraMachine.setProbe(probe); this.infraMachineDAO.save(infraMachine); Infra infraByMachine = Infra.CreateInfraByType(infraMachine.getId(), InfraMachine.class); diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index baacdcd..9c73748 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -314,54 +314,6 @@ INSERT INTO public.meta_sensor_item (id,create_date,"key","name",type_id) VALUES INSERT INTO public.meta_sensor_item (id,create_date,"key","name",type_id) VALUES ( 4,'2017-06-26 20:10:08.394','mem.free','MEMORY FREE',2); --- --- --- --- --- -INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES ( -'loafle','2017-06-26 11:07:27.625','overflow@loafle.com','overFlow','000-000-0000','qwer5795',2); - -INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES ( -'loafle','2017-06-26 11:07:27.625','geek@loafle.com','geek','000-000-0000','qwer5795',1); - -INSERT INTO public.email_auth (auth_confirm_date,create_date,email_auth_key,member_id) VALUES ( -NULL,'2017-06-26 15:28:48.895','dbseogns1234',1); - -INSERT INTO public."domain" (create_date,"name") VALUES ( -'2017-06-26 11:25:44.866','overFlow''s domain'); - -INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES ( -'2017-06-26 11:27:43.023',1,1); - -INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( -'52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1); - -INSERT INTO public.noauth_probe (api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES ( -'52abd6fd57e511e7ac52080027658d13','2017-06-26 12:43:46.877','snoop',3232235980,8796753988883,'1cf2555c57d511e79714080027658d13',1,NULL,3); - -INSERT INTO public.probe (create_date,description,encryption_key,last_polling_date,next_polling_date,probe_key,domain_id,status) VALUES ( -'2017-06-26 12:44:59.813','snoop probe','9c8d41ab57de11e7a2c9080027658d13',NULL,NULL,'a1e1710557de11e78799080027658d13',1,1); - -INSERT INTO public.infra_machine (create_date,meta,probe_id) VALUES ( -'2017-06-26 12:12:11.698',NULL,1); - -INSERT INTO public.infra (child_id,create_date,type_id) VALUES ( -0,'2017-06-26 12:12:11.809',1); - -INSERT INTO public.target (create_date,infra_id,probe_id) VALUES ( -'2017-06-26 12:37:22.854',1,1); - -INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES ( -NULL,'2017-06-26 20:19:07.009','My sensor',1,1,1); -INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES ( -NULL,'2017-06-26 20:19:07.074','My sensor',1,1,1); - -INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( -'2017-06-26 20:21:16.626',1,1); -INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( -'2017-06-26 20:21:50.988',2,2); - INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( 1,'2017-07-27 15:29:48.634',23,26); INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( @@ -424,3 +376,58 @@ INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VAL 30,'2017-07-27 15:29:48.634',23,62); INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( 31,'2017-07-27 15:29:48.634',24,63); + + + +INSERT INTO public."member" (id,company_name,create_date,email,"name",phone,pw,status_id) VALUES ( +1,'loafle','2017-06-26 11:07:27.625','overflow@loafle.com','overFlow','000-000-0000','qwer5795',2); + +INSERT INTO public."member" (id,company_name,create_date,email,"name",phone,pw,status_id) VALUES ( +2,'loafle','2017-06-26 11:07:27.625','geek@loafle.com','geek','000-000-0000','qwer5795',1); + +INSERT INTO public.email_auth (auth_confirm_date,create_date,email_auth_key,member_id) VALUES ( +NULL,'2017-06-26 15:28:48.895','dbseogns1234',1); + +INSERT INTO public."domain" (create_date,"name") VALUES ( +'2017-06-26 11:25:44.866','overFlow''s domain'); + +INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES ( +'2017-06-26 11:27:43.023',1,1); + +INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( +'52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1); + +INSERT INTO public.noauth_probe (api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES ( +'52abd6fd57e511e7ac52080027658d13','2017-06-26 12:43:46.877','snoop',3232235980,8796753988883,'1cf2555c57d511e79714080027658d13',1,NULL,3); + +INSERT INTO public.infra_machine (id,create_date,meta) VALUES ( +1,'2017-07-27 19:54:26.677',''); + +INSERT INTO public.infra_os (id,create_date,meta,machine_id,vendor_id) VALUES ( +1,'2017-07-27 19:55:47.326','',1,26); + +INSERT INTO public.infra_host (id,create_date,ip,mac,os_id) VALUES ( +1,'2017-07-27 19:57:10.607',3232235980,8796753988883,1); + +INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES ( +1,1,'2017-07-27 20:10:41.458',1); +INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES ( +2,1,'2017-07-27 20:10:41.479',3); +INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES ( +3,1,'2017-07-27 20:10:41.506',2); + +INSERT INTO public.probe (id,authorized_date,cidr,create_date,description,display_name,encryption_key,probe_key,sensor_count,target_count,member_id,domain_id,host_id,status) VALUES ( +1,'2017-07-27 20:01:28.513','192.168.1.0/24','2017-07-27 20:01:28.513','snoop probe','test probe','8c51fa9c5bcc11e7980a080027658d13','899fdd145bcc11e7b611080027658d13',0,0,1,1,1,1); + +INSERT INTO public.target (id,create_date,infra_id,probe_id) VALUES ( +1,'2017-06-26 12:37:22.854',1,1); + +INSERT INTO public.sensor (id,crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES ( +1,NULL,'2017-06-26 20:19:07.009','My sensor',1,1,1); +INSERT INTO public.sensor (id,crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES ( +2,NULL,'2017-06-26 20:19:07.074','My sensor',1,1,1); + +INSERT INTO public.sensor_item (id,create_date,item_id,sensor_id) VALUES ( +1,'2017-06-26 20:21:16.626',1,1); +INSERT INTO public.sensor_item (id,create_date,item_id,sensor_id) VALUES ( +2,'2017-06-26 20:21:50.988',2,2); \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java new file mode 100644 index 0000000..0e09695 --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java @@ -0,0 +1,50 @@ +package com.loafle.overflow.module.infra.service; + +import com.loafle.overflow.module.infra.model.InfraHost; +import com.loafle.overflow.module.infra.model.InfraOS; +import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import com.loafle.overflow.spring.MailConfiguration; +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. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class}) +public class InfraHostServiceTest { + + @Autowired + private InfraHostService infraHostService; + + @Test + public void regist() throws Exception { + + InfraHost infraHost = new InfraHost(); + + infraHost.setMac(8796753988883L); + infraHost.setIp(3232235980L); + + InfraOS infraOS = new InfraOS(); + infraOS.setId(1); + + infraHost.setOs(infraOS); + + this.infraHostService.regist(infraHost); + + Assert.assertNotEquals(infraHost.getId(), 0 ); + + } + + @Test + public void read() throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraMachineServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraMachineServiceTest.java new file mode 100644 index 0000000..7902b0e --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraMachineServiceTest.java @@ -0,0 +1,43 @@ +package com.loafle.overflow.module.infra.service; + +import com.loafle.overflow.module.infra.model.InfraMachine; +import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import com.loafle.overflow.spring.MailConfiguration; +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. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class}) +public class InfraMachineServiceTest { + + @Autowired + private InfraMachineService infraMachineService; + + @Test + public void regist() throws Exception { + + InfraMachine infraMachine = new InfraMachine(); + + infraMachine.setMeta(""); + + this.infraMachineService.regist(infraMachine); + + Assert.assertNotEquals(infraMachine.getId(), 0); + + } + + @Test + public void read() throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSServiceTest.java new file mode 100644 index 0000000..d59f0a1 --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSServiceTest.java @@ -0,0 +1,50 @@ +package com.loafle.overflow.module.infra.service; + +import com.loafle.overflow.module.infra.model.InfraMachine; +import com.loafle.overflow.module.infra.model.InfraOS; +import com.loafle.overflow.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import com.loafle.overflow.spring.MailConfiguration; +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. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class}) +public class InfraOSServiceTest { + + @Autowired + private InfraOSService infraOSService; + + @Test + public void regist() throws Exception { + + InfraOS infraOS = new InfraOS(); + + MetaInfraVendor metaInfraVendor = new MetaInfraVendor(); + metaInfraVendor.setId(26); + + infraOS.setVendor(metaInfraVendor); + infraOS.setMeta(""); + + InfraMachine infraMachine = new InfraMachine(); + infraMachine.setId(1); + + infraOS.setMachine(infraMachine); + + this.infraOSService.regist(infraOS); + } + + @Test + public void read() throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceTest.java new file mode 100644 index 0000000..b28847c --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceTest.java @@ -0,0 +1,60 @@ +package com.loafle.overflow.module.infra.service; + +import com.loafle.overflow.module.infra.model.Infra; +import com.loafle.overflow.module.meta.model.MetaInfraType; +import com.loafle.overflow.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.JdbcConfiguration; +import com.loafle.overflow.spring.MailConfiguration; +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. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class}) +public class InfraServiceTest { + + @Autowired + private InfraService infraService; + + @Test + public void regist() throws Exception { + + long id =registInfra(1,1); + Assert.assertNotEquals(id, 0); + + id =registInfra(3,1); + Assert.assertNotEquals(id, 0); + + id =registInfra(2,1); + Assert.assertNotEquals(id, 0); + + + + } + + public long registInfra(int type, int childId) { + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(type); + + Infra infra = new Infra(); + infra.setType(metaInfraType); + infra.setChildId(childId); + + this.infraService.regist(infra); + return infra.getId(); + } + + @Test + public void read() throws Exception { + } + +} \ No newline at end of file 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 index 4baaab6..42e6db8 100644 --- a/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java @@ -1,10 +1,13 @@ package com.loafle.overflow.module.probe.service; import com.loafle.overflow.module.domain.model.Domain; +import com.loafle.overflow.module.infra.model.InfraHost; +import com.loafle.overflow.module.member.model.Member; 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 com.loafle.overflow.spring.MailConfiguration; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -13,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.Date; import java.util.List; import static org.junit.Assert.*; @@ -21,13 +25,13 @@ import static org.junit.Assert.*; * Created by snoop on 17. 6. 28. */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class}) public class ProbeServiceTest { @Autowired private ProbeService probeService; - @Ignore + @Test public void regist() throws Exception { @@ -49,12 +53,27 @@ public class ProbeServiceTest { probe.setStatus(status); + probe.setTargetCount(0); + probe.setSensorCount(0); + probe.setDisplayName("test probe"); + probe.setCidr("192.168.1.0/24"); +// probe.setAuthorizedDate(new Date()); + + Member member = new Member(); + member.setId(1l); + probe.setAuthorizedMember(member); + + InfraHost infraHost = new InfraHost(); + infraHost.setId(1); + + probe.setInfraHost(infraHost); + this.probeService.regist(probe); Assert.assertNotEquals(probe.getId(), 0); } - @Ignore + @Test public void readAllByDomain() throws Exception {