infraservice setting metainfraType, probe

This commit is contained in:
geek 2018-06-20 17:42:31 +09:00
parent 68153ce4ee
commit d1d9f96a48
2 changed files with 115 additions and 3 deletions

View File

@ -157,8 +157,8 @@ public class CentralInfraService implements InfraService {
}
InfraHost infraHost = new InfraHost();
infraZone.setMetaInfraType(MetaInfraType.Enum.HOST.to());
infraZone.setProbe(probe);
infraHost.setMetaInfraType(MetaInfraType.Enum.HOST.to());
infraHost.setProbe(probe);
infraHost.setInfraZone(infraZone);
infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to());
@ -247,6 +247,8 @@ public class CentralInfraService implements InfraService {
com.loafle.overflow.model.infra.InfraService infraService = new com.loafle.overflow.model.infra.InfraService();
infraService.setInfraHostPort(infraHostPort);
infraService.setMetaCryptoType(metaCryptoType);
infraService.setMetaInfraType(MetaInfraType.Enum.SERVICE.to());
infraService.setProbe(probe);
return this.infraServiceDAO.save(infraService);
}

View File

@ -0,0 +1,110 @@
package com.loafle.overflow.central.module.infra.service;
import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.discovery.Host;
import com.loafle.overflow.model.discovery.Port;
import com.loafle.overflow.model.discovery.Service;
import com.loafle.overflow.model.discovery.Zone;
import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.meta.MetaCryptoType;
import com.loafle.overflow.model.meta.MetaIPType;
import com.loafle.overflow.model.meta.MetaPortType;
import com.loafle.overflow.service.central.infra.InfraService;
import com.loafle.overflow.service.central.meta.MetaCryptoTypeService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("test")
@ContextConfiguration(classes = {AppConfigTest.class})
public class CentralInfraServiceTest {
@Autowired
InfraService infraService;
@Autowired
MetaCryptoTypeService metaCryptoTypeService;
// probeID, List<Host>, List<Service>
@Test
public void registDiscoverd() throws OverflowException {
List<Host> hosts = new ArrayList<>(5);
List<Service> services = new ArrayList<>(5);
List<Port> ports = new ArrayList<>(5);
Host host = null;
Service service = null;
Port port = null;
MetaCryptoType cryptoType = null;
Zone zone = new Zone();
zone.setAddress("192.168.10.101/24");
zone.setDiscoveredDate(new Date());
zone.setIface("enf03");
zone.setMac("44:8a:5b:44:8c:e4");
zone.setMetaIPType(MetaIPType.Enum.V4.to());
zone.setNetwork("192.168.10.0/24");
// for (int i = 1; i < 6; i++) {
host = new Host();
host.setMetaIPType(MetaIPType.Enum.V4.to());
host.getMetaIPType().setKey("V4");
host.setAddress("192.168.10.12");
host.setMac("44:8a:5b:44:8c:e7");
host.setDiscoveredDate(new Date());
host.setZone(zone);
for (int j = 24; j < 25; j ++) {
port = new Port();
port.setDiscoveredDate(new Date());
port.setHost(host);
port.setMetaPortType(MetaPortType.Enum.TCP.to());
port.setPortNumber(j);
for (int x = 24; x < 25; x ++) {
service = new Service();
cryptoType = new MetaCryptoType();
cryptoType.setKey("UNKNOWN");
cryptoType.setId(Short.valueOf((short)2));
cryptoType.setName("Unknown");
service.setMetaCryptoType(cryptoType);
service.setPort(port);
service.setDiscoveredDate(new Date());
service.setName("Unknown");
services.add(service);
}
port.setServiceList(services);
ports.add(port);
}
host.setPortList(ports);
hosts.add(host);
// }
List<Infra> infras = this.infraService.registDiscoverd(Long.valueOf((long)1), hosts, services);
System.out.println("CentralInfraServiceTest Infra List Size: " + infras.size());
}
@Test
public void readAllByProbeID() {
}
@Test
public void readAllByDomainID() {
}
@Test
public void readAllInfraByProbeID() {
}
}