Merge remote-tracking branch 'origin/master'

This commit is contained in:
geek 2018-06-28 20:10:18 +09:00
commit 3eb3a718ca
3 changed files with 53 additions and 5 deletions

View File

@ -58,4 +58,8 @@ public class CentralSensorItemService implements SensorItemService {
this.sensorItemDAO.deleteById(sensorItemID); this.sensorItemDAO.deleteById(sensorItemID);
} }
public void removeAllBySensorID(Long sensorID) throws OverflowException {
this.sensorItemDAO.deleteAll(this.readAllBySensorID(sensorID));
}
} }

View File

@ -57,8 +57,15 @@ public class CentralSensorService implements SensorService {
@Transactional @Transactional
@Override @Override
public Sensor modify(Long sensorID, List<MetaDisplayItemMapping> metaDisplayItemMappings) throws OverflowException { public Sensor modify(Long sensorID, List<MetaDisplayItemMapping> metaDisplayItemMappings) throws OverflowException {
// FIXME : not impl Sensor sensor = this.read(sensorID);
return null; if (null == sensor) {
throw new OverflowException(String.format("ID[%d] of Sensor is not valid", sensorID));
}
this.sensorItemService.readAllBySensorID(sensorID);
for (MetaDisplayItemMapping metaDisplayItemMapping : metaDisplayItemMappings) {
this.sensorItemService.regist(sensor, metaDisplayItemMapping);
}
return sensor;
} }
@Override @Override

View File

@ -1,8 +1,13 @@
package com.loafle.overflow.central.module.sensor.service; package com.loafle.overflow.central.module.sensor.service;
import com.loafle.overflow.central.module.meta.dao.MetaCrawlerMappingDAO;
import com.loafle.overflow.central.module.meta.dao.MetaDisplayItemMappingDAO; import com.loafle.overflow.central.module.meta.dao.MetaDisplayItemMappingDAO;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
import com.loafle.overflow.model.meta.MetaCrawlerMapping;
import com.loafle.overflow.model.sensor.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.target.Target; import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.service.central.sensor.SensorService; import com.loafle.overflow.service.central.sensor.SensorService;
@ -30,9 +35,8 @@ public class SensorServiceTest {
@Autowired @Autowired
MetaDisplayItemMappingDAO metaDisplayItemMappingService; MetaDisplayItemMappingDAO metaDisplayItemMappingService;
@Autowired @Autowired
ObjectMapper objectMapper; MetaCrawlerMappingDAO metaCrawlerMappingDAO;
@Test @Test
@Ignore @Ignore
@ -42,7 +46,40 @@ public class SensorServiceTest {
Sensor sensor = new Sensor(); Sensor sensor = new Sensor();
sensor.setTarget(target); sensor.setTarget(target);
List<MetaCrawlerMapping> metaCrawlerMappings = this.metaCrawlerMappingDAO.findAll();
sensor.setMetaCrawlerMapping(metaCrawlerMappings.get(0));
Sensor result = this.sensorService.regist(sensor, this.metaDisplayItemMappingService.findAll()); Sensor result = this.sensorService.regist(sensor, this.metaDisplayItemMappingService.findAll());
Assert.assertNotNull(result); Assert.assertNotNull(result);
} }
@Test
@Ignore
public void readAllByTargetID() throws Exception {
this.regist();
Assert.assertNotNull(this.sensorService.readAllByTargetID(Long.valueOf(1)));
}
@Test
@Ignore
public void readAllByTargetIn() throws Exception {
this.regist();
List<Target> targets = new ArrayList<Target>();
Target t1 = new Target();
t1.setId(Long.valueOf(1));
Target t2 = new Target();
t2.setId(Long.valueOf(2));
targets.add(t1);
targets.add(t2);
List<Sensor> sensors = this.sensorService.readAllByTargetIn(targets);
Assert.assertNotNull(sensors);
}
@Test
@Ignore
public void readAllByTargetInfraProbeID() throws Exception {
this.regist();
List<Sensor> sensors = this.sensorService.readAllByTargetInfraProbeID(Long.valueOf(1));
Assert.assertNotNull(sensors);
}
} }