Skip to content

Commit

Permalink
added ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
bochkov committed Jan 13, 2019
1 parent 8942825 commit 8f9dc47
Show file tree
Hide file tree
Showing 33 changed files with 162 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'com.jfrog.artifactory' version '4.8.1'
id 'com.jfrog.artifactory' version '4.9.0'
}

group = 'cordelia'
version = '1.2.5.RELEASE'
version = '1.2.6.RELEASE'

apply plugin: 'java'
apply plugin: 'com.jfrog.artifactory'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/BlocklistUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ public final class BlocklistUpdate implements Req {
private final String method;
private final Integer tag;

public BlocklistUpdate() {
this(1);
}

public BlocklistUpdate(Integer tag) {
this.tag = tag;
this.method = "blocklist-update";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/FreeSpace.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public final class FreeSpace implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public FreeSpace(String path) {
this(2, path);
}

public FreeSpace(Integer tag, String path) {
this.method = "free-space";
this.tag = tag;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/PortCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ public final class PortCheck implements Req {
private final String method;
private final Integer tag;

public PortCheck() {
this(3);
}

public PortCheck(Integer tag) {
this.tag = tag;
this.method = "port-test";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cordelia/rpc/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public final class Queue implements OptReq {
private final Map<String, Object> arguments;

public Queue(To to, Object... ids) {
this(null, to, ids);
this(4, to, ids);
}

public Queue(Integer tag, To to, Object... ids) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/RenamePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public final class RenamePath implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public RenamePath(Object id, String path, String name) {
this(5, id, path, name);
}

public RenamePath(Integer tag, Object id, String path, String name) {
this.tag = tag;
this.method = "torrent-rename-path";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/SessionClose.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ public final class SessionClose implements Req {
private final String method;
private final Integer tag;

public SessionClose() {
this(6);
}

public SessionClose(Integer tag) {
this.tag = tag;
this.method = "session-close";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/SessionGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public final class SessionGet implements Req {
private final String method;
private final Integer tag;

public SessionGet() {
this(7);
}

public SessionGet(Integer tag) {
this.tag = tag;
this.method = "session-get";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/SessionSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public final class SessionSet implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public SessionSet(Map<String, Object> options) {
this(8, options);
}

public SessionSet(Integer tag, Map<String, Object> options) {
this.tag = tag;
this.method = "session-set";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/SessionStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public final class SessionStats implements Req {
private final String method;
private final Integer tag;

public SessionStats() {
this(9);
}

public SessionStats(Integer tag) {
this.tag = tag;
this.method = "session-stats";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/Torrent.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public final class Torrent implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public Torrent(Action action, Object... ids) {
this(10, action, ids);
}

public Torrent(Integer tag, Action action, Object... ids) {
this.method = action.method();
this.tag = tag;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/TorrentAdd.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public final class TorrentAdd implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public TorrentAdd(Map<String, Object> options) {
this(11, options);
}

public TorrentAdd(Integer tag, Map<String, Object> options) {
this.tag = tag;
this.method = "torrent-add";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/TorrentGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ public final class TorrentGet implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public TorrentGet(List<String> fields, Object... ids) {
this(12, fields, ids);
}

public TorrentGet(Integer tag, List<String> fields, Object... ids) {
this.tag = tag;
this.method = "torrent-get";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/TorrentMove.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public final class TorrentMove implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public TorrentMove(String location, Boolean move, Object... ids) {
this(13, location, move, ids);
}

public TorrentMove(Integer tag, String location, Boolean move, Object... ids) {
this.tag = tag;
this.method = "torrent-set-location";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/TorrentRemove.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public final class TorrentRemove implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public TorrentRemove(Boolean withData, Object... ids) {
this(14, withData, ids);
}

public TorrentRemove(Integer tag, Boolean withData, Object... ids) {
this.tag = tag;
this.method = "torrent-remove";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cordelia/rpc/TorrentSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public final class TorrentSet implements OptReq {
private final Integer tag;
private final Map<String, Object> arguments;

public TorrentSet(Map<String, Object> options) {
this(15, options);
}

public TorrentSet(Integer tag, Map<String, Object> options) {
this.tag = tag;
this.method = "torrent-set";
Expand Down
8 changes: 7 additions & 1 deletion src/test/java/cordelia/rpc/BlocklistUpdateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ public class BlocklistUpdateTest {
@Test
public void testCtor() {
Req req = new BlocklistUpdate(15);
Assert.assertEquals(new Integer(15), req.tag());
Assert.assertEquals(Integer.valueOf(15), req.tag());
Assert.assertEquals("blocklist-update", req.method());
}

@Test
public void testCtorNoArgs() {
Req req = new BlocklistUpdate();
Assert.assertEquals(Integer.valueOf(1), req.tag());
}
}
8 changes: 7 additions & 1 deletion src/test/java/cordelia/rpc/FreeSpaceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ public class FreeSpaceTest {
public void testCtor() {
OptReq req = new FreeSpace(12, "/tmp");
Assert.assertEquals("free-space", req.method());
Assert.assertEquals(new Integer(12), req.tag());
Assert.assertEquals(Integer.valueOf(12), req.tag());
Assert.assertEquals(
"/tmp",
req.arguments().get("path")
);
}

@Test
public void testCtorNoArgs() {
Req req = new FreeSpace("/tmp");
Assert.assertEquals(Integer.valueOf(2), req.tag());
}
}
8 changes: 7 additions & 1 deletion src/test/java/cordelia/rpc/PortCheckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ public class PortCheckTest {
@Test
public void testCtor() {
Req req = new PortCheck(11);
Assert.assertEquals(new Integer(11), req.tag());
Assert.assertEquals(Integer.valueOf(11), req.tag());
Assert.assertEquals("port-test", req.method());
}

@Test
public void testCtorNoArgs() {
Req req = new PortCheck();
Assert.assertEquals(Integer.valueOf(3), req.tag());
}
}
10 changes: 8 additions & 2 deletions src/test/java/cordelia/rpc/QueueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@ public class QueueTest {
@Test
public void testArgs() {
OptReq req = new Queue(10, Queue.To.TOP, 101, 102, 103);
Assert.assertEquals(new Integer(10), req.tag());
Assert.assertEquals(Integer.valueOf(10), req.tag());
Assert.assertEquals(
Arrays.asList(101, 102, 103),
req.arguments().get("ids")
);
}

@Test
public void testCtorNoArgs() {
Req req = new Queue(Queue.To.TOP, 101, 102, 103);
Assert.assertEquals(Integer.valueOf(4), req.tag());
}

@Test
public void testEmpty() {
OptReq req = new Queue(Queue.To.TOP);
Assert.assertNull(req.tag());
Assert.assertNotNull(req.tag());
Assert.assertEquals("queue-move-top", req.method());
Assert.assertNotNull(req.arguments());
Assert.assertNull(req.arguments().get("ids"));
Expand Down
9 changes: 7 additions & 2 deletions src/test/java/cordelia/rpc/RenamePathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import org.junit.Assert;
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;

public class RenamePathTest {

@Test
public void testCtor() {
OptReq req = new RenamePath(9, 15, "/tmp/dest", "src");
Assert.assertEquals(new Integer(9), req.tag());
Assert.assertEquals(Integer.valueOf(9), req.tag());
Assert.assertEquals("torrent-rename-path", req.method());
Assert.assertEquals(
Collections.singletonList(15),
Expand All @@ -26,4 +25,10 @@ public void testCtor() {
req.arguments().get("name")
);
}

@Test
public void testCtorNoArgs() {
Req req = new RenamePath(15, "/tmp/dest", "src");
Assert.assertEquals(Integer.valueOf(5), req.tag());
}
}
7 changes: 6 additions & 1 deletion src/test/java/cordelia/rpc/SessionCloseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ public class SessionCloseTest {
@Test
public void testCtor() {
Req req = new SessionClose(15);
Assert.assertEquals(new Integer(15), req.tag());
Assert.assertEquals(Integer.valueOf(15), req.tag());
Assert.assertEquals("session-close", req.method());
}

@Test
public void testCtorNoArgs() {
Req req = new SessionClose();
Assert.assertEquals(Integer.valueOf(6), req.tag());
}
}
8 changes: 7 additions & 1 deletion src/test/java/cordelia/rpc/SessionGetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ public class SessionGetTest {
@Test
public void testCtor() {
Req req = new SessionGet(14);
Assert.assertEquals(new Integer(14), req.tag());
Assert.assertEquals(Integer.valueOf(14), req.tag());
Assert.assertEquals("session-get", req.method());
}

@Test
public void testCtorNoArgs() {
Req req = new SessionGet();
Assert.assertEquals(Integer.valueOf(7), req.tag());
}
}
8 changes: 7 additions & 1 deletion src/test/java/cordelia/rpc/SessionSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ public class SessionSetTest {
@Test
public void testCtor() {
OptReq req = new SessionSet(9, new MapOf<>(new MapEntry<>("test", "test")));
Assert.assertEquals(new Integer(9), req.tag());
Assert.assertEquals(Integer.valueOf(9), req.tag());
Assert.assertEquals("session-set", req.method());
Assert.assertEquals(
"test",
req.arguments().get("test")
);
}

@Test
public void testCtorNoArgs() {
Req req = new SessionSet(new MapOf<>(new MapEntry<>("test", "test")));
Assert.assertEquals(Integer.valueOf(8), req.tag());
}
}
8 changes: 7 additions & 1 deletion src/test/java/cordelia/rpc/SessionStatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ public class SessionStatsTest {
@Test
public void testCtor() {
Req req = new SessionStats(12);
Assert.assertEquals(new Integer(12), req.tag());
Assert.assertEquals(Integer.valueOf(12), req.tag());
Assert.assertEquals("session-stats", req.method());
}

@Test
public void testCtorNoArgs() {
Req req = new SessionStats();
Assert.assertEquals(Integer.valueOf(9), req.tag());
}
}
7 changes: 6 additions & 1 deletion src/test/java/cordelia/rpc/TorrentAddTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ public class TorrentAddTest {
@Test
public void testCtor() {
OptReq req = new TorrentAdd(4, new MapOf<>(new MapEntry<>("filename", "test")));
Assert.assertEquals(new Integer(4), req.tag());
Assert.assertEquals(Integer.valueOf(4), req.tag());
Assert.assertEquals("torrent-add", req.method());
Assert.assertEquals(
"test",
req.arguments().get("filename")
);
}

@Test
public void testCtorNoArgs() {
Req req = new TorrentAdd(new MapOf<>(new MapEntry<>("filename", "test")));
Assert.assertEquals(Integer.valueOf(11), req.tag());
}
}
8 changes: 7 additions & 1 deletion src/test/java/cordelia/rpc/TorrentGetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TorrentGetTest {
@Test
public void testCtor() {
OptReq req = new TorrentGet(1, Arrays.asList("field1", "field2"), 10, 11, 12);
Assert.assertEquals(new Integer(1), req.tag());
Assert.assertEquals(Integer.valueOf(1), req.tag());
Assert.assertEquals("torrent-get", req.method());
Assert.assertEquals(
Arrays.asList("field1", "field2"),
Expand All @@ -21,4 +21,10 @@ public void testCtor() {
req.arguments().get("ids")
);
}

@Test
public void testCtorNoArgs() {
Req req = new TorrentGet(Arrays.asList("field1", "field2"), 10, 11, 12);
Assert.assertEquals(Integer.valueOf(12), req.tag());
}
}
Loading

0 comments on commit 8f9dc47

Please sign in to comment.