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.probe.model.Probe; | ||||||
| import com.loafle.overflow.module.target.model.Target; | import com.loafle.overflow.module.target.model.Target; | ||||||
| import org.springframework.data.jpa.repository.JpaRepository; | import org.springframework.data.jpa.repository.JpaRepository; | ||||||
|  | import org.springframework.stereotype.Repository; | ||||||
| 
 | 
 | ||||||
| import java.util.List; | import java.util.List; | ||||||
| 
 | 
 | ||||||
| @ -10,6 +11,7 @@ import java.util.List; | |||||||
| /** | /** | ||||||
|  * Created by root on 17. 6. 5. |  * Created by root on 17. 6. 5. | ||||||
|  */ |  */ | ||||||
|  | @Repository | ||||||
| public interface TargetDAO extends JpaRepository<Target, Long> { | 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 long id; | ||||||
|     private Date createDate; |     private Date createDate; | ||||||
|     private Probe probe; |     private String displayName; | ||||||
|     private Infra infra; |     private String description; | ||||||
| 
 | 
 | ||||||
|     /* |     /* | ||||||
|     private long id; |     private long id; | ||||||
| @ -47,25 +47,44 @@ public class Target { | |||||||
|         this.createDate = createDate; |         this.createDate = createDate; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @ManyToOne |     @Column(name = "DISPLAY_NAME") | ||||||
|     @JoinColumn(name = "PROBE_ID", nullable = false) |     public String getDisplayName() { | ||||||
|     @OnDelete(action = OnDeleteAction.CASCADE) |         return displayName; | ||||||
|     public Probe getProbe() { |  | ||||||
|         return probe; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setProbe(Probe probe) { |     public void setDisplayName(String displayName) { | ||||||
|         this.probe = probe; |         this.displayName = displayName; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @ManyToOne |     @Column(name = "DESCRIPTION") | ||||||
|     @JoinColumn(name = "INFRA_ID", nullable = false) |     public String getDescription() { | ||||||
|     public Infra getInfra() { |         return description; | ||||||
|         return infra; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setInfra(Infra infra) { |     public void setDescription(String description) { | ||||||
|         this.infra = infra; |         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()) { |             if(host.isTarget()) { | ||||||
|                 Target targetHost = new Target(); |                 Target targetHost = new Target(); | ||||||
|                 targetHost.setInfra(infraByHost); | //                targetHost.setInfra(infraByHost); | ||||||
|                 targetHost.setProbe(probe); | //                targetHost.setProbe(probe); | ||||||
|                 this.targetDAO.save(targetHost); |                 this.targetDAO.save(targetHost); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -126,8 +126,8 @@ public class TargetDiscoveryService { | |||||||
| 
 | 
 | ||||||
|                     if(service.isTarget()) { |                     if(service.isTarget()) { | ||||||
|                         Target targetService = new Target(); |                         Target targetService = new Target(); | ||||||
|                         targetService.setInfra(infraByService); | //                        targetService.setInfra(infraByService); | ||||||
|                         targetService.setProbe(probe); | //                        targetService.setProbe(probe); | ||||||
|                         this.targetDAO.save(targetService); |                         this.targetDAO.save(targetService); | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -25,9 +25,9 @@ public class TargetService { | |||||||
|         return this.targetDAO.findOne(Long.valueOf(id)); |         return this.targetDAO.findOne(Long.valueOf(id)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public List<Target> readAllByProbe(Probe probe) { | //    public List<Target> readAllByProbe(Probe probe) { | ||||||
|         return this.targetDAO.findAllByProbe(probe); | //        return this.targetDAO.findAllByProbe(probe); | ||||||
|     } | //    } | ||||||
| 
 | 
 | ||||||
|     public void remove(Target target) { |     public void remove(Target target) { | ||||||
|         this.targetDAO.delete(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 ( | 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); | 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 ( | INSERT INTO public.target (id,create_date,description,display_name) VALUES ( | ||||||
| 1,'2017-06-26 12:37:22.854',1,1); | 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 ( | 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); | 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.module.target.model.Target; | ||||||
| import com.loafle.overflow.spring.AppConfig; | import com.loafle.overflow.spring.AppConfig; | ||||||
| import com.loafle.overflow.spring.JdbcConfiguration; | import com.loafle.overflow.spring.JdbcConfiguration; | ||||||
|  | import com.loafle.overflow.spring.MailConfiguration; | ||||||
| import org.junit.Assert; | import org.junit.Assert; | ||||||
| import org.junit.Ignore; | import org.junit.Ignore; | ||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| @ -18,9 +19,9 @@ import java.util.Date; | |||||||
| /** | /** | ||||||
|  * Created by insanity on 17. 6. 28. |  * Created by insanity on 17. 6. 28. | ||||||
|  */ |  */ | ||||||
| @Ignore | 
 | ||||||
| @RunWith(SpringJUnit4ClassRunner.class) | @RunWith(SpringJUnit4ClassRunner.class) | ||||||
| @ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) | @ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class}) | ||||||
| public class TargetServiceTest { | public class TargetServiceTest { | ||||||
|     @Autowired |     @Autowired | ||||||
|     TargetService targetService; |     TargetService targetService; | ||||||
| @ -29,12 +30,14 @@ public class TargetServiceTest { | |||||||
|     public void regist() throws Exception { |     public void regist() throws Exception { | ||||||
|         Target t = new Target(); |         Target t = new Target(); | ||||||
|         t.setCreateDate(new Date()); |         t.setCreateDate(new Date()); | ||||||
|         Infra infra = new Infra(); | //        Infra infra = new Infra(); | ||||||
|         infra.setId(1); | //        infra.setId(1); | ||||||
|         Probe probe = new Probe(); | //        Probe probe = new Probe(); | ||||||
|         probe.setId(1); | //        probe.setId(1); | ||||||
|         t.setProbe(probe); | //        t.setProbe(probe); | ||||||
|         t.setInfra(infra); | //        t.setInfra(infra); | ||||||
|  |         t.setDescription("i am target"); | ||||||
|  |         t.setDisplayName("ghost target"); | ||||||
| 
 | 
 | ||||||
|         Target res = this.targetService.regist(t); |         Target res = this.targetService.regist(t); | ||||||
|         Assert.assertNotNull(res); |         Assert.assertNotNull(res); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user