From 02459e0de66fefbbd752ab89d85f027e16b0eb92 Mon Sep 17 00:00:00 2001 From: snoop Date: Mon, 21 Aug 2017 15:04:47 +0900 Subject: [PATCH] added sample data --- src/main/resources/init.sql | 21 ++++++++++---- .../probe/service/ProbeServiceTest.java | 28 +++++++++++++------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index 6367565..5893987 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -397,20 +397,27 @@ 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.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,sensor_count,target_count,authorize_member_id,domain_id,status) VALUES ( +'2017-08-21 14:48:31.563','192.168.1.0/24','2017-08-21 14:48:31.563','snoop probe','test probe 111111','8c51fa9c5bcc11e7980a080027658d13','899fdd145bcc11e7b611080027658d13',0,0,1,1,1); +INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,sensor_count,target_count,authorize_member_id,domain_id,status) VALUES ( +'2017-08-21 15:00:09.691','192.168.2.0/24','2017-08-21 15:00:09.691','insanity probe','test probe 22222','f1f72c8d2a814580bb7c4615ec43a6a8','95d8bcdc739741dca74c4a0e489e0774',0,0,1,1,1); + +INSERT INTO public.target (create_date,description,display_name) VALUES ( +'2017-07-27 20:18:09.555','i am target','ghost target'); 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); +'INFRA_MACHINE','2017-08-21 12:59:10.244',1,1,1); 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); +'INFRA_OS','2017-08-21 13:05:24.883',3,1,1); 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); +'INFRA_HOST','2017-08-21 14:20:01.830',2,1,1); 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); +'INFRA_SERVICE','2017-08-21 14:24:26.525',7,1,1); 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); +'INFRA_OS_APPLICATION','2017-08-21 14:27:19.474',4,1,1); 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); +'INFRA_OS_DAEMON','2017-08-21 14:28:48.761',5,1,1); INSERT INTO public.infra_machine (meta,id) VALUES ( @@ -433,3 +440,5 @@ INSERT INTO public.infra_os_daemon ("name",id,os_id) VALUES ( + + 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 7397ef4..a6b9730 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 @@ -15,6 +15,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.List; +import java.util.UUID; /** * Created by snoop on 17. 6. 28. @@ -26,7 +27,7 @@ public class ProbeServiceTest { @Autowired private ProbeService probeService; - @Ignore +// @Ignore @Test public void regist() throws Exception { @@ -40,8 +41,8 @@ public class ProbeServiceTest { probe.setDomain(domain); - probe.setEncryptionKey("8c51fa9c5bcc11e7980a080027658d13"); - probe.setProbeKey("899fdd145bcc11e7b611080027658d13"); + probe.setEncryptionKey(getUUID()); + probe.setProbeKey(getUUID()); MetaProbeStatus status = new MetaProbeStatus(); status.setId((short)1); @@ -50,7 +51,7 @@ public class ProbeServiceTest { probe.setTargetCount(0); probe.setSensorCount(0); - probe.setDisplayName("test probe"); + probe.setDisplayName("test probe 22222"); probe.setCidr("192.168.1.0/24"); // probe.setAuthorizedDate(new Date()); @@ -58,16 +59,27 @@ public class ProbeServiceTest { member.setId(1l); probe.setAuthorizeMember(member); - InfraHost infraHost = new InfraHost(); - infraHost.setId(1); - - probe.setHost(infraHost); +// InfraHost infraHost = new InfraHost(); +// infraHost.setId(1); +// +// probe.setHost(infraHost); this.probeService.regist(probe); Assert.assertNotEquals(probe.getId(), 0); } + public String getUUID() { + return UUID.randomUUID().toString().replaceAll("-", ""); + } + + @Test + public void tttt() { + String uuid = UUID.randomUUID().toString(); + String uuid2 = uuid.replaceAll("-", ""); + + System.out.println(uuid2); + } @Test public void readAllByDomain() throws Exception {