Collector

This commit is contained in:
insanity 2016-11-16 12:33:23 +09:00
parent d6e3450e2b
commit d4861a8c95
5 changed files with 117 additions and 38 deletions

View File

@ -1,4 +1,4 @@
package com.loafle.bridge.collector.entity;
package com.loafle.bridge.collector;
import javax.persistence.*;
import java.util.Date;
@ -7,14 +7,6 @@ import java.util.Date;
* Created by root on 16. 11. 15.
*/
enum License {
LICENSE1,
LICENSE2,
LICENSE3,
LICENSE4,
LICENSE5;
}
@Entity
public class Collector {
@ -25,14 +17,11 @@ public class Collector {
@Column(nullable = false)
private String productId;
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false)
private Date installedDate;
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
private Date updatedDate;
@Column(nullable = false)
private String version;
@Enumerated(EnumType.STRING)
private License licenseType;
private LicenseType licenseType;
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
private Date licenseDueDate;
@ -40,8 +29,11 @@ public class Collector {
@Column(nullable = false)
private String configPath;
@Column(nullable = false)
private String collectorVersion;
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false)
private Date installDate;
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
private Date updateDate;
public Collector() {
}
@ -62,19 +54,27 @@ public class Collector {
this.productId = productId;
}
public Date getInstalledDate() {
return installedDate;
public Date getInstallDate() {
return installDate;
}
public void setInstalledDate(Date installedDate) {
this.installedDate = installedDate;
public void setInstallDate(Date installDate) {
this.installDate = installDate;
}
public License getLicenseType() {
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public LicenseType getLicenseType() {
return licenseType;
}
public void setLicenseType(License licenseType) {
public void setLicenseType(LicenseType licenseType) {
this.licenseType = licenseType;
}
@ -94,19 +94,11 @@ public class Collector {
this.configPath = configPath;
}
public String getCollectorVersion() {
return collectorVersion;
public String getVersion() {
return version;
}
public void setCollectorVersion(String collectorVersion) {
this.collectorVersion = collectorVersion;
}
public Date getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
public void setVersion(String version) {
this.version = version;
}
}

View File

@ -1,4 +1,4 @@
package com.loafle.bridge.collector.controller;
package com.loafle.bridge.collector;
/**
* Created by root on 16. 11. 15.

View File

@ -1,6 +1,6 @@
package com.loafle.bridge.collector.repository;
package com.loafle.bridge.collector;
import com.loafle.bridge.collector.entity.Collector;
import com.loafle.bridge.collector.Collector;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

View File

@ -0,0 +1,21 @@
package com.loafle.bridge.collector;
/**
* Created by root on 16. 11. 16.
*/
public enum LicenseType {
LICENSE1("License 1"),
LICENSE2("License 2"),
LICENSE3("License 3"),
LICENSE4("License 4"),
LICENSE5("License 5");
private String stringValue;
LicenseType(String string) {stringValue = string;}
@Override
public String toString() {
return stringValue;
}
}

View File

@ -0,0 +1,66 @@
package com.loafle.bridge.collector;
import com.loafle.bridge.Application;
import org.apache.log4j.Logger;
import org.junit.After;
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;
import java.util.Date;
import static org.junit.Assert.assertEquals;
/**
* Created by root on 16. 11. 15.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = Application.class)
public class CollectorRepositoryTest {
@Autowired
private CollectorRepository repo;
Logger l = Logger.getLogger(this.getClass());
// @Before
// public void Before() {
// Collector c = new Collector();
// c.setCollectorVersion("1.0.0");
// c.setConfigPath("/root");
// c.setInstalledDate(new Date());
// c.setLicenseDueDate(new Date());
// c.setProductId("1111111");
// repo.save(c);
// }
@After
public void After() {
repo.deleteAll();
}
@Test
public void TestInsertPort() {
Collector c = new Collector();
c.setVersion("1.0.0");
c.setConfigPath("/root");
c.setInstallDate(new Date());
c.setUpdateDate(new Date());
c.setLicenseDueDate(new Date());
c.setProductId("1111111");
repo.save(c);
Collector res = repo.findOne(c.getId());
assertEquals(c.getId(),res.getId());
}
}