ing
This commit is contained in:
parent
2fd73e60cf
commit
816bb769f8
2
pom.xml
2
pom.xml
|
@ -51,7 +51,7 @@
|
|||
<dependency>
|
||||
<groupId>com.loafle.overflow</groupId>
|
||||
<artifactId>commons-java</artifactId>
|
||||
<version>1.0.74-SNAPSHOT</version>
|
||||
<version>1.0.77-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.loafle.overflow.model.infra.InfraHost;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
@ -9,4 +11,5 @@ import org.springframework.stereotype.Repository;
|
|||
*/
|
||||
@Repository
|
||||
public interface InfraHostDAO extends JpaRepository<InfraHost, Long> {
|
||||
List<InfraHost> findAllByInfraZoneId(Long infraZoneId);
|
||||
}
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||
import com.loafle.overflow.model.infra.InfraHostPort;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
|
@ -12,9 +14,14 @@ import org.springframework.stereotype.Repository;
|
|||
*/
|
||||
@Repository
|
||||
public interface InfraHostPortDAO extends JpaRepository<InfraHostPort, Long> {
|
||||
List<InfraHostPort> findAllByInfraHostIPId(Long infraHostIPId);
|
||||
@Query("SELECT ihp from InfraHostPort ihp where ihp.infraHostIP.id = :infraHostIPId")
|
||||
List<InfraHostPort> findAllByInfraHostIPId(@Param("infraHostIPId") Long infraHostIPId);
|
||||
|
||||
List<InfraHostPort> findAllByInfraHostIPIdAndMetaPortTypeId(Long infraHostIPId, Short metaPortTypeId);
|
||||
@Query("SELECT ihp from InfraHostPort ihp where ihp.infraHostIP.id = :infraHostIPId AND metaPortType.key = :metaPortTypeKey")
|
||||
List<InfraHostPort> findAllByInfraHostIPIdAndMetaPortTypeKey(@Param("infraHostIPId") Long infraHostIPId,
|
||||
@Param("metaPortTypeKey") Short metaPortTypeKey);
|
||||
|
||||
InfraHostPort findByInfraHostIPIdAndMetaPortTypeKeyAndPort(Long infraHostIPId, String metaPortTypeKey, Integer port);
|
||||
@Query("SELECT ihp from InfraHostPort ihp where ihp.infraHostIP.id = :infraHostIPId AND metaPortType.key = :metaPortTypeKey AND port = :port")
|
||||
InfraHostPort findByInfraHostIPIdAndMetaPortTypeKeyAndPort(@Param("infraHostIPId") Long infraHostIPId,
|
||||
@Param("metaPortTypeKey") String metaPortTypeKey, @Param("port") Integer port);
|
||||
}
|
|
@ -11,8 +11,8 @@ import org.springframework.stereotype.Repository;
|
|||
*/
|
||||
@Repository
|
||||
public interface InfraServiceDAO extends JpaRepository<InfraService, Long> {
|
||||
@Query("SELECT i from InfraService i where i.infraHostPort.infraHost.id = :infraHostId AND i.infraHostPort.metaPortType.key = :metaPortTypeKey AND i.infraHostPort.port = :port")
|
||||
InfraService findByInfraHostPortInfraHostIdAndInfraHostPortMetaPortTypeKeyAndInfraHostPortPort(
|
||||
@Param("infraHostId") Long infraHostId, @Param("metaPortTypeKey") String metaPortTypeKey,
|
||||
@Query("SELECT i from InfraService i where i.infraHostPort.infraHostIP.id = :infraHostIPId AND i.infraHostPort.metaPortType.key = :metaPortTypeKey AND i.infraHostPort.port = :port")
|
||||
InfraService findByInfraHostPortInfraHostIPIdAndInfraHostPortMetaPortTypeKeyAndInfraHostPortPort(
|
||||
@Param("infraHostIPId") Long infraHostIPId, @Param("metaPortTypeKey") String metaPortTypeKey,
|
||||
@Param("port") Integer port);
|
||||
}
|
||||
|
|
|
@ -358,4 +358,7 @@ public class CentralInfraService implements InfraService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<InfraHost> readAllInfraHostByInfraZoneID(Long infraZoneID) throws OverflowException {
|
||||
return this.infraHostDAO.findAllByInfraZoneId(infraZoneID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,15 +69,14 @@ INSERT INTO public.infra (infra_type, meta_infra_type_id, probe_id) VALUES (3, 3
|
|||
|
||||
INSERT INTO public.infra_zone (id, meta_target_zone_type_id, network, iface, meta_ip_type_id, "address", mac) VALUES (1, 1, '192.168.1.0/24', 'enp3s0', 1, '192.168.1.101', '44:8a:5b:f1:f1:f3');
|
||||
|
||||
INSERT INTO public.infra_host (id, infra_zone_id, meta_target_host_type_id) VALUES (2, 1, 127);
|
||||
INSERT INTO public.infra_host_machine (meta) VALUES ('{"vendor": "Micro-Star International Co., Ltd.", "product": "GP60 2QF (To be filled by O.E.M.)", "version": "REV:1.0", "serial": "9S716GH21875ZF1000339"}');
|
||||
|
||||
INSERT INTO public.infra_host_os ("name", os, platform, platform_family, platform_version, kernel_version, host_id) VALUES ('geek-ubuntu', 'linux', 'ubuntu', 'debian', '', '4.4.0-93-generic', '03000200-0400-0500-0006-000700080009');
|
||||
|
||||
INSERT INTO public.infra_host (id, infra_zone_id, meta_target_host_type_id, infra_host_machine_id, infra_host_os_id) VALUES (2, 1, 127, 1, 1);
|
||||
|
||||
INSERT INTO public.infra_host_ip (infra_host_id, meta_ip_type_id, "address", mac) VALUES (2, 1, '192.168.1.101', '44:8a:5b:f1:f1:f3');
|
||||
INSERT INTO public.infra_host_port (infra_host_id, meta_port_type_id, port) VALUES (2, 1, 5432);
|
||||
|
||||
|
||||
INSERT INTO public.infra_host_machine (infra_host_id, meta) VALUES (2, '{"vendor": "Micro-Star International Co., Ltd.", "product": "GP60 2QF (To be filled by O.E.M.)", "version": "REV:1.0", "serial": "9S716GH21875ZF1000339"}');
|
||||
|
||||
INSERT INTO public.infra_host_os (infra_host_id, "name", os, platform, platform_family, platform_version, kernel_version, host_id) VALUES (2, 'geek-ubuntu', 'linux', 'ubuntu', 'debian', '', '4.4.0-93-generic', '03000200-0400-0500-0006-000700080009');
|
||||
INSERT INTO public.infra_host_port (infra_host_ip_id, meta_port_type_id, port) VALUES (1, 1, 5432);
|
||||
|
||||
INSERT INTO public.infra_host_application (infra_host_id, "name") VALUES (2, 'Apache Httpd');
|
||||
|
||||
|
@ -91,7 +90,7 @@ INSERT INTO public.infra_host_daemon (infra_host_id, "name") VALUES (2, 'Postgre
|
|||
INSERT INTO public.infra_host_daemon (infra_host_id, "name") VALUES (2, 'MySQL');
|
||||
|
||||
|
||||
INSERT INTO public.infra_service (id, meta_target_service_type_id, infra_host_ip_id, infra_host_port_id) VALUES (3, 1035, 1, 1);
|
||||
INSERT INTO public.infra_service (id, meta_target_service_type_id, infra_host_port_id, meta_crypto_type_id) VALUES (3, 1035, 1, 1);
|
||||
|
||||
|
||||
INSERT INTO public.target (infra_id, "name", description, sensor_count, meta_target_type_id) VALUES (1, 'Zone', 'Zone Target', 1, 2);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.loafle.overflow.central.module.domain.service;
|
||||
|
||||
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
import com.loafle.overflow.model.domain.Domain;
|
||||
import org.junit.Assert;
|
||||
|
@ -11,12 +10,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 6. 28.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
@ContextConfiguration(classes = { AppConfigTest.class })
|
||||
public class DomainServiceTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,15 +1,33 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
import com.loafle.overflow.model.infra.InfraHost;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 7. 27.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
@ContextConfiguration(classes = { AppConfigTest.class })
|
||||
public class InfraServiceTest {
|
||||
|
||||
@Autowired
|
||||
private CentralInfraService infraService;
|
||||
|
||||
@Test
|
||||
public void readAllInfraHostByInfraZoneID() throws Exception {
|
||||
List<InfraHost> infraHosts = this.infraService.readAllInfraHostByInfraZoneID((long) 1);
|
||||
|
||||
assertNotNull(infraHosts);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user