This commit is contained in:
insanity 2016-11-17 17:26:31 +09:00
parent 3cdc4b2ccf
commit 51331fd9b6
4 changed files with 23 additions and 22 deletions

View File

@ -1,8 +1,5 @@
package com.loafle.bridge.collector; package com.loafle.bridge.collector;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
@ -24,18 +21,21 @@ public class Collector {
private String version; private String version;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(nullable = false)
private LicenseType licenseType; private LicenseType licenseType;
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") @Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false)
private Date licenseDueDate; private Date licenseDueDate;
@Column(nullable = false) @Column(nullable = false)
private String configPath; private String configPath;
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false) @Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false)
private Date installDate; private Date installDate;
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false) @Temporal(TemporalType.TIMESTAMP)
private Date updateDate; private Date updateDate;
public Collector() { public Collector() {

View File

@ -28,17 +28,17 @@ public class DiscoveryZone {
private DiscoveryHistory discovery; private DiscoveryHistory discovery;
@OneToMany(mappedBy = "zone", cascade = CascadeType.ALL) @OneToMany(mappedBy = "zone", cascade = CascadeType.ALL)
private List<HostScanHistory> hostScanHistories; private List<HostScanHistory> histories;
@OneToMany(mappedBy = "zone", cascade = CascadeType.ALL) @OneToMany(mappedBy = "zone", cascade = CascadeType.ALL)
private List<DiscoveryHost> discoveryHosts; private List<DiscoveryHost> discoveryHosts;
public List<HostScanHistory> getHostScanHistories() { public List<HostScanHistory> getHistories() {
return hostScanHistories; return histories;
} }
public void setHostScanHistories(List<HostScanHistory> hostScanHistories) { public void setHistories(List<HostScanHistory> histories) {
this.hostScanHistories = hostScanHistories; this.histories = histories;
} }
public List<DiscoveryHost> getDiscoveryHosts() { public List<DiscoveryHost> getDiscoveryHosts() {

View File

@ -16,6 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import java.util.Date; import java.util.Date;
import java.util.List;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@ -32,17 +33,13 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standal
@WebIntegrationTest @WebIntegrationTest
public class CollectorControllerTest { public class CollectorControllerTest {
Logger l = Logger.getLogger(this.getClass());
private MockMvc mockMvc; private MockMvc mockMvc;
@Autowired @Autowired
private CollectorRepository repo; private CollectorRepository repo;
@Autowired @Autowired
private CollectorController controller; private CollectorController controller;
Logger l = Logger.getLogger(this.getClass());
@Before @Before
public void Before() { public void Before() {
@ -81,5 +78,14 @@ public class CollectorControllerTest {
} }
@Test
public void TestGelAllCollector() throws Exception {
List<Collector> list = repo.findAll();
String jsonString = jsonStringFromObject(list);
System.out.println(list);
}
} }

View File

@ -2,21 +2,16 @@ package com.loafle.bridge.discoveryzone;
import com.loafle.bridge.Application; import com.loafle.bridge.Application;
import org.junit.After; import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static org.junit.Assert.*;
/** /**
* Created by snoop on 16. 11. 16. * Created by snoop on 16. 11. 16.
*/ */
@ -102,7 +97,7 @@ public class DiscoveryZoneRepositoryTest {
} }
zone.setHostScanHistories(hostScanHistories); zone.setHistories(hostScanHistories);
discoveryZoneRepository.save(zone); discoveryZoneRepository.save(zone);