Merge remote-tracking branch 'origin/master'

This commit is contained in:
geek 2017-06-28 15:36:23 +09:00
commit ba809a27f5
5 changed files with 168 additions and 0 deletions

View File

@ -0,0 +1,67 @@
package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.dao.*;
import com.loafle.overflow.module.infra.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by insanity on 17. 6. 28.
*/
@Service
public class InfraService {
@Autowired
InfraDAO infraDAO;
@Autowired
InfraMachineDAO infraMachineDAO;
@Autowired
InfraHostDAO infraHostDAO;
@Autowired
InfraOSDAO infraOSDAO;
@Autowired
InfraOSApplicationDAO infraOSApplicationDAO;
@Autowired
InfraOSDaemonDAO infraOSDaemonDAO;
@Autowired
InfraOSPortDAO infraOSPortDAO;
@Autowired
InfraServiceDAO infraServiceDAO;
public Infra regist(Infra infra) {
return this.infraDAO.save(infra);
}
public InfraMachine registMachine(InfraMachine infraMachine) {
return this.infraMachineDAO.save(infraMachine);
}
public InfraHost registHost(InfraHost infraHost) {
return this.infraHostDAO.save(infraHost);
}
public InfraOS registOS(InfraOS infraOS) {
return this.infraOSDAO.save(infraOS);
}
public InfraOSApplication registOSApplication(InfraOSApplication infraOSApplication) {
return this.infraOSApplicationDAO.save(infraOSApplication);
}
public InfraOSDaemon registOSDaemon(InfraOSDaemon infraOSDaemon) {
return this.infraOSDaemonDAO.save(infraOSDaemon);
}
public InfraOSPort registOSPort(InfraOSPort infraOSPort) {
return this.infraOSPortDAO.save(infraOSPort);
}
public com.loafle.overflow.module.infra.model.InfraService registService(com.loafle.overflow.module.infra.model.InfraService infraService) {
return this.infraServiceDAO.save(infraService);
}
public Infra read(String id) {
return this.infraDAO.findOne(Long.valueOf(id));
}
}

View File

@ -1,15 +1,18 @@
package com.loafle.overflow.module.sensor.service;
import com.loafle.overflow.module.meta.model.MetaSensorStatus;
import com.loafle.overflow.module.sensor.dao.SensorDAO;
import com.loafle.overflow.module.sensor.model.Sensor;
import com.loafle.overflow.module.target.model.Target;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by insanity on 17. 6. 28.
*/
@Service
public class SensorService {
@Autowired
@ -30,4 +33,16 @@ public class SensorService {
public void remove(Sensor sensor) {
this.sensorDAO.delete(sensor);
}
public Sensor start(Sensor sensor) {
MetaSensorStatus status = new MetaSensorStatus((short)1);
sensor.setStatus(status);
return this.sensorDAO.save(sensor);
}
public Sensor stop(Sensor sensor) {
MetaSensorStatus status = new MetaSensorStatus((short)2);
sensor.setStatus(status);
return this.sensorDAO.save(sensor);
}
}

View File

@ -0,0 +1,8 @@
package com.loafle.overflow.module.target.service;
/**
* Created by insanity on 17. 6. 28.
*/
public class TargetDiscoveryService {
}

View File

@ -4,12 +4,14 @@ import com.loafle.overflow.module.probe.model.Probe;
import com.loafle.overflow.module.target.dao.TargetDAO;
import com.loafle.overflow.module.target.model.Target;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by insanity on 17. 6. 28.
*/
@Service
public class TargetService {
@Autowired

View File

@ -0,0 +1,76 @@
package com.loafle.overflow.module.noauthprobe.service;
import com.loafle.overflow.module.domain.model.Domain;
import com.loafle.overflow.module.meta.model.MetaNoAuthProbeStatus;
import com.loafle.overflow.module.noauthprobe.model.NoAuthProbe;
import com.loafle.overflow.spring.AppConfig;
import com.loafle.overflow.spring.JdbcConfiguration;
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 java.util.List;
import static org.junit.Assert.*;
/**
* Created by snoop on 17. 6. 28.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
public class NoAuthProbeServiceTest {
@Autowired
private NoAuthProbeService noAuthProbeService;
@Test
public void regist() throws Exception {
NoAuthProbe noAuthProbe = new NoAuthProbe();
noAuthProbe.setHostName("snoop");
noAuthProbe.setIpAddress(3232235980L);
noAuthProbe.setMacAddress(8796753988883L);
noAuthProbe.setApiKey("52abd6fd57e511e7ac52080027658d13");
MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus();
metaNoAuthProbeStatus.setId((short)3);
noAuthProbe.setStatus(metaNoAuthProbeStatus);
noAuthProbe.setTempProbeKey("ac7f252b5bc811e784ad080027658d13");
Domain d = new Domain();
d.setId(1);
noAuthProbe.setDomain(d);
this.noAuthProbeService.regist(noAuthProbe);
Assert.assertNotEquals(noAuthProbe.getId(), 0);
}
@Test
public void readAllByDomain() throws Exception {
Domain domain = new Domain();
domain.setId(1);
List<NoAuthProbe> probes = this.noAuthProbeService.readAllByDomain(domain);
Assert.assertNotEquals(probes.size(), 0);
}
@Test
public void read() throws Exception {
NoAuthProbe noAuthProbe = this.noAuthProbeService.read(1);
Assert.assertNotEquals(noAuthProbe, null);
}
}