This commit is contained in:
insanity 2017-06-22 20:58:16 +09:00
parent 1facd88842
commit fc763c645e
17 changed files with 159 additions and 443 deletions

View File

@ -53,27 +53,4 @@ public class MetaCrawler {
this.desc = desc; 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;
}
} }

View File

@ -44,25 +44,4 @@ public class MetaInfraType {
this.createDate = createDate; 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;
}
} }

View File

@ -54,28 +54,4 @@ public class MetaInputType {
public void setCreateDate(Date createDate) { public void setCreateDate(Date createDate) {
this.createDate = 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;
}
} }

View File

@ -31,23 +31,4 @@ public class MetaMemberStatus {
this.name = name; 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;
}
} }

View File

@ -13,7 +13,7 @@ public class MetaNotification {
private long id; private long id;
private Date createDate; private Date createDate;
private String name; private String name;
private String description; private String desc;
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy= GenerationType.IDENTITY)
@ -46,36 +46,13 @@ public class MetaNotification {
} }
@Column(name = "DESCRIPTION", nullable = true, length = 50) @Column(name = "desc", nullable = true, length = 50)
public String getDescription() { public String getDesc() {
return description; return desc;
} }
public void setDescription(String description) { public void setDesc(String desc) {
this.description = description; this.desc = desc;
} }
@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;
}
} }

View File

@ -11,7 +11,7 @@ import java.util.Date;
@Table(name = "TBL_META_PROBE_ARCHITECTURE", schema = "public", catalog = "postgres") @Table(name = "TBL_META_PROBE_ARCHITECTURE", schema = "public", catalog = "postgres")
public class MetaProbeArchitecture { public class MetaProbeArchitecture {
private short id; private short id;
private String archi; private String architecture;
private Date createDate; private Date createDate;
@Id @Id
@ -25,13 +25,13 @@ public class MetaProbeArchitecture {
} }
@Column(name = "ARCHI", nullable = true, length = 10) @Column(name = "ARCHITECTURE", nullable = true, length = 10)
public String getArchi() { public String getArchitecture() {
return archi; return architecture;
} }
public void setArchi(String archi) { public void setArchitecture(String architecture) {
this.archi = archi; this.architecture = architecture;
} }
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@ -44,25 +44,4 @@ public class MetaProbeArchitecture {
this.createDate = createDate; 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;
}
} }

View File

@ -44,25 +44,4 @@ public class MetaProbeOs {
this.createDate = createDate; 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;
}
} }

View File

@ -11,9 +11,9 @@ import java.util.Date;
@Table(name = "TBL_META_PROBE_PACKAGE", schema = "public", catalog = "postgres") @Table(name = "TBL_META_PROBE_PACKAGE", schema = "public", catalog = "postgres")
public class MetaProbePackage { public class MetaProbePackage {
private long id; private long id;
private MetaProbeVersion versionId; private MetaProbeVersion version;
private MetaProbeOs osId; private MetaProbeOs os;
private MetaProbeArchitecture architectureId; private MetaProbeArchitecture architecture;
private Date createDate; private Date createDate;
@Id @Id
@ -28,32 +28,32 @@ public class MetaProbePackage {
@ManyToOne @ManyToOne
@JoinColumn(name = "VERSION_ID", nullable = false) @JoinColumn(name = "VERSION_ID", nullable = false)
public MetaProbeVersion getVersionId() { public MetaProbeVersion getVersion() {
return versionId; return version;
} }
public void setVersionId(MetaProbeVersion versionId) { public void setVersion(MetaProbeVersion version) {
this.versionId = versionId; this.version = version;
} }
@ManyToOne @ManyToOne
@JoinColumn(name = "OS_ID", nullable = false) @JoinColumn(name = "OS_ID", nullable = false)
public MetaProbeOs getOsId() { public MetaProbeOs getOs() {
return osId; return os;
} }
public void setOsId(MetaProbeOs osId) { public void setOs(MetaProbeOs os) {
this.osId = osId; this.os = os;
} }
@ManyToOne @ManyToOne
@JoinColumn(name = "ARCHITECTURE_ID", nullable = false) @JoinColumn(name = "ARCHITECTURE_ID", nullable = false)
public MetaProbeArchitecture getArchitectureId() { public MetaProbeArchitecture getArchitecture() {
return architectureId; return architecture;
} }
public void setArchitectureId(MetaProbeArchitecture architectureId) { public void setArchitecture(MetaProbeArchitecture architecture) {
this.architectureId = architectureId; this.architecture = architecture;
} }
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@ -66,29 +66,4 @@ public class MetaProbePackage {
this.createDate = createDate; 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;
// }
} }

View File

@ -44,25 +44,4 @@ public class MetaProbeVersion {
this.createDate = createDate; 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;
}
} }

View File

@ -73,30 +73,4 @@ public class MetaSensorItem {
public void setCreateDate(Date createDate) { public void setCreateDate(Date createDate) {
this.createDate = 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;
// }
} }

View File

@ -55,27 +55,4 @@ public class MetaSensorItemType {
this.createDate = createDate; 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;
}
} }

View File

@ -75,27 +75,4 @@ public class MetaVendorCrawler {
this.createDate = createDate; 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;
// }
} }

View File

@ -109,34 +109,4 @@ public class MetaVendorCrawlerSensorItem {
this.crawlerId = crawlerId; 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;
// }
} }

View File

@ -1,12 +1,17 @@
package com.loafle.overflow.module.target.dao; package com.loafle.overflow.module.target.dao;
import com.loafle.overflow.module.probe.model.Probe;
import com.loafle.overflow.module.target.model.Target; import com.loafle.overflow.module.target.model.Target;
import org.springframework.data.jpa.repository.JpaRepository; 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. * Created by root on 17. 6. 5.
*/ */
public interface TargetDAO extends JpaRepository<Target, Long> { public interface TargetDAO extends JpaRepository<Target, Long> {
@Query("SELECT m FROM TARGET m WHERE m.probeId = :probeId")
List<Target> findAllByProbe(Probe probe);
} }

View File

@ -1,115 +1,115 @@
package com.loafle; //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<com.loafle.overflow.target.model.Target>");
Object obj = mapper.readValue(testRes, cls);
List<Object> aa = Arrays.asList((Object[])obj);
System.out.println(aa.getClass());
// List<Target> tl = (List<Target>)aa;
// List<Target> aaa = (List<Target>)obj.;
// //
// //
// for( Target t : aaa) { //import com.loafle.overflow.db.api.DBGrpc;
// System.out.println(t); //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<com.loafle.overflow.target.model.Target>");
//
// Object obj = mapper.readValue(testRes, cls);
//
//
// List<Object> aa = Arrays.asList((Object[])obj);
//
// System.out.println(aa.getClass());
//// List<Target> tl = (List<Target>)aa;
//
//
//// List<Target> aaa = (List<Target>)obj.;
////
////
//// for( Target t : aaa) {
//// System.out.println(t);
//// }
//
// }
//} //}
}
}

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.module.member.dao;
import com.loafle.overflow.AppConfig; import com.loafle.overflow.AppConfig;
import com.loafle.overflow.JdbcConfiguration; import com.loafle.overflow.JdbcConfiguration;
import com.loafle.overflow.module.member.model.Member;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -24,8 +25,8 @@ public class MemberDAOTest {
Member m = new Member(); Member m = new Member();
m.setName("insanity2"); m.setName("insanity2");
m.setCompany("loafle"); m.setCompanyName("loafle");
m.setDigest("bbbbbbbbb"); m.setPw("bbbbbbbbb");
m.setPwSalt("salktttt"); m.setPwSalt("salktttt");
m.setPhone("000-000-0000"); m.setPhone("000-000-0000");
m.setEmail("insanity1@loafle.com"); m.setEmail("insanity1@loafle.com");

View File

@ -1,15 +1,22 @@
package com.loafle.overflow.target.dao; 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.infra.Infra;
import com.loafle.overflow.module.target.dao.TargetDAO; import com.loafle.overflow.module.target.dao.TargetDAO;
import com.loafle.overflow.module.target.model.Target; import com.loafle.overflow.module.target.model.Target;
import com.loafle.overflow.module.probe.model.Probe; import com.loafle.overflow.module.probe.model.Probe;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; 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.sql.Timestamp;
import java.util.Date; import java.util.Date;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
public class JPATargetDaoTest { public class JPATargetDaoTest {
@Autowired @Autowired
@ -28,6 +35,9 @@ public class JPATargetDaoTest {
Probe p = new Probe(); Probe p = new Probe();
p.setId(1); p.setId(1);
t.setInfra(i);
t.setProbe(p);
Target ret = repo.save(t); Target ret = repo.save(t);
} }