Skip to content

Commit

Permalink
Simplified test.
Browse files Browse the repository at this point in the history
Reviewed Rules for linter error.
  • Loading branch information
cdr-chakotay committed Jun 5, 2024
1 parent 7e49c5a commit fd21fb2
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/test/java/io/tus/java/client/TestTusClient.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package io.tus.java.client;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
Expand All @@ -21,6 +16,12 @@
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
* Class to test the tus-Client.
*/
Expand All @@ -32,7 +33,7 @@ public class TestTusClient extends MockServerProvider {
@Test
public void testTusClient() {
TusClient client = new TusClient();
assertEquals(client.getUploadCreationURL(), null);
assertNull(client.getUploadCreationURL());
}

/**
Expand Down Expand Up @@ -63,14 +64,14 @@ public void testSetUploadCreationURL() throws MalformedURLException {
@Test
public void testEnableResuming() {
TusClient client = new TusClient();
assertEquals(client.resumingEnabled(), false);
assertFalse(client.resumingEnabled());

TusURLStore store = new TusURLMemoryStore();
client.enableResuming(store);
assertEquals(client.resumingEnabled(), true);
assertTrue(client.resumingEnabled());

client.disableResuming();
assertEquals(client.resumingEnabled(), false);
assertFalse(client.resumingEnabled());
}

/**
Expand Down Expand Up @@ -250,20 +251,20 @@ public void testResumeUpload() throws ResumingNotEnabledException, FingerprintNo
*/
private class TestResumeUploadStore implements TusURLStore {
public void set(String fingerprint, URL url) {
assertTrue("set method must not be called", false);
fail("set method must not be called");
}

public URL get(String fingerprint) {
assertEquals(fingerprint, "test-fingerprint");

try {
return new URL(mockServerURL.toString() + "/foo");
} catch (Exception e) { }
} catch (Exception ignored) { }
return null;
}

public void remove(String fingerprint) {
assertTrue("remove method must not be called", false);
fail("remove method must not be called");
}
}

Expand Down Expand Up @@ -513,14 +514,14 @@ public void testRemoveFingerprintOnSuccessDisabled() throws IOException, Protoco
store.set("fingerprint", dummyURL);
client.enableResuming(store);

assertTrue(!client.removeFingerprintOnSuccessEnabled());
assertFalse(client.removeFingerprintOnSuccessEnabled());

TusUpload upload = new TusUpload();
upload.setFingerprint("fingerprint");

client.uploadFinished(upload);

assertTrue(dummyURL.equals(store.get("fingerprint")));
assertEquals(dummyURL, store.get("fingerprint"));

}

Expand Down Expand Up @@ -548,7 +549,7 @@ public void testRemoveFingerprintOnSuccessEnabled() throws IOException, Protocol

client.uploadFinished(upload);

assertTrue(store.get("fingerprint") == null);
assertNull(store.get("fingerprint"));

}
}

0 comments on commit fd21fb2

Please sign in to comment.