fixed
target
This commit is contained in:
parent
f7742f4be8
commit
bee7eda0f0
|
@ -3,6 +3,7 @@ package com.loafle.overflow.module.target.dao;
|
|||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
|||
/**
|
||||
* Created by root on 17. 6. 5.
|
||||
*/
|
||||
@Repository
|
||||
public interface TargetDAO extends JpaRepository<Target, Long> {
|
||||
List<Target> findAllByProbe(Probe probe);
|
||||
// List<Target> findAllByProbe(Probe probe);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ public class Target {
|
|||
|
||||
private long id;
|
||||
private Date createDate;
|
||||
private Probe probe;
|
||||
private Infra infra;
|
||||
private String displayName;
|
||||
private String description;
|
||||
|
||||
/*
|
||||
private long id;
|
||||
|
@ -47,25 +47,44 @@ public class Target {
|
|||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PROBE_ID", nullable = false)
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
public Probe getProbe() {
|
||||
return probe;
|
||||
@Column(name = "DISPLAY_NAME")
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setProbe(Probe probe) {
|
||||
this.probe = probe;
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "INFRA_ID", nullable = false)
|
||||
public Infra getInfra() {
|
||||
return infra;
|
||||
@Column(name = "DESCRIPTION")
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setInfra(Infra infra) {
|
||||
this.infra = infra;
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "PROBE_ID", nullable = false)
|
||||
// @OnDelete(action = OnDeleteAction.CASCADE)
|
||||
// public Probe getProbe() {
|
||||
// return probe;
|
||||
// }
|
||||
//
|
||||
// public void setProbe(Probe probe) {
|
||||
// this.probe = probe;
|
||||
// }
|
||||
//
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "INFRA_ID", nullable = false)
|
||||
// public Infra getInfra() {
|
||||
// return infra;
|
||||
// }
|
||||
//
|
||||
// public void setInfra(Infra infra) {
|
||||
// this.infra = infra;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -75,8 +75,8 @@ public class TargetDiscoveryService {
|
|||
|
||||
if(host.isTarget()) {
|
||||
Target targetHost = new Target();
|
||||
targetHost.setInfra(infraByHost);
|
||||
targetHost.setProbe(probe);
|
||||
// targetHost.setInfra(infraByHost);
|
||||
// targetHost.setProbe(probe);
|
||||
this.targetDAO.save(targetHost);
|
||||
}
|
||||
|
||||
|
@ -126,8 +126,8 @@ public class TargetDiscoveryService {
|
|||
|
||||
if(service.isTarget()) {
|
||||
Target targetService = new Target();
|
||||
targetService.setInfra(infraByService);
|
||||
targetService.setProbe(probe);
|
||||
// targetService.setInfra(infraByService);
|
||||
// targetService.setProbe(probe);
|
||||
this.targetDAO.save(targetService);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ public class TargetService {
|
|||
return this.targetDAO.findOne(Long.valueOf(id));
|
||||
}
|
||||
|
||||
public List<Target> readAllByProbe(Probe probe) {
|
||||
return this.targetDAO.findAllByProbe(probe);
|
||||
}
|
||||
// public List<Target> readAllByProbe(Probe probe) {
|
||||
// return this.targetDAO.findAllByProbe(probe);
|
||||
// }
|
||||
|
||||
public void remove(Target target) {
|
||||
this.targetDAO.delete(target);
|
||||
|
|
|
@ -419,8 +419,8 @@ INSERT INTO public.infra (id,child_id,create_date,type_id) VALUES (
|
|||
INSERT INTO public.probe (id,authorized_date,cidr,create_date,description,display_name,encryption_key,probe_key,sensor_count,target_count,member_id,domain_id,host_id,status) VALUES (
|
||||
1,'2017-07-27 20:01:28.513','192.168.1.0/24','2017-07-27 20:01:28.513','snoop probe','test probe','8c51fa9c5bcc11e7980a080027658d13','899fdd145bcc11e7b611080027658d13',0,0,1,1,1,1);
|
||||
|
||||
INSERT INTO public.target (id,create_date,infra_id,probe_id) VALUES (
|
||||
1,'2017-06-26 12:37:22.854',1,1);
|
||||
INSERT INTO public.target (id,create_date,description,display_name) VALUES (
|
||||
1,'2017-07-27 20:18:09.555','i am target','ghost target');
|
||||
|
||||
INSERT INTO public.sensor (id,crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES (
|
||||
1,NULL,'2017-06-26 20:19:07.009','My sensor',1,1,1);
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.loafle.overflow.module.probe.model.Probe;
|
|||
import com.loafle.overflow.module.target.model.Target;
|
||||
import com.loafle.overflow.spring.AppConfig;
|
||||
import com.loafle.overflow.spring.JdbcConfiguration;
|
||||
import com.loafle.overflow.spring.MailConfiguration;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -18,9 +19,9 @@ import java.util.Date;
|
|||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
@Ignore
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class})
|
||||
public class TargetServiceTest {
|
||||
@Autowired
|
||||
TargetService targetService;
|
||||
|
@ -29,12 +30,14 @@ public class TargetServiceTest {
|
|||
public void regist() throws Exception {
|
||||
Target t = new Target();
|
||||
t.setCreateDate(new Date());
|
||||
Infra infra = new Infra();
|
||||
infra.setId(1);
|
||||
Probe probe = new Probe();
|
||||
probe.setId(1);
|
||||
t.setProbe(probe);
|
||||
t.setInfra(infra);
|
||||
// Infra infra = new Infra();
|
||||
// infra.setId(1);
|
||||
// Probe probe = new Probe();
|
||||
// probe.setId(1);
|
||||
// t.setProbe(probe);
|
||||
// t.setInfra(infra);
|
||||
t.setDescription("i am target");
|
||||
t.setDisplayName("ghost target");
|
||||
|
||||
Target res = this.targetService.regist(t);
|
||||
Assert.assertNotNull(res);
|
||||
|
|
Loading…
Reference in New Issue
Block a user