fixed infra list for domain

This commit is contained in:
snoop 2017-08-21 16:09:45 +09:00
parent 02459e0de6
commit 1867f54c56
4 changed files with 39 additions and 89 deletions

View File

@ -18,11 +18,12 @@ import java.util.List;
public interface InfraDAO extends JpaRepository<Infra, Long> {
public List<Infra> findAllByProbe(Probe probe);
List<Infra> findAllByProbe(List<Probe> probeList);
@Query("SELECT i FROM INFRA i WHERE i.probe IN (:probeList)")
List<Infra> findAllByProbeList(@Param("probeList") List<Probe> probeList);
// @Query("SELECT DISTINCT i.target FROM Infra i WHERE i.probe IN (:probeList)")
// List<Target> findAllTargetByProbeList(@Param("probeList") List<Probe> probeList);
@Query("SELECT DISTINCT i.target FROM INFRA i WHERE i.probe IN (:probeList)")
List<Target> findAllTargetByProbeList(@Param("probeList") List<Probe> probeList);
// List<Infra> findAllByProbe(List<Probe> probeList);
}

View File

@ -40,15 +40,16 @@ public class InfraService {
List<Probe> probeList = this.probeService.readAllByDomain(domain);
return this.infraDAO.findAllByProbe(probeList);
return this.infraDAO.findAllByProbeList(probeList);
}
public List<Infra> readAllByProbeList(List<Probe> probeList) {
return this.infraDAO.findAllByProbe(probeList);
return this.infraDAO.findAllByProbeList(probeList);
}
public List<Target> readAllTargetByProbeList(List<Probe> probeList) {
// return this.infraDAO.findAllTargetByProbeList(probeList);
return null;
return this.infraDAO.findAllTargetByProbeList(probeList);
// return null;
}
}

View File

@ -47,7 +47,7 @@ public class InfraMachineServiceTest {
@Test
public void read() throws Exception {
regist();
// regist();
InfraMachine infraMachine = this.infraMachineService.read(1);

View File

@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.IOException;
import java.util.List;
/**
@ -36,91 +37,12 @@ public class InfraServiceTest {
private InfraMachineService infraMachineService;
// public void regist() throws Exception {
//
// long id =registInfra(7,1);
// Assert.assertNotEquals(id, 0);
//
//// id =registInfra(3,1);
//// Assert.assertNotEquals(id, 0);
////
//// id =registInfra(2,1);
//// Assert.assertNotEquals(id, 0);
//
//
//
// }
@Test
public void tttt() {
}
@Test
public void registInfraMachine() {
InfraMachine infraMachine = new InfraMachine();
infraMachine.setMeta("i am a inframachine");
// Assert.assertNotEquals(infraMachine.getId(), 0);
// Probe probe = new Probe();
// probe.setId(1);
//
// Target target = new Target();
// target.setId(1);
// Infra infra = new Infra();
// infra.setTarget(target);
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(1);
// infraMachine.setInfraType(metaInfraType);
// infra.setProbe(probe);
// infra.setInfraChild(infraMachine);
this.infraMachineService.regist(infraMachine);
// this.infraService.regist(infra);
// Assert.assertNotEquals(infra.getId(), 0);
}
@Test
public void registInfraOS() {
registInfraMachine();
}
//// @Ignore
// public long registInfra(int type, int childId) {
// MetaInfraType metaInfraType = new MetaInfraType();
// metaInfraType.setId(type);
//
// Infra infra = new Infra();
// infra.setInfraType(metaInfraType);
//// infra.setChildId(childId);
//
//
//
// Probe probe = new Probe();
// probe.setId(1);
//
// Target target = new Target();
// target.setId(1);
//
// infra.setProbe(probe);
// infra.setTarget(target);
//
// this.infraService.regist(infra);
//
// return infra.getId();
// }
@Test
public void read() throws Exception {
@ -136,7 +58,30 @@ public class InfraServiceTest {
}
@Test
public void readAllByProbeList() {
public void readAllProbe() throws IOException {
Probe probe = new Probe();
probe.setId(1);
List<Infra> infraList = this.infraService.readAllByProbe(probe);
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(infraList);
System.out.println(json);
}
@Test
public void readAllTarget() {
Domain domain = new Domain();
domain.setId(1);
// this.infraService.readAllTargetByProbeList()
}
@Test
public void readAllByProbeList() throws IOException {
Domain domain = new Domain();
domain.setId(1);
@ -144,7 +89,10 @@ public class InfraServiceTest {
List<Infra> fl = this.infraService.readAllByDomain(domain);
System.out.println(fl.size());
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(fl);
System.out.println(json);
}