From db0edbe4c0e51441015234ee572210503283cb5d Mon Sep 17 00:00:00 2001 From: insanity Date: Sun, 25 Jun 2017 16:18:10 +0900 Subject: [PATCH] infra-meta test data --- .../infra/dao/JPAMetaInfraDAOTest.java | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 src/test/java/com/loafle/overflow/infra/dao/JPAMetaInfraDAOTest.java diff --git a/src/test/java/com/loafle/overflow/infra/dao/JPAMetaInfraDAOTest.java b/src/test/java/com/loafle/overflow/infra/dao/JPAMetaInfraDAOTest.java new file mode 100644 index 0000000..7ebb081 --- /dev/null +++ b/src/test/java/com/loafle/overflow/infra/dao/JPAMetaInfraDAOTest.java @@ -0,0 +1,150 @@ +package com.loafle.overflow.infra.dao; + +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.meta.dao.MetaInfraTypeDAO; +import com.loafle.overflow.meta.dao.MetaInfraVendorDAO; +import com.loafle.overflow.meta.model.MetaInfraType; +import com.loafle.overflow.meta.model.MetaInfraVendor; +import org.junit.After; +import org.junit.Before; +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.Date; +import java.util.List; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class JPAMetaInfraDAOTest { + + @Autowired + private MetaInfraTypeDAO infraTypeRepo; + @Autowired + private MetaInfraVendorDAO infraVendorRepo; + + private List machineVendors; + private List osVendors; + private List serviceVendors; + + @Before + public void setUp() throws Exception { + MetaInfraType infraType1 = new MetaInfraType(); + infraType1.setId(1); + infraType1.setName("MACHINE"); + infraType1.setCreateDate(new Date()); + infraTypeRepo.save(infraType1); + MetaInfraType infraType2 = new MetaInfraType(); + infraType2.setId(2); + infraType2.setName("HOST"); + infraType2.setCreateDate(new Date()); + infraTypeRepo.save(infraType2); + MetaInfraType infraType3 = new MetaInfraType(); + infraType3.setId(3); + infraType3.setName("SERVICE"); + infraType3.setCreateDate(new Date()); + infraTypeRepo.save(infraType3); + + this.machineVendors = new ArrayList<>(); + this.osVendors = new ArrayList<>(); + this.serviceVendors = new ArrayList<>(); + + this.machineVendors.add("APPLE"); + this.machineVendors.add("MICROSOFT"); + this.machineVendors.add("ASUS"); + this.machineVendors.add("HP"); + this.machineVendors.add("DELL"); + this.machineVendors.add("LENOVO"); + this.machineVendors.add("ACER"); + this.machineVendors.add("SAMSUNG"); + this.machineVendors.add("LG"); + this.machineVendors.add("CISCO"); + + this.osVendors.add("Windows"); + this.osVendors.add("Mac OS"); + this.osVendors.add("Ubuntu"); + this.osVendors.add("Cent OS"); + this.osVendors.add("Fedora"); + this.osVendors.add("Red Hat"); + this.osVendors.add("Debian"); + this.osVendors.add("SUSE"); + this.osVendors.add("Core OS"); + this.osVendors.add("Amazon Linux"); + this.osVendors.add("Kubernetes"); + this.osVendors.add("Docker"); + this.osVendors.add("iOS"); + this.osVendors.add("Android"); + + this.serviceVendors.add("Cassandra"); + this.serviceVendors.add("Oracle"); + this.serviceVendors.add("Redis"); + this.serviceVendors.add("MongoDB"); + this.serviceVendors.add("SQL Server"); + this.serviceVendors.add("MySQL"); + this.serviceVendors.add("Active Directory"); + this.serviceVendors.add("SSH"); + this.serviceVendors.add("FTP"); + this.serviceVendors.add("SMTP"); + this.serviceVendors.add("DNS"); + this.serviceVendors.add("SMB"); + this.serviceVendors.add("NetBios"); + this.serviceVendors.add("SNMP"); + this.serviceVendors.add("RMI"); + this.serviceVendors.add("TELNET"); + this.serviceVendors.add("HTTP"); + this.serviceVendors.add("WMI"); + this.serviceVendors.add("IMAP"); + this.serviceVendors.add("LDAP"); + this.serviceVendors.add("POP3"); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void createInfraVendor() { + int idx = 1; + + for (String name : machineVendors) { + MetaInfraVendor v = new MetaInfraVendor(); + v.setId(idx++); + v.setCreateDate(new Date()); + MetaInfraType t = new MetaInfraType(); + t.setId(1); + v.setMetaInfraType(t); + v.setName(name); + this.infraVendorRepo.save(v); + } + + for (String name : osVendors) { + MetaInfraVendor v = new MetaInfraVendor(); + v.setId(idx++); + v.setCreateDate(new Date()); + MetaInfraType t = new MetaInfraType(); + t.setId(2); + v.setMetaInfraType(t); + v.setName(name); + this.infraVendorRepo.save(v); + } + + for (String name : osVendors) { + MetaInfraVendor v = new MetaInfraVendor(); + v.setId(idx++); + v.setCreateDate(new Date()); + MetaInfraType t = new MetaInfraType(); + t.setId(3); + v.setMetaInfraType(t); + v.setName(name); + this.infraVendorRepo.save(v); + } + + } + + +} \ No newline at end of file