diff --git a/account-dao/pom.xml b/account-dao/pom.xml
index ab5ef37..33948c7 100644
--- a/account-dao/pom.xml
+++ b/account-dao/pom.xml
@@ -27,5 +27,30 @@
de.muehlencord.shared
shared-util
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.3.1
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ 5.3.1
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.3.1
+ test
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.9.8
+ test
+ jar
+
\ No newline at end of file
diff --git a/account-dao/src/main/java/de/muehlencord/shared/account/dao/ApiKeyObject.java b/account-dao/src/main/java/de/muehlencord/shared/account/dao/ApiKeyObject.java
index 004af3e..fba65b4 100644
--- a/account-dao/src/main/java/de/muehlencord/shared/account/dao/ApiKeyObject.java
+++ b/account-dao/src/main/java/de/muehlencord/shared/account/dao/ApiKeyObject.java
@@ -18,6 +18,7 @@ package de.muehlencord.shared.account.dao;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.gson.annotations.Expose;
import java.util.Date;
+import java.util.Objects;
/**
*
@@ -28,10 +29,10 @@ public class ApiKeyObject {
@Expose
private String userName;
@Expose
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm'Z'")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, locale="en_US", timezone = "UTC", pattern="yyyy-MM-dd'T'HH:mm:ss:SSS'Z[UTC]'")
private Date issuedOn;
@Expose
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm'Z'")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, locale="en_US", timezone = "UTC", pattern="yyyy-MM-dd'T'HH:mm:ss:SSS'Z[UTC]'")
private Date expiresOn;
@Expose
private String authToken;
@@ -68,4 +69,37 @@ public class ApiKeyObject {
this.authToken = authToken;
}
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 53 * hash + Objects.hashCode(this.userName);
+ hash = 53 * hash + Objects.hashCode(this.issuedOn);
+ hash = 53 * hash + Objects.hashCode(this.expiresOn);
+ hash = 53 * hash + Objects.hashCode(this.authToken);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ApiKeyObject other = (ApiKeyObject) obj;
+ if (!Objects.equals(this.userName, other.userName)) {
+ return false;
+ }
+ if (!Objects.equals(this.authToken, other.authToken)) {
+ return false;
+ }
+ return true;
+ }
+
+
+
}
diff --git a/account-dao/src/test/java/de/muehlencord/shared/account/dao/ApiKeyObjectTest.java b/account-dao/src/test/java/de/muehlencord/shared/account/dao/ApiKeyObjectTest.java
new file mode 100644
index 0000000..2756c5d
--- /dev/null
+++ b/account-dao/src/test/java/de/muehlencord/shared/account/dao/ApiKeyObjectTest.java
@@ -0,0 +1,41 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package de.muehlencord.shared.account.dao;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.Date;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+
+/**
+ *
+ * @author Joern Muehlencord
+ */
+public class ApiKeyObjectTest {
+
+
+
+ @Test
+ public void testJackson() throws JsonProcessingException, IOException {
+ ApiKeyObject apiKeyObject = new ApiKeyObject();
+ apiKeyObject.setUserName("web");
+ apiKeyObject.setIssuedOn(new Date());
+ apiKeyObject.setExpiresOn(new Date());
+
+ ObjectMapper mapper = new ObjectMapper();
+ String json = mapper.writeValueAsString(apiKeyObject);
+
+ System.out.println(json);
+
+
+ ApiKeyObject apiKeyObject2 = mapper.readValue (json, ApiKeyObject.class);
+ assertTrue (apiKeyObject.equals(apiKeyObject2));
+
+ }
+
+}