diff --git a/src/main/java/com/uvasoftware/scanii/internal/DefaultScaniiClient.java b/src/main/java/com/uvasoftware/scanii/internal/DefaultScaniiClient.java
index 39ccd4a..74c0498 100644
--- a/src/main/java/com/uvasoftware/scanii/internal/DefaultScaniiClient.java
+++ b/src/main/java/com/uvasoftware/scanii/internal/DefaultScaniiClient.java
@@ -31,9 +31,9 @@
/**
* Thread safe client to the Scanii content processing service.
- * Please note that this client does not throw checked exceptions, all exceptions are wrapped around a ScaniiException that extends RuntimeException
+ * Please note that this client does not throw checked exceptions; all exceptions are wrapped around a ScaniiException that extends RuntimeException
*
- * @see http://docs.scanii.com/v2.1/resources.html
+ * @see spec
*/
public class DefaultScaniiClient implements ScaniiClient {
private static final Logger LOG = Loggers.build();
@@ -85,7 +85,7 @@ public ScaniiProcessingResult process(Path content, String callback, Map retrieve(String id) {
Objects.requireNonNull(id, "resource id cannot be null");
- HttpGet req = new HttpGet(target.resolve("/v2.1/files/" + id));
+ HttpGet req = new HttpGet(target.resolve("/v2.2/files/" + id));
addHeaders(req);
try {
@@ -227,7 +227,7 @@ public ScaniiPendingResult fetch(String location, String callback, Map fields = new ArrayList<>();
@@ -269,7 +269,7 @@ public ScaniiPendingResult fetch(String location, String callback, Map fields = new ArrayList<>();
@@ -322,7 +322,7 @@ public ScaniiAuthToken createAuthToken(int timeout, TimeUnit timeoutUnit) {
public boolean deleteAuthToken(String id) {
Objects.requireNonNull(id, "id cannot be null");
- HttpDelete req = new HttpDelete(target.resolve("/v2.1/auth/tokens/" + id));
+ HttpDelete req = new HttpDelete(target.resolve("/v2.2/auth/tokens/" + id));
addHeaders(req);
try {
@@ -343,7 +343,7 @@ public boolean deleteAuthToken(String id) {
public ScaniiAuthToken retrieveAuthToken(String id) {
Objects.requireNonNull(id, "id cannot be null");
- HttpGet req = new HttpGet(target.resolve("/v2.1/auth/tokens/" + id));
+ HttpGet req = new HttpGet(target.resolve("/v2.2/auth/tokens/" + id));
addHeaders(req);
try {
@@ -369,7 +369,7 @@ public ScaniiAuthToken retrieveAuthToken(String id) {
@Override
public ScaniiAccountInfo retrieveAccountInfo() {
- HttpGet req = new HttpGet(target.resolve("/v2.1/account.json"));
+ HttpGet req = new HttpGet(target.resolve("/v2.2/account.json"));
addHeaders(req);
try {
diff --git a/src/main/java/com/uvasoftware/scanii/models/ScaniiAccountInfo.java b/src/main/java/com/uvasoftware/scanii/models/ScaniiAccountInfo.java
index e1e21b0..95873f4 100644
--- a/src/main/java/com/uvasoftware/scanii/models/ScaniiAccountInfo.java
+++ b/src/main/java/com/uvasoftware/scanii/models/ScaniiAccountInfo.java
@@ -6,6 +6,7 @@
import java.util.Map;
import java.util.Set;
+@SuppressWarnings("unused")
public class ScaniiAccountInfo extends ScaniiResult {
@JsonProperty("name")
private String name;
@@ -113,7 +114,7 @@ public String toString() {
'}';
}
- private static class User {
+ public static class User {
@JsonProperty("creation_date")
private Instant creationDate;
@JsonProperty("last_login_date")
@@ -136,7 +137,7 @@ public void setLastLoginDate(Instant lastLoginDate) {
}
}
- private static class ApiKey {
+ public static class ApiKey {
@JsonProperty("active")
private boolean active;
@JsonProperty("creation_date")
diff --git a/src/test/java/com/uvasoftware/scanii/ScaniiClientTest.java b/src/test/java/com/uvasoftware/scanii/ScaniiClientTest.java
index dc6e87a..fc2d521 100644
--- a/src/test/java/com/uvasoftware/scanii/ScaniiClientTest.java
+++ b/src/test/java/com/uvasoftware/scanii/ScaniiClientTest.java
@@ -80,7 +80,7 @@ void testProcessWithMetadata() throws Exception {
ScaniiProcessingResult result;
// simple processing clean
- result = client.process(Systems.randomFile(1024), new HashMap() {{
+ result = client.process(Systems.randomFile(1024), new HashMap<>() {{
put("foo", "bar");
}});
Assertions.assertNotNull(result.getResourceId());
@@ -96,7 +96,7 @@ void testProcessInputStreamWithMetadata() throws Exception {
FileInputStream is = new FileInputStream(Systems.randomFile(1024).toFile());
// simple processing clean
- result = client.process(is, new HashMap() {{
+ result = client.process(is, new HashMap<>() {{
put("foo", "bar");
}});
Assertions.assertNotNull(result.getResourceId());
@@ -109,7 +109,7 @@ void testProcessWithMetadataAndCallback() throws Exception {
ScaniiProcessingResult result;
// simple processing clean
- result = client.process(Systems.randomFile(1024), "https://httpbin.org/post", new HashMap() {{
+ result = client.process(Systems.randomFile(1024), "https://httpbin.org/post", new HashMap<>() {{
put("foo", "bar");
}});
Assertions.assertNotNull(result.getResourceId());
@@ -125,7 +125,7 @@ void testProcessInputStreamWithMetadataAndCallback() throws Exception {
FileInputStream is = new FileInputStream(Systems.randomFile(1024).toFile());
// simple processing clean
- result = client.process(is, "https://httpbin.org/post", new HashMap() {{
+ result = client.process(is, "https://httpbin.org/post", new HashMap<>() {{
put("foo", "bar");
}});
Assertions.assertNotNull(result.getResourceId());
@@ -181,7 +181,7 @@ void testProcessAsync() throws Exception {
@Test
void testProcessAsyncWithMetadata() throws Exception {
- ScaniiPendingResult result = client.processAsync(Systems.randomFile(1024), new HashMap() {{
+ ScaniiPendingResult result = client.processAsync(Systems.randomFile(1024), new HashMap<>() {{
put("foo", "bar");
}});
@@ -199,7 +199,7 @@ void testProcessAsyncInputStreamWithMetadata() throws Exception {
FileInputStream is = new FileInputStream(Systems.randomFile(1024).toFile());
- ScaniiPendingResult result = client.processAsync(is, new HashMap() {{
+ ScaniiPendingResult result = client.processAsync(is, new HashMap<>() {{
put("foo", "bar");
}});
@@ -211,7 +211,7 @@ void testProcessAsyncInputStreamWithMetadata() throws Exception {
@Test
void testProcessAsyncWithMetadataAndCallback() throws Exception {
- ScaniiPendingResult result = client.processAsync(Systems.randomFile(1024), "https://httpbin.org/post", new HashMap() {{
+ ScaniiPendingResult result = client.processAsync(Systems.randomFile(1024), "https://httpbin.org/post", new HashMap<>() {{
put("foo", "bar");
}});
@@ -227,7 +227,7 @@ void testProcessAsyncInputStreamWithMetadataAndCallback() throws Exception {
FileInputStream is = new FileInputStream(Systems.randomFile(1024).toFile());
- ScaniiPendingResult result = client.processAsync(is, "https://httpbin.org/post", new HashMap() {{
+ ScaniiPendingResult result = client.processAsync(is, "https://httpbin.org/post", new HashMap<>() {{
put("foo", "bar");
}});
@@ -293,7 +293,7 @@ void testFetchWithCallback() throws InterruptedException {
@Test
void testFetchWithMetadata() throws Exception {
- ScaniiPendingResult result = client.fetch("https://scanii.s3.amazonaws.com/eicarcom2.zip", "http://google.com", new HashMap() {{
+ ScaniiPendingResult result = client.fetch("https://scanii.s3.amazonaws.com/eicarcom2.zip", "http://google.com", new HashMap<>() {{
put("foo", "bar");
}});
Assertions.assertNotNull(result.getResourceId());
@@ -372,8 +372,16 @@ void shouldRetrieveAccountInfo() {
Assertions.assertTrue(account.getStartingBalance() > 0);
Assertions.assertNotNull(account.getCreationDate());
Assertions.assertNotNull(account.getModificationDate());
- Assertions.assertTrue(account.getUsers().size() > 0);
- Assertions.assertTrue(account.getKeys().size() > 0);
+ Assertions.assertFalse(account.getUsers().isEmpty());
+ Assertions.assertFalse(account.getKeys().isEmpty());
+ Assertions.assertFalse(account.getKeys().isEmpty());
+
+ var firstKey = account.getKeys().values().stream().findFirst().orElseThrow();
+ Assertions.assertNotNull(firstKey.getCreationDate());
+ Assertions.assertNotNull(firstKey.getLastSeenDate());
+ Assertions.assertNotNull(firstKey.getDetectionCategoriesEnabled());
+
+
}
@Test