From 51aa8e3c6ea5c5206b0e29dd7808cbe09c5d24ed Mon Sep 17 00:00:00 2001 From: snoop Date: Mon, 21 Aug 2017 14:46:54 +0900 Subject: [PATCH] remove InfraHost in Probe --- .../overflow/module/probe/model/Probe.java | 22 ++++++------ src/main/resources/init.sql | 36 +++++++++++++++++++ .../infra/service/InfraHostServiceTest.java | 15 ++++++-- .../InfraOSApplicationServiceTest.java | 9 +++-- .../service/InfraOSDaemonServiceTest.java | 10 ++++-- .../infra/service/InfraOSPortServiceTest.java | 8 ++++- .../service/InfraServiceServiceTest.java | 10 ++++-- 7 files changed, 89 insertions(+), 21 deletions(-) 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 fda96ae..470cd1b 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 @@ -28,7 +28,7 @@ public class Probe { private String cidr; private Date authorizeDate; private Member authorizeMember; - private InfraHost host; +// private InfraHost host; @Id @GeneratedValue(strategy= GenerationType.IDENTITY) @@ -155,14 +155,14 @@ public class Probe { public void setAuthorizeMember(Member authorizeMember) { this.authorizeMember = authorizeMember; } - - @ManyToOne - @JoinColumn(name = "HOST_ID", nullable = false) - public InfraHost getHost() { - return host; - } - - public void setHost(InfraHost host) { - this.host = host; - } +// +// @ManyToOne +// @JoinColumn(name = "HOST_ID", nullable = false) +// public InfraHost getHost() { +// return host; +// } +// +// public void setHost(InfraHost host) { +// this.host = host; +// } } diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index f4a1717..6367565 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -397,3 +397,39 @@ INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES ( INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( '52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1); + + +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +'INFRA_MACHINE','2017-08-21 12:59:10.244',1,NULL,NULL); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +'INFRA_OS','2017-08-21 13:05:24.883',3,NULL,NULL); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +'INFRA_HOST','2017-08-21 14:20:01.830',2,NULL,NULL); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +'INFRA_SERVICE','2017-08-21 14:24:26.525',7,NULL,NULL); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +'INFRA_OS_APPLICATION','2017-08-21 14:27:19.474',4,NULL,NULL); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +'INFRA_OS_DAEMON','2017-08-21 14:28:48.761',5,NULL,NULL); + + +INSERT INTO public.infra_machine (meta,id) VALUES ( +'i am a infra machine',1); + +INSERT INTO public.infra_os (meta,id,machine_id,vendor_id) VALUES ( +'',2,1,26); + +INSERT INTO public.infra_host (ip,mac,id,os_id) VALUES ( +3232235980,8796753988883,3,2); + +INSERT INTO public.infra_service (port,port_type,tls_type,id,host_id,vendor_id) VALUES ( +80,'TCP',false,4,3,45); + +INSERT INTO public.infra_os_application ("name",id,os_id) VALUES ( +'Apache',5,2); + +INSERT INTO public.infra_os_daemon ("name",id,os_id) VALUES ( +'Apache',6,2); + + + 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 index 5942192..5e8f999 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java @@ -3,6 +3,8 @@ 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.module.meta.model.MetaInfraType; +import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.spring.AppConfigTest; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; @@ -25,7 +27,7 @@ public class InfraHostServiceTest { private InfraHostService infraHostService; @Test - @Ignore +// @Ignore public void regist() throws Exception { InfraHost infraHost = new InfraHost(); @@ -34,9 +36,16 @@ public class InfraHostServiceTest { infraHost.setIp(3232235980L); InfraOS infraOS = new InfraOS(); - infraOS.setId(1); + infraOS.setId(2); + + infraHost.setOs(infraOS); + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(2); + + infraHost.setInfraType(metaInfraType); + -// infraHost.setOs(infraOS); this.infraHostService.regist(infraHost); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSApplicationServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSApplicationServiceTest.java index 7da3bd5..8c68fc7 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSApplicationServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSApplicationServiceTest.java @@ -2,6 +2,7 @@ package com.loafle.overflow.module.infra.service; import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOSApplication; +import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.spring.AppConfigTest; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; @@ -24,7 +25,7 @@ public class InfraOSApplicationServiceTest { @Autowired private InfraOSApplicationService infraOSApplicationService; - @Ignore +// @Ignore @Test public void regist() throws Exception { InfraOSApplication infraOSApplication = new InfraOSApplication(); @@ -32,10 +33,14 @@ public class InfraOSApplicationServiceTest { infraOSApplication.setName("Apache"); InfraOS infraOS = new InfraOS(); - infraOS.setId(1); + infraOS.setId(2); infraOSApplication.setOs(infraOS); + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(4); + infraOSApplication.setInfraType(metaInfraType); + this.infraOSApplicationService.regist(infraOSApplication); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSDaemonServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSDaemonServiceTest.java index 91b825a..bde4797 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSDaemonServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSDaemonServiceTest.java @@ -2,6 +2,7 @@ package com.loafle.overflow.module.infra.service; import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOSDaemon; +import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.spring.AppConfigTest; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; @@ -24,7 +25,7 @@ public class InfraOSDaemonServiceTest { @Autowired private InfraOSDaemonService infraOSDaemonService; - @Ignore +// @Ignore @Test public void regist() throws Exception { @@ -32,10 +33,15 @@ public class InfraOSDaemonServiceTest { infraOSDaemon.setName("Apache"); InfraOS infraOS = new InfraOS(); - infraOS.setId(1); + infraOS.setId(2); infraOSDaemon.setOs(infraOS); + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(5); + + infraOSDaemon.setInfraType(metaInfraType); + this.infraOSDaemonService.regist(infraOSDaemon); Assert.assertNotEquals(infraOSDaemon.getId(), 0); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSPortServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSPortServiceTest.java index 9c7474c..1b51ef8 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSPortServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSPortServiceTest.java @@ -2,6 +2,7 @@ package com.loafle.overflow.module.infra.service; import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOSPort; +import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.spring.AppConfigTest; import org.junit.Ignore; import org.junit.Test; @@ -22,7 +23,7 @@ public class InfraOSPortServiceTest { @Autowired private InfraOSPortService infraOSPortService; - @Ignore +// @Ignore @Test public void regist() throws Exception { @@ -33,6 +34,11 @@ public class InfraOSPortServiceTest { InfraOS infraOS = new InfraOS(); infraOS.setId(1); + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(2); + + infraOSPort.setInfraType(metaInfraType); + infraOSPort.setOs(infraOS); // FIXME::vendor??? diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceServiceTest.java index edc314a..e3a6c1f 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceServiceTest.java @@ -3,6 +3,7 @@ package com.loafle.overflow.module.infra.service; import com.loafle.overflow.module.infra.model.InfraHost; import com.loafle.overflow.module.infra.model.InfraService; +import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.spring.AppConfigTest; import org.junit.Assert; @@ -25,7 +26,7 @@ public class InfraServiceServiceTest { @Autowired private InfraServiceService infraServiceService; - @Ignore +// @Ignore @Test public void regist() throws Exception { @@ -35,7 +36,7 @@ public class InfraServiceServiceTest { infraService.setPortType("TCP"); InfraHost infraHost = new InfraHost(); - infraHost.setId(1); + infraHost.setId(3); infraService.setHost(infraHost); infraService.setTlsType(false); @@ -45,6 +46,11 @@ public class InfraServiceServiceTest { infraService.setVendor(metaInfraVendor); + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(7); + + infraService.setInfraType(metaInfraType); + this.infraServiceService.regist(infraService); Assert.assertNotEquals(infraService.getId(), 0);