diff --git a/src/main/java/com/loafle/overflow/meta/MetaCrawler.java b/src/main/java/com/loafle/overflow/meta/MetaCrawler.java index bece2e0..f395449 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaCrawler.java +++ b/src/main/java/com/loafle/overflow/meta/MetaCrawler.java @@ -53,27 +53,4 @@ public class MetaCrawler { this.desc = desc; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaCrawler that = (MetaCrawler) o; - - if (id != that.id) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (desc != null ? !desc.equals(that.desc) : that.desc != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) id; - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (desc != null ? desc.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaInfraType.java b/src/main/java/com/loafle/overflow/meta/MetaInfraType.java index 88b1413..18182ef 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaInfraType.java +++ b/src/main/java/com/loafle/overflow/meta/MetaInfraType.java @@ -44,25 +44,4 @@ public class MetaInfraType { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaInfraType that = (MetaInfraType) o; - - if (id != that.id) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaInputType.java b/src/main/java/com/loafle/overflow/meta/MetaInputType.java index de72c60..f81a67c 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaInputType.java +++ b/src/main/java/com/loafle/overflow/meta/MetaInputType.java @@ -54,28 +54,4 @@ public class MetaInputType { public void setCreateDate(Date createDate) { this.createDate = createDate; } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaInputType that = (MetaInputType) o; - - if (id != that.id) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (desc != null ? !desc.equals(that.desc) : that.desc != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) id; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (desc != null ? desc.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaMemberStatus.java b/src/main/java/com/loafle/overflow/meta/MetaMemberStatus.java index 8cfd97c..4410d0d 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaMemberStatus.java +++ b/src/main/java/com/loafle/overflow/meta/MetaMemberStatus.java @@ -31,23 +31,4 @@ public class MetaMemberStatus { this.name = name; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaMemberStatus that = (MetaMemberStatus) o; - - if (id != that.id) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) id; - result = 31 * result + (name != null ? name.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaNotification.java b/src/main/java/com/loafle/overflow/meta/MetaNotification.java index 330cf21..52e6f8a 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaNotification.java +++ b/src/main/java/com/loafle/overflow/meta/MetaNotification.java @@ -13,7 +13,7 @@ public class MetaNotification { private long id; private Date createDate; private String name; - private String description; + private String desc; @Id @GeneratedValue(strategy= GenerationType.IDENTITY) @@ -46,36 +46,13 @@ public class MetaNotification { } - @Column(name = "DESCRIPTION", nullable = true, length = 50) - public String getDescription() { - return description; + @Column(name = "desc", nullable = true, length = 50) + public String getDesc() { + return desc; } - public void setDescription(String description) { - this.description = description; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaNotification that = (MetaNotification) o; - - if (id != that.id) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (description != null ? !description.equals(that.description) : that.description != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - return result; + public void setDesc(String desc) { + this.desc = desc; } + } diff --git a/src/main/java/com/loafle/overflow/meta/MetaProbeArchitecture.java b/src/main/java/com/loafle/overflow/meta/MetaProbeArchitecture.java index d8642f5..f6c3206 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaProbeArchitecture.java +++ b/src/main/java/com/loafle/overflow/meta/MetaProbeArchitecture.java @@ -11,7 +11,7 @@ import java.util.Date; @Table(name = "TBL_META_PROBE_ARCHITECTURE", schema = "public", catalog = "postgres") public class MetaProbeArchitecture { private short id; - private String archi; + private String architecture; private Date createDate; @Id @@ -25,13 +25,13 @@ public class MetaProbeArchitecture { } - @Column(name = "ARCHI", nullable = true, length = 10) - public String getArchi() { - return archi; + @Column(name = "ARCHITECTURE", nullable = true, length = 10) + public String getArchitecture() { + return architecture; } - public void setArchi(String archi) { - this.archi = archi; + public void setArchitecture(String architecture) { + this.architecture = architecture; } @Temporal(TemporalType.TIMESTAMP) @@ -44,25 +44,4 @@ public class MetaProbeArchitecture { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaProbeArchitecture that = (MetaProbeArchitecture) o; - - if (id != that.id) return false; - if (archi != null ? !archi.equals(that.archi) : that.archi != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) id; - result = 31 * result + (archi != null ? archi.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaProbeOs.java b/src/main/java/com/loafle/overflow/meta/MetaProbeOs.java index e6bc7cc..747d22d 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaProbeOs.java +++ b/src/main/java/com/loafle/overflow/meta/MetaProbeOs.java @@ -44,25 +44,4 @@ public class MetaProbeOs { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaProbeOs that = (MetaProbeOs) o; - - if (id != that.id) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) id; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaProbePackage.java b/src/main/java/com/loafle/overflow/meta/MetaProbePackage.java index 66ccf91..1beb2a0 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaProbePackage.java +++ b/src/main/java/com/loafle/overflow/meta/MetaProbePackage.java @@ -11,9 +11,9 @@ import java.util.Date; @Table(name = "TBL_META_PROBE_PACKAGE", schema = "public", catalog = "postgres") public class MetaProbePackage { private long id; - private MetaProbeVersion versionId; - private MetaProbeOs osId; - private MetaProbeArchitecture architectureId; + private MetaProbeVersion version; + private MetaProbeOs os; + private MetaProbeArchitecture architecture; private Date createDate; @Id @@ -28,32 +28,32 @@ public class MetaProbePackage { @ManyToOne @JoinColumn(name = "VERSION_ID", nullable = false) - public MetaProbeVersion getVersionId() { - return versionId; + public MetaProbeVersion getVersion() { + return version; } - public void setVersionId(MetaProbeVersion versionId) { - this.versionId = versionId; + public void setVersion(MetaProbeVersion version) { + this.version = version; } @ManyToOne @JoinColumn(name = "OS_ID", nullable = false) - public MetaProbeOs getOsId() { - return osId; + public MetaProbeOs getOs() { + return os; } - public void setOsId(MetaProbeOs osId) { - this.osId = osId; + public void setOs(MetaProbeOs os) { + this.os = os; } @ManyToOne @JoinColumn(name = "ARCHITECTURE_ID", nullable = false) - public MetaProbeArchitecture getArchitectureId() { - return architectureId; + public MetaProbeArchitecture getArchitecture() { + return architecture; } - public void setArchitectureId(MetaProbeArchitecture architectureId) { - this.architectureId = architectureId; + public void setArchitecture(MetaProbeArchitecture architecture) { + this.architecture = architecture; } @Temporal(TemporalType.TIMESTAMP) @@ -66,29 +66,4 @@ public class MetaProbePackage { this.createDate = createDate; } -// @Override -// public boolean equals(Object o) { -// if (this == o) return true; -// if (o == null || getClass() != o.getClass()) return false; -// -// MetaProbePackage that = (MetaProbePackage) o; -// -// if (id != that.id) return false; -// if (versionId != that.versionId) return false; -// if (osId != that.osId) return false; -// if (architectureId != that.architectureId) return false; -// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; -// -// return true; -// } - -// @Override -// public int hashCode() { -// int result = (int) (id ^ (id >>> 32)); -// result = 31 * result + (int) versionId; -// result = 31 * result + (int) osId; -// result = 31 * result + (int) architectureId; -// result = 31 * result + (createDate != null ? createDate.hashCode() : 0); -// return result; -// } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaProbeVersion.java b/src/main/java/com/loafle/overflow/meta/MetaProbeVersion.java index ce56887..fff6c65 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaProbeVersion.java +++ b/src/main/java/com/loafle/overflow/meta/MetaProbeVersion.java @@ -44,25 +44,4 @@ public class MetaProbeVersion { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaProbeVersion that = (MetaProbeVersion) o; - - if (id != that.id) return false; - if (version != null ? !version.equals(that.version) : that.version != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) id; - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaSensorItem.java b/src/main/java/com/loafle/overflow/meta/MetaSensorItem.java index e86cfb4..316967f 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaSensorItem.java +++ b/src/main/java/com/loafle/overflow/meta/MetaSensorItem.java @@ -73,30 +73,4 @@ public class MetaSensorItem { public void setCreateDate(Date createDate) { this.createDate = createDate; } - -// @Override -// public boolean equals(Object o) { -// if (this == o) return true; -// if (o == null || getClass() != o.getClass()) return false; -// -// MetaSensorItem that = (MetaSensorItem) o; -// -// if (id != that.id) return false; -// if (typeId != that.typeId) return false; -// if (key != null ? !key.equals(that.key) : that.key != null) return false; -// if (name != null ? !name.equals(that.name) : that.name != null) return false; -// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; -// -// return true; -// } -// -// @Override -// public int hashCode() { -// int result = id; -// result = 31 * result + (int) typeId; -// result = 31 * result + (key != null ? key.hashCode() : 0); -// result = 31 * result + (name != null ? name.hashCode() : 0); -// result = 31 * result + (createDate != null ? createDate.hashCode() : 0); -// return result; -// } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaSensorItemType.java b/src/main/java/com/loafle/overflow/meta/MetaSensorItemType.java index 062df28..8962da8 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaSensorItemType.java +++ b/src/main/java/com/loafle/overflow/meta/MetaSensorItemType.java @@ -55,27 +55,4 @@ public class MetaSensorItemType { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MetaSensorItemType that = (MetaSensorItemType) o; - - if (id != that.id) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (desc != null ? !desc.equals(that.desc) : that.desc != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) id; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (desc != null ? desc.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaVendorCrawler.java b/src/main/java/com/loafle/overflow/meta/MetaVendorCrawler.java index 60eee5a..2af8287 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaVendorCrawler.java +++ b/src/main/java/com/loafle/overflow/meta/MetaVendorCrawler.java @@ -75,27 +75,4 @@ public class MetaVendorCrawler { this.createDate = createDate; } -// @Override -// public boolean equals(Object o) { -// if (this == o) return true; -// if (o == null || getClass() != o.getClass()) return false; -// -// MetaVendorCrawler that = (MetaVendorCrawler) o; -// -// if (id != that.id) return false; -// if (crawlerId != that.crawlerId) return false; -// if (vendorId != that.vendorId) return false; -// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; -// -// return true; -// } -// -// @Override -// public int hashCode() { -// int result = id; -// result = 31 * result + (int) crawlerId; -// result = 31 * result + vendorId; -// result = 31 * result + (createDate != null ? createDate.hashCode() : 0); -// return result; -// } } diff --git a/src/main/java/com/loafle/overflow/meta/MetaVendorCrawlerSensorItem.java b/src/main/java/com/loafle/overflow/meta/MetaVendorCrawlerSensorItem.java index f491613..d4808ab 100644 --- a/src/main/java/com/loafle/overflow/meta/MetaVendorCrawlerSensorItem.java +++ b/src/main/java/com/loafle/overflow/meta/MetaVendorCrawlerSensorItem.java @@ -109,34 +109,4 @@ public class MetaVendorCrawlerSensorItem { this.crawlerId = crawlerId; } -// @Override -// public boolean equals(Object o) { -// if (this == o) return true; -// if (o == null || getClass() != o.getClass()) return false; -// -// MetaVendorCrawlerSensorItem that = (MetaVendorCrawlerSensorItem) o; -// -// if (id != that.id) return false; -// if (itemId != that.itemId) return false; -// if (vendorId != that.vendorId) return false; -// if (crawlerId != that.crawlerId) return false; -// if (interval != null ? !interval.equals(that.interval) : that.interval != null) return false; -// if (warnCondition != null ? !warnCondition.equals(that.warnCondition) : that.warnCondition != null) -// return false; -// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; -// -// return true; -// } -// -// @Override -// public int hashCode() { -// int result = (int) (id ^ (id >>> 32)); -// result = 31 * result + (interval != null ? interval.hashCode() : 0); -// result = 31 * result + (warnCondition != null ? warnCondition.hashCode() : 0); -// result = 31 * result + (createDate != null ? createDate.hashCode() : 0); -// result = 31 * result + itemId; -// result = 31 * result + vendorId; -// result = 31 * result + (int) crawlerId; -// return result; -// } } diff --git a/src/main/java/com/loafle/overflow/module/target/dao/TargetDAO.java b/src/main/java/com/loafle/overflow/module/target/dao/TargetDAO.java index d10563f..dbe364f 100644 --- a/src/main/java/com/loafle/overflow/module/target/dao/TargetDAO.java +++ b/src/main/java/com/loafle/overflow/module/target/dao/TargetDAO.java @@ -1,12 +1,17 @@ package com.loafle.overflow.module.target.dao; +import com.loafle.overflow.module.probe.model.Probe; import com.loafle.overflow.module.target.model.Target; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; /** * Created by root on 17. 6. 5. */ public interface TargetDAO extends JpaRepository { - + @Query("SELECT m FROM TARGET m WHERE m.probeId = :probeId") + List findAllByProbe(Probe probe); } diff --git a/src/test/java/com/loafle/TestClient.java b/src/test/java/com/loafle/TestClient.java index f248e19..81502be 100644 --- a/src/test/java/com/loafle/TestClient.java +++ b/src/test/java/com/loafle/TestClient.java @@ -1,115 +1,115 @@ -package com.loafle; - - -import com.loafle.overflow.db.api.DBGrpc; -import com.loafle.overflow.db.api.DBInput; -import com.loafle.overflow.db.api.DBOutput; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import io.grpc.StatusRuntimeException; -import org.codehaus.jackson.map.ObjectMapper; -import org.junit.Test; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class TestClient { - - private static final Logger logger = Logger.getLogger(TestClient.class.getName()); - - private final ManagedChannel channel; - private final DBGrpc.DBBlockingStub dbStub; - - public TestClient() { - channel = ManagedChannelBuilder.forAddress("127.0.0.1", 50006).usePlaintext(true).build(); - dbStub = DBGrpc.newBlockingStub(channel); - } - - - public void shutdown() throws InterruptedException { - channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - - public void execute() { - - try { - Member m = new Member(); - m.setId(Long.parseLong("2")); - m.setName("geek"); - m.setCompany("loafle"); - m.setDigest("bbbbbbbbb"); - m.setPwSalt("salktttt"); - m.setEmail("insanity@loafle.com"); - - ObjectMapper mapper = new ObjectMapper(); - - DBInput request = DBInput.newBuilder() - .setTargetDao("member") - .setMethod("findByEmail") - .putParams("com.loafle.overflow.member.model.Member", mapper.writeValueAsString(m)) - //.putParams("id", "1") - .build(); - DBOutput response; - try { - response = dbStub.exec(request); - } catch (StatusRuntimeException e) { - logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus()); - return; - } - logger.log(Level.INFO, response.getResult()); - }catch(Exception e) { - e.printStackTrace(); - } - - } - - @Test - public void testRPCServer() { - TestClient client = new TestClient(); - try { - client.execute(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - client.shutdown(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - - - @Test - public void testClassName() throws ClassNotFoundException, IOException { - - String testRes = "[{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL2222\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL3333\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL4444\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL5555\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL6666\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}}]"; - - ObjectMapper mapper = new ObjectMapper(); - Class cls = Class.forName("[L" + "com.loafle.overflow.target.model.Target" + ";"); -// Class cls = Class.forName("java.util.List"); - - Object obj = mapper.readValue(testRes, cls); - - - List aa = Arrays.asList((Object[])obj); - - System.out.println(aa.getClass()); -// List tl = (List)aa; - - -// List aaa = (List)obj.; +//package com.loafle; // // -// for( Target t : aaa) { -// System.out.println(t); +//import com.loafle.overflow.db.api.DBGrpc; +//import com.loafle.overflow.db.api.DBInput; +//import com.loafle.overflow.db.api.DBOutput; +//import io.grpc.ManagedChannel; +//import io.grpc.ManagedChannelBuilder; +//import io.grpc.StatusRuntimeException; +//import org.codehaus.jackson.map.ObjectMapper; +//import org.junit.Test; +// +//import java.io.IOException; +//import java.util.Arrays; +//import java.util.List; +//import java.util.concurrent.TimeUnit; +//import java.util.logging.Level; +//import java.util.logging.Logger; +// +//public class TestClient { +// +// private static final Logger logger = Logger.getLogger(TestClient.class.getName()); +// +// private final ManagedChannel channel; +// private final DBGrpc.DBBlockingStub dbStub; +// +// public TestClient() { +// channel = ManagedChannelBuilder.forAddress("127.0.0.1", 50006).usePlaintext(true).build(); +// dbStub = DBGrpc.newBlockingStub(channel); +// } +// +// +// public void shutdown() throws InterruptedException { +// channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); +// } +// +// +// public void execute() { +// +// try { +// Member m = new Member(); +// m.setId(Long.parseLong("2")); +// m.setName("geek"); +// m.setCompany("loafle"); +// m.setDigest("bbbbbbbbb"); +// m.setPwSalt("salktttt"); +// m.setEmail("insanity@loafle.com"); +// +// ObjectMapper mapper = new ObjectMapper(); +// +// DBInput request = DBInput.newBuilder() +// .setTargetDao("member") +// .setMethod("findByEmail") +// .putParams("com.loafle.overflow.member.model.Member", mapper.writeValueAsString(m)) +// //.putParams("id", "1") +// .build(); +// DBOutput response; +// try { +// response = dbStub.exec(request); +// } catch (StatusRuntimeException e) { +// logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus()); +// return; +// } +// logger.log(Level.INFO, response.getResult()); +// }catch(Exception e) { +// e.printStackTrace(); // } - - } -} \ No newline at end of file +// +// } +// +// @Test +// public void testRPCServer() { +// TestClient client = new TestClient(); +// try { +// client.execute(); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// try { +// client.shutdown(); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// } +// +// +// +// @Test +// public void testClassName() throws ClassNotFoundException, IOException { +// +// String testRes = "[{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL2222\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL3333\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL4444\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL5555\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL6666\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}}]"; +// +// ObjectMapper mapper = new ObjectMapper(); +// Class cls = Class.forName("[L" + "com.loafle.overflow.target.model.Target" + ";"); +//// Class cls = Class.forName("java.util.List"); +// +// Object obj = mapper.readValue(testRes, cls); +// +// +// List aa = Arrays.asList((Object[])obj); +// +// System.out.println(aa.getClass()); +//// List tl = (List)aa; +// +// +//// List aaa = (List)obj.; +//// +//// +//// for( Target t : aaa) { +//// System.out.println(t); +//// } +// +// } +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java index d481054..f6f6712 100644 --- a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java @@ -2,6 +2,7 @@ package com.loafle.overflow.module.member.dao; import com.loafle.overflow.AppConfig; import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.module.member.model.Member; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -24,8 +25,8 @@ public class MemberDAOTest { Member m = new Member(); m.setName("insanity2"); - m.setCompany("loafle"); - m.setDigest("bbbbbbbbb"); + m.setCompanyName("loafle"); + m.setPw("bbbbbbbbb"); m.setPwSalt("salktttt"); m.setPhone("000-000-0000"); m.setEmail("insanity1@loafle.com"); diff --git a/src/test/java/com/loafle/overflow/target/dao/JPATargetDaoTest.java b/src/test/java/com/loafle/overflow/target/dao/JPATargetDaoTest.java index dac6b3d..8ec423e 100644 --- a/src/test/java/com/loafle/overflow/target/dao/JPATargetDaoTest.java +++ b/src/test/java/com/loafle/overflow/target/dao/JPATargetDaoTest.java @@ -1,15 +1,22 @@ package com.loafle.overflow.target.dao; +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; import com.loafle.overflow.module.infra.Infra; import com.loafle.overflow.module.target.dao.TargetDAO; import com.loafle.overflow.module.target.model.Target; import com.loafle.overflow.module.probe.model.Probe; 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.sql.Timestamp; import java.util.Date; +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) public class JPATargetDaoTest { @Autowired @@ -28,6 +35,9 @@ public class JPATargetDaoTest { Probe p = new Probe(); p.setId(1); + t.setInfra(i); + t.setProbe(p); + Target ret = repo.save(t); }