From 7d34fdb484856787bbb479373242dd43ea74e019 Mon Sep 17 00:00:00 2001 From: snoop Date: Wed, 7 Jun 2017 19:37:30 +0900 Subject: [PATCH] added target changed target model --- .../loafle/overflow/target/model/Target.java | 23 +++++++++++++++---- .../loafle/overflow/target/type/PortType.java | 19 +++++++++++++++ .../dao/JPANoAuthAgentDAOTest.java | 16 ++++++++++++- src/test/resources/META-INF/persistence.xml | 1 + 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/loafle/overflow/target/type/PortType.java diff --git a/src/main/java/com/loafle/overflow/target/model/Target.java b/src/main/java/com/loafle/overflow/target/model/Target.java index 8dfb584..ffe7e7e 100644 --- a/src/main/java/com/loafle/overflow/target/model/Target.java +++ b/src/main/java/com/loafle/overflow/target/model/Target.java @@ -1,6 +1,7 @@ package com.loafle.overflow.target.model; import com.loafle.overflow.member.model.Member; +import com.loafle.overflow.target.type.PortType; import com.loafle.overflow.target.type.TargetType; import javax.persistence.*; @@ -19,26 +20,30 @@ public class Target { @Column(name="IP", nullable=false) private long ip; - @Column(name="PORT", nullable=false) + @Column(name="PORT") private int port; - @Column(name="TARGET_TYPE", nullable=false) + @Column(name="TARGET_TYPE") @Enumerated(EnumType.STRING) private TargetType targetType; - @Column(name="VENDOR_NAME", nullable=false) + @Column(name="VENDOR_NAME") private String vendorName; - @Column(name="KINDS", nullable=false) + @Column(name="KINDS") private String kinds; - @Column(name="VERSION", nullable=false) + @Column(name="VERSION") private String version; @Temporal(TemporalType.TIMESTAMP) @Column(name="CREATE_DATE", nullable=false , columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false) private Date createDate; + @Column(name="PORT_TYPE") + @Enumerated(EnumType.STRING) + private PortType portType; + @ManyToOne @JoinColumn(name = "MEMBER_ID", nullable=false) private Member member; @@ -114,4 +119,12 @@ public class Target { public void setMember(Member member) { this.member = member; } + + public PortType getPortType() { + return portType; + } + + public void setPortType(PortType portType) { + this.portType = portType; + } } diff --git a/src/main/java/com/loafle/overflow/target/type/PortType.java b/src/main/java/com/loafle/overflow/target/type/PortType.java new file mode 100644 index 0000000..dd3edc2 --- /dev/null +++ b/src/main/java/com/loafle/overflow/target/type/PortType.java @@ -0,0 +1,19 @@ +package com.loafle.overflow.target.type; + +/** + * Created by root on 17. 6. 7. + */ +public enum PortType { + + TCP("TCP"), + UDP("UDP"); + + + private String stringValue; + PortType(String string) {stringValue = string;} + + @Override + public String toString() { + return stringValue; + } +} diff --git a/src/test/java/com/loafle/overflow/noauthagent/dao/JPANoAuthAgentDAOTest.java b/src/test/java/com/loafle/overflow/noauthagent/dao/JPANoAuthAgentDAOTest.java index 444e59c..f7f4565 100644 --- a/src/test/java/com/loafle/overflow/noauthagent/dao/JPANoAuthAgentDAOTest.java +++ b/src/test/java/com/loafle/overflow/noauthagent/dao/JPANoAuthAgentDAOTest.java @@ -1,6 +1,7 @@ package com.loafle.overflow.noauthagent.dao; import com.loafle.overflow.noauthagent.model.NoAuthAgent; +import com.loafle.overflow.noauthagent.type.AuthType; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -23,24 +24,37 @@ public class JPANoAuthAgentDAOTest { @Test public void findByTempKey() throws Exception { + + NoAuthAgent noAuthAgent = new NoAuthAgent(); + noAuthAgent.setTempKey("3398473-90847903874"); + + NoAuthAgent aa = this.jpaNoAuthAgentDAO.findByTempKey(noAuthAgent); + + System.out.println(aa.getAuthStatus()); + } @Test public void findAllByNoAuth() throws Exception { } - @Ignore + @Test public void createNoAuthAgent() { NoAuthAgent noAuthAgent = new NoAuthAgent(); + noAuthAgent.setApiKey("aaaaaaa"); noAuthAgent.setDate(new Date()); noAuthAgent.setHostName("Snoop pc"); noAuthAgent.setLocalIP(4123); noAuthAgent.setTempKey("3398473-90847903874"); + noAuthAgent.setAuthStatus(AuthType.WAIT); this.jpaNoAuthAgentDAO.create(noAuthAgent); } + + + } \ No newline at end of file diff --git a/src/test/resources/META-INF/persistence.xml b/src/test/resources/META-INF/persistence.xml index d050fad..ce661fd 100644 --- a/src/test/resources/META-INF/persistence.xml +++ b/src/test/resources/META-INF/persistence.xml @@ -8,6 +8,7 @@ com.loafle.overflow.apikey.model.Apikey com.loafle.overflow.agent.model.Agent com.loafle.overflow.email.model.EmailAuth + com.loafle.overflow.target.model.Target