sensor item
This commit is contained in:
parent
1f69042bac
commit
65784514d0
|
@ -2,13 +2,16 @@ package com.loafle.overflow.module.sensor.dao;
|
|||
|
||||
|
||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 9.
|
||||
*/
|
||||
@Repository
|
||||
public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
||||
|
||||
List<Sensor> findAllByTarget(Target target);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package com.loafle.overflow.module.sensor.dao;
|
||||
|
||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.module.sensor.model.SensorItem;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 9.
|
||||
*/
|
||||
@Repository
|
||||
public interface SensorItemDAO extends JpaRepository<SensorItem, Long> {
|
||||
|
||||
// List<SensorItem> findAllByCrawlerId(Crawler crawler);
|
||||
List<SensorItem> findAllBySensor(Sensor sensor);
|
||||
}
|
||||
|
|
|
@ -60,12 +60,6 @@ public class DBProxy {
|
|||
daoMap.put("infraOSDaemon", ctx.getBean(InfraOSDaemonDAO.class));
|
||||
daoMap.put("infraOSPort", ctx.getBean(InfraOSPortDAO.class));
|
||||
daoMap.put("infraService", ctx.getBean(InfraServiceDAO.class));
|
||||
|
||||
// daoMap.put("crawler", crawlerDAO);
|
||||
// daoMap.put("crawlerInputItem", crawlerInputItemDAO);
|
||||
// daoMap.put("crawlerInputItemMapping", crawlerInputItemMappingDAO);
|
||||
// daoMap.put("sensorItemCategory", sensorItemCategoryDao);
|
||||
// daoMap.put("sensorItemMapping", sensorItemMappingDao);
|
||||
}
|
||||
|
||||
public void start(int port) throws IOException {
|
||||
|
|
|
@ -189,6 +189,41 @@ INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,vers
|
|||
INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES (
|
||||
16,'2017-06-25 16:59:59.522',2,4,2);
|
||||
|
||||
INSERT INTO public.meta_probe_status (id,"name") VALUES (
|
||||
1,'INITIAL');
|
||||
INSERT INTO public.meta_probe_status (id,"name") VALUES (
|
||||
2,'NORMAL');
|
||||
|
||||
INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES (
|
||||
1,'ACCEPT');
|
||||
INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES (
|
||||
2,'DENY');
|
||||
INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES (
|
||||
3,'PROCESS');
|
||||
|
||||
INSERT INTO public.meta_probe_task_type (id,create_date,description,"name") VALUES (
|
||||
1,'2017-06-26 15:58:02.397','DISCOVERY START','DISCOVERY');
|
||||
|
||||
INSERT INTO public.meta_sensor_status (id,"name") VALUES (
|
||||
1,'RUNNING');
|
||||
INSERT INTO public.meta_sensor_status (id,"name") VALUES (
|
||||
2,'STOPPED');
|
||||
|
||||
INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES (
|
||||
1,'2017-06-26 19:49:39.690','CPU blah blah blah','CPU');
|
||||
INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES (
|
||||
2,'2017-06-26 19:49:39.811','MEMORY blah blah blah','MEMORY');
|
||||
INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES (
|
||||
3,'2017-06-26 19:49:39.824','DISK blah blah blah','DISK');
|
||||
|
||||
INSERT INTO public.meta_sensor_item (id,create_date,"key","name",type_id) VALUES (
|
||||
1,'2017-06-26 20:10:08.269','cpu.usage','CPU USAGE',1);
|
||||
INSERT INTO public.meta_sensor_item (id,create_date,"key","name",type_id) VALUES (
|
||||
2,'2017-06-26 20:10:08.361','cpu.free','CPU FREE',1);
|
||||
INSERT INTO public.meta_sensor_item (id,create_date,"key","name",type_id) VALUES (
|
||||
3,'2017-06-26 20:10:08.376','mem.usage','MEMORY USAGE',2);
|
||||
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);
|
||||
|
||||
--
|
||||
--
|
||||
|
@ -210,30 +245,15 @@ INSERT INTO public."domain" (id,create_date,"name") VALUES (
|
|||
INSERT INTO public.domain_member (id,create_date,domain_id,member_id) VALUES (
|
||||
1,'2017-06-26 11:27:43.023',1,1);
|
||||
|
||||
|
||||
INSERT INTO public.meta_probe_status (id,"name") VALUES (
|
||||
1,'INITIAL');
|
||||
INSERT INTO public.meta_probe_status (id,"name") VALUES (
|
||||
2,'NORMAL');
|
||||
|
||||
INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES (
|
||||
1,'ACCEPT');
|
||||
INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES (
|
||||
2,'DENY');
|
||||
INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES (
|
||||
3,'PROCESS');
|
||||
|
||||
INSERT INTO public.api_key (id,api_key,create_date,domain_id) VALUES (
|
||||
1,'52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1);
|
||||
|
||||
|
||||
INSERT INTO public.noauth_probe (id,api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES (
|
||||
1,'52abd6fd57e511e7ac52080027658d13','2017-06-26 12:43:46.877','snoop',3232235980,8796753988883,'1cf2555c57d511e79714080027658d13',1,NULL,3);
|
||||
|
||||
INSERT INTO public.probe (id,create_date,description,encryption_key,last_polling_date,next_polling_date,probe_key,domain_id,status) VALUES (
|
||||
1,'2017-06-26 12:44:59.813','snoop probe','9c8d41ab57de11e7a2c9080027658d13',NULL,NULL,'a1e1710557de11e78799080027658d13',1,1);
|
||||
|
||||
|
||||
INSERT INTO public.infra_machine (id,create_date,meta,probe_id) VALUES (
|
||||
0,'2017-06-26 12:12:11.698',NULL,1);
|
||||
|
||||
|
@ -243,10 +263,3 @@ INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES (
|
|||
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.meta_probe_task_type (id,create_date,description,"name") VALUES (
|
||||
1,'2017-06-26 15:58:02.397','DISCOVERY START','DISCOVERY');
|
||||
|
||||
INSERT INTO public.meta_sensor_status (id,"name") VALUES (
|
||||
1,'RUNNING');
|
||||
INSERT INTO public.meta_sensor_status (id,"name") VALUES (
|
||||
2,'STOPPED');
|
|
@ -0,0 +1,66 @@
|
|||
package com.loafle.overflow.meta.dao;
|
||||
|
||||
import com.loafle.overflow.AppConfig;
|
||||
import com.loafle.overflow.JdbcConfiguration;
|
||||
import com.loafle.overflow.meta.model.MetaSensorItem;
|
||||
import com.loafle.overflow.meta.model.MetaSensorItemType;
|
||||
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 java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 6. 26.
|
||||
*/
|
||||
@Ignore
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
||||
public class MetaSensorItemDAOTest {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorItemDAO dao;
|
||||
|
||||
@Test
|
||||
public void Create() {
|
||||
MetaSensorItemType cpuType = new MetaSensorItemType();
|
||||
cpuType.setId((short)1);
|
||||
|
||||
MetaSensorItemType memType = new MetaSensorItemType();
|
||||
memType.setId((short)2);
|
||||
|
||||
MetaSensorItem item1 = new MetaSensorItem();
|
||||
item1.setMetaSensorItemType(cpuType);
|
||||
item1.setKey("cpu.usage");
|
||||
item1.setName("CPU USAGE");
|
||||
item1.setCreateDate(new Date());
|
||||
dao.save(item1);
|
||||
|
||||
MetaSensorItem item2 = new MetaSensorItem();
|
||||
item2.setMetaSensorItemType(cpuType);
|
||||
item2.setKey("cpu.free");
|
||||
item2.setName("CPU FREE");
|
||||
item2.setCreateDate(new Date());
|
||||
dao.save(item2);
|
||||
|
||||
MetaSensorItem item3 = new MetaSensorItem();
|
||||
item3.setMetaSensorItemType(memType);
|
||||
item3.setKey("mem.usage");
|
||||
item3.setName("MEMORY USAGE");
|
||||
item3.setCreateDate(new Date());
|
||||
dao.save(item3);
|
||||
|
||||
MetaSensorItem item4 = new MetaSensorItem();
|
||||
item4.setMetaSensorItemType(memType);
|
||||
item4.setKey("mem.free");
|
||||
item4.setName("MEMORY FREE");
|
||||
item4.setCreateDate(new Date());
|
||||
dao.save(item4);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.loafle.overflow.meta.dao;
|
||||
|
||||
import com.loafle.overflow.AppConfig;
|
||||
import com.loafle.overflow.JdbcConfiguration;
|
||||
import com.loafle.overflow.meta.model.MetaSensorItemType;
|
||||
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.Date;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 6. 26.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
||||
public class MetaSensorItemTypeDAOTest {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorItemTypeDAO dao;
|
||||
|
||||
@Test
|
||||
public void Create() {
|
||||
MetaSensorItemType category1 = new MetaSensorItemType();
|
||||
category1.setId((short)1);
|
||||
category1.setCreateDate(new Date());
|
||||
category1.setName("CPU");
|
||||
category1.setDescription("CPU blah blah blah");
|
||||
dao.save(category1);
|
||||
|
||||
MetaSensorItemType category2 = new MetaSensorItemType();
|
||||
category2.setId((short)2);
|
||||
category2.setCreateDate(new Date());
|
||||
category2.setName("MEMORY");
|
||||
category2.setDescription("MEMORY blah blah blah");
|
||||
dao.save(category2);
|
||||
|
||||
MetaSensorItemType category3 = new MetaSensorItemType();
|
||||
category3.setId((short)3);
|
||||
category3.setCreateDate(new Date());
|
||||
category3.setName("DISK");
|
||||
category3.setDescription("DISK blah blah blah");
|
||||
dao.save(category3);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,16 +7,16 @@ import com.loafle.overflow.meta.model.MetaCrawlerInputItem;
|
|||
import com.loafle.overflow.meta.model.MetaSensorStatus;
|
||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.*;
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Ignore
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
||||
public class SensorDAOTest {
|
||||
|
@ -27,6 +27,7 @@ public class SensorDAOTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
create();
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -58,5 +59,12 @@ public class SensorDAOTest {
|
|||
sensorDAO.save(sensor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void list() {
|
||||
Target t = new Target();
|
||||
t.setId(1);
|
||||
List<Sensor> sensors = this.sensorDAO.findAllByTarget(t);
|
||||
Assert.assertEquals(2, sensors.size());
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import com.loafle.overflow.module.infra.model.Infra;
|
|||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Ignore
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
||||
public class TargetDAOTest {
|
||||
|
|
Loading…
Reference in New Issue
Block a user