From 815add8ba4bd87bf6b1e32bda10ba7b3f4170ff4 Mon Sep 17 00:00:00 2001 From: snoop Date: Sun, 25 Jun 2017 15:52:55 +0900 Subject: [PATCH] added meta test --- .../overflow/meta/model/MetaCrawler.java | 2 +- .../meta/model/MetaCrawlerInputItem.java | 2 +- .../overflow/meta/model/MetaInputType.java | 2 +- .../overflow/meta/dao/MetaCrawlerDAOTest.java | 66 +++++++++ .../meta/dao/MetaCrawlerInputItemDAOTest.java | 128 ++++++++++++++++++ .../meta/dao/MetaInputTypeDAOTest.java | 69 ++++++++++ .../overflow/proxy/db/MethodSeekerTest.java | 2 +- 7 files changed, 267 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/loafle/overflow/meta/dao/MetaCrawlerDAOTest.java create mode 100644 src/test/java/com/loafle/overflow/meta/dao/MetaCrawlerInputItemDAOTest.java create mode 100644 src/test/java/com/loafle/overflow/meta/dao/MetaInputTypeDAOTest.java diff --git a/src/main/java/com/loafle/overflow/meta/model/MetaCrawler.java b/src/main/java/com/loafle/overflow/meta/model/MetaCrawler.java index 8ec8cb2..1d89a20 100644 --- a/src/main/java/com/loafle/overflow/meta/model/MetaCrawler.java +++ b/src/main/java/com/loafle/overflow/meta/model/MetaCrawler.java @@ -24,7 +24,7 @@ public class MetaCrawler { } @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/meta/model/MetaCrawlerInputItem.java b/src/main/java/com/loafle/overflow/meta/model/MetaCrawlerInputItem.java index 583a1bf..67c6436 100644 --- a/src/main/java/com/loafle/overflow/meta/model/MetaCrawlerInputItem.java +++ b/src/main/java/com/loafle/overflow/meta/model/MetaCrawlerInputItem.java @@ -70,7 +70,7 @@ public class MetaCrawlerInputItem { } @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/meta/model/MetaInputType.java b/src/main/java/com/loafle/overflow/meta/model/MetaInputType.java index 1431d8b..643be22 100644 --- a/src/main/java/com/loafle/overflow/meta/model/MetaInputType.java +++ b/src/main/java/com/loafle/overflow/meta/model/MetaInputType.java @@ -44,7 +44,7 @@ public class MetaInputType { } @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/test/java/com/loafle/overflow/meta/dao/MetaCrawlerDAOTest.java b/src/test/java/com/loafle/overflow/meta/dao/MetaCrawlerDAOTest.java new file mode 100644 index 0000000..90426a9 --- /dev/null +++ b/src/test/java/com/loafle/overflow/meta/dao/MetaCrawlerDAOTest.java @@ -0,0 +1,66 @@ +package com.loafle.overflow.meta.dao; + +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.meta.model.MetaCrawler; +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 root on 17. 6. 25. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class MetaCrawlerDAOTest { + + @Autowired + private MetaCrawlerDAO metaCrawlerDAO; + + + + @Test + public void Create() { + + List metaCrawlerList = new ArrayList<>(); + + MetaCrawler crawMWI = new MetaCrawler(); + crawMWI.setName("WMI_CRAWLER"); + crawMWI.setDescription("WMI"); + + MetaCrawler crawlerSNMPV2 = new MetaCrawler(); + crawlerSNMPV2.setName("SNMP_V2_CRAWLER"); + crawlerSNMPV2.setDescription("SNMPV2"); + + MetaCrawler crawlerSNMPV3 = new MetaCrawler(); + crawlerSNMPV3.setName("SNMP_V3_CRAWLER"); + crawlerSNMPV3.setDescription("SNMPV3"); + + MetaCrawler crawlerMySQL = new MetaCrawler(); + crawlerMySQL.setName("MYSQL_CRAWLER"); + crawlerMySQL.setDescription("MYSQL"); + + metaCrawlerList.add(crawMWI); + metaCrawlerList.add(crawlerSNMPV2); + metaCrawlerList.add(crawlerSNMPV3); + metaCrawlerList.add(crawlerMySQL); + + + + for(int indexI = 0 ; indexI< metaCrawlerList.size();++indexI) { + MetaCrawler crawler = metaCrawlerList.get(indexI); + crawler.setId((short)(indexI + 1)); + this.metaCrawlerDAO.save(crawler); + + } + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/meta/dao/MetaCrawlerInputItemDAOTest.java b/src/test/java/com/loafle/overflow/meta/dao/MetaCrawlerInputItemDAOTest.java new file mode 100644 index 0000000..c03bcd1 --- /dev/null +++ b/src/test/java/com/loafle/overflow/meta/dao/MetaCrawlerInputItemDAOTest.java @@ -0,0 +1,128 @@ +package com.loafle.overflow.meta.dao; + +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.meta.model.MetaCrawler; +import com.loafle.overflow.meta.model.MetaCrawlerInputItem; +import com.loafle.overflow.meta.model.MetaInputType; +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 static org.junit.Assert.*; + +/** + * Created by root on 17. 6. 25. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class MetaCrawlerInputItemDAOTest { + + @Autowired + private MetaCrawlerInputItemDAO metaCrawlerInputItemDAO; + + @Test + public void craete() { + + MetaInputType typeText = new MetaInputType(); + typeText.setId((short)1); + + MetaInputType typePW = new MetaInputType(); + typePW.setId((short)2); + + + int ID = 0; + //WMI + { + MetaCrawler crawlerWMI = new MetaCrawler(); + crawlerWMI.setId((short)1); + + MetaCrawlerInputItem itemID = new MetaCrawlerInputItem(); + itemID.setId(++ID); + itemID.setMetaInputType(typeText); + itemID.setMetaCrawler(crawlerWMI); + itemID.setRequired(true); + itemID.setDescription("Windows Account ID"); + itemID.setPattern(""); + itemID.setName("ID"); + itemID.setDefaultValue("Loafle"); + + MetaCrawlerInputItem itemPW = new MetaCrawlerInputItem(); + itemPW.setId(++ID); + itemPW.setMetaInputType(typePW); + itemPW.setMetaCrawler(crawlerWMI); + itemPW.setRequired(true); + itemPW.setDescription("Windows Account PW"); + itemPW.setPattern(""); + itemPW.setName("PassWord"); + itemPW.setDefaultValue(""); + + this.metaCrawlerInputItemDAO.save(itemID); + this.metaCrawlerInputItemDAO.save(itemPW); + } + + + //SNMP V2 + { + MetaCrawler crawlerSNMPV2 = new MetaCrawler(); + crawlerSNMPV2.setId((short)2); + + MetaCrawlerInputItem itemCommunity = new MetaCrawlerInputItem(); + itemCommunity.setId(++ID); + itemCommunity.setMetaInputType(typeText); + itemCommunity.setMetaCrawler(crawlerSNMPV2); + itemCommunity.setRequired(true); + itemCommunity.setDescription("SNMP V2 Community"); + itemCommunity.setPattern(""); + itemCommunity.setName("Community"); + itemCommunity.setDefaultValue("public"); + + this.metaCrawlerInputItemDAO.save(itemCommunity); + } + + + //MySQL + { + MetaCrawler crawlerMySQL = new MetaCrawler(); + crawlerMySQL.setId((short)4); + + MetaCrawlerInputItem itemDB = new MetaCrawlerInputItem(); + itemDB.setId(++ID); + itemDB.setMetaInputType(typeText); + itemDB.setMetaCrawler(crawlerMySQL); + itemDB.setRequired(true); + itemDB.setDescription("MYSQL DB Name"); + itemDB.setPattern(""); + itemDB.setName("DB Name"); + itemDB.setDefaultValue("mysqldb"); + + MetaCrawlerInputItem itemID = new MetaCrawlerInputItem(); + itemID.setId(++ID); + itemID.setMetaInputType(typeText); + itemID.setMetaCrawler(crawlerMySQL); + itemID.setRequired(true); + itemID.setDescription("MYSQL Account ID"); + itemID.setPattern(""); + itemID.setName("ID"); + itemID.setDefaultValue("Loafle"); + + MetaCrawlerInputItem itemPW = new MetaCrawlerInputItem(); + itemPW.setId(++ID); + itemPW.setMetaInputType(typePW); + itemPW.setMetaCrawler(crawlerMySQL); + itemPW.setRequired(true); + itemPW.setDescription("MYSQL Account PW"); + itemPW.setPattern(""); + itemPW.setName("PassWord"); + itemPW.setDefaultValue(""); + + this.metaCrawlerInputItemDAO.save(itemDB); + this.metaCrawlerInputItemDAO.save(itemID); + this.metaCrawlerInputItemDAO.save(itemPW); + } + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/meta/dao/MetaInputTypeDAOTest.java b/src/test/java/com/loafle/overflow/meta/dao/MetaInputTypeDAOTest.java new file mode 100644 index 0000000..1d37dcd --- /dev/null +++ b/src/test/java/com/loafle/overflow/meta/dao/MetaInputTypeDAOTest.java @@ -0,0 +1,69 @@ +package com.loafle.overflow.meta.dao; + +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.meta.model.MetaInputType; +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 root on 17. 6. 25. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class MetaInputTypeDAOTest { + + + @Autowired + private MetaInputTypeDAO metaInputTypeDAO; + + + @Test + public void create() { + + MetaInputType typeText = new MetaInputType(); + typeText.setName("TEXT_TYPE"); + typeText.setDescription("TEXT"); + + MetaInputType typePW = new MetaInputType(); + typePW.setName("PASSWORD_TYPE"); + typePW.setDescription("PASSWORD"); + + MetaInputType typeNumber = new MetaInputType(); + typeNumber.setName("NUMBER_TYPE"); + typeNumber.setDescription("NUMBER"); + + MetaInputType typeBool = new MetaInputType(); + typeBool.setName("BOOLEAN_TYPE"); + typeBool.setDescription("BOOLEAN"); + + MetaInputType typeSelect = new MetaInputType(); + typeSelect.setName("SELECT_TYPE"); + typeSelect.setDescription("SELECT"); + + List metaInputTypes = new ArrayList<>(); + + metaInputTypes.add(typeText); + metaInputTypes.add(typePW); + metaInputTypes.add(typeNumber); + metaInputTypes.add(typeBool); + metaInputTypes.add(typeSelect); + + + for(int indexI = 1; indexI <= metaInputTypes.size(); ++indexI) { + MetaInputType type = metaInputTypes.get(indexI-1); + type.setId((short)indexI); + this.metaInputTypeDAO.save(type); + } + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/proxy/db/MethodSeekerTest.java b/src/test/java/com/loafle/overflow/proxy/db/MethodSeekerTest.java index b4c8a1e..932bc46 100644 --- a/src/test/java/com/loafle/overflow/proxy/db/MethodSeekerTest.java +++ b/src/test/java/com/loafle/overflow/proxy/db/MethodSeekerTest.java @@ -45,7 +45,7 @@ public class MethodSeekerTest { Method[] mArray = jpa.getClass().getMethods(); for (Method m : mArray) { - if( m.getName().equals("findAllByDomain")) { + if( m.getName().equals("findOne")) { System.out.println(m.getParameterTypes()); }