diff --git a/src/main/java/com/loafle/overflow/meta/model/MetaInfraVendor.java b/src/main/java/com/loafle/overflow/meta/model/MetaInfraVendor.java index 2e69bd4..f2022d0 100644 --- a/src/main/java/com/loafle/overflow/meta/model/MetaInfraVendor.java +++ b/src/main/java/com/loafle/overflow/meta/model/MetaInfraVendor.java @@ -34,7 +34,7 @@ public class MetaInfraVendor { } @Temporal(TemporalType.TIMESTAMP) - @Column(name = "CREATE_DATE", nullable = false) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Date getCreateDate() { return createDate; } diff --git a/src/main/java/com/loafle/overflow/module/probe/model/ProbeTask.java b/src/main/java/com/loafle/overflow/module/probe/model/ProbeTask.java index f1eabda..338aeca 100644 --- a/src/main/java/com/loafle/overflow/module/probe/model/ProbeTask.java +++ b/src/main/java/com/loafle/overflow/module/probe/model/ProbeTask.java @@ -60,6 +60,7 @@ public class ProbeTask { this.data = data; } + @Temporal(TemporalType.TIMESTAMP) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Date getCreateDate() { return createDate; diff --git a/src/test/java/com/loafle/overflow/meta/dao/MetaInfraVendorDAOTest.java b/src/test/java/com/loafle/overflow/meta/dao/MetaInfraVendorDAOTest.java new file mode 100644 index 0000000..7b01e69 --- /dev/null +++ b/src/test/java/com/loafle/overflow/meta/dao/MetaInfraVendorDAOTest.java @@ -0,0 +1,70 @@ +package com.loafle.overflow.meta.dao; + +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.meta.model.MetaInfraType; +import com.loafle.overflow.meta.model.MetaInfraVendor; +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.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 6. 26. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class MetaInfraVendorDAOTest { + + @Autowired + private MetaInfraVendorDAO metaInfraVendorDAO; + + @Test + public void create() { + + MetaInfraType typeApp = new MetaInfraType(); + typeApp.setId(7); + + MetaInfraVendor vendorMySQL = new MetaInfraVendor(); + vendorMySQL.setMetaInfraType(typeApp); + vendorMySQL.setName("MySql"); + + MetaInfraVendor vendorPost = new MetaInfraVendor(); + vendorPost.setMetaInfraType(typeApp); + vendorPost.setName("PostgreSQL"); + + MetaInfraVendor vendorWMI = new MetaInfraVendor(); + vendorWMI.setMetaInfraType(typeApp); + vendorWMI.setName("WMI"); + + MetaInfraVendor vendorSNMPV2 = new MetaInfraVendor(); + vendorSNMPV2.setMetaInfraType(typeApp); + vendorSNMPV2.setName("SNMP_V2"); + + + List vendors = new ArrayList<>(); + + vendors.add(vendorMySQL); + vendors.add(vendorPost); + vendors.add(vendorWMI); + vendors.add(vendorSNMPV2); + + int startIdx = 39; + for(int indexI = 0 ; indexI < vendors.size(); ++indexI) { + MetaInfraVendor v = vendors.get(indexI); + + v.setId(indexI + startIdx); + + this.metaInfraVendorDAO.save(v); + + } + + } + +} \ No newline at end of file