From 2ed287d9fe6034dc45362756c05a17cf50d5d910 Mon Sep 17 00:00:00 2001 From: Nikhil VK Date: Fri, 6 Dec 2019 12:55:08 +0530 Subject: [PATCH 1/2] Added order_by and skip_if parameters in WorkflowRuleTarget --- .../twilio/taskrouter/WorkflowRuleTarget.java | 54 +++++++++++++++++++ .../taskrouter/WorkflowRuleTargetTest.java | 4 +- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java b/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java index 3a9de41593..3db74ffc6c 100644 --- a/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java +++ b/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java @@ -26,6 +26,12 @@ public class WorkflowRuleTarget extends TaskRouterResource { @JsonProperty("timeout") private final Integer timeout; + + @JsonProperty("order_by") + private String orderBy; + + @JsonProperty("skip_if") + private String skipIf; @JsonCreator private WorkflowRuleTarget( @@ -45,6 +51,8 @@ private WorkflowRuleTarget(Builder b) throws IllegalArgumentException { this.expression = b.expression; this.priority = b.priority; this.timeout = b.timeout; + this.orderBy = b.orderBy; + this.skipIf = b.skipIf; } /** @@ -79,6 +87,38 @@ public Integer getTimeout() { return timeout; } + /** + * Get the orderBy for the workflow rule target. + * @return the orderBy + */ + public String getOrderBy() { + return orderBy; + } + + /** + * Sets the orderBy for the workflow rule target. + * @param orderBy the orderBy + */ + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + /** + * Get the skipIf for the workflow rule target. + * @return the skipIf + */ + public String getSkipIf() { + return skipIf; + } + + /** + * Sets the skipIf for the workflow rule target. + * @param skipIf the skipIf + */ + public void setSkipIf(String skipIf) { + this.skipIf = skipIf; + } + /** * Return a string representation of this workflow rule target. * @return string representation of target @@ -90,6 +130,8 @@ public String toString() { .add("expression", expression) .add("priority", priority) .add("timeout", timeout) + .add("orderBy", orderBy) + .add("skipIf", skipIf) .toString(); } @@ -111,6 +153,8 @@ public static class Builder { private String expression; private Integer priority; private Integer timeout; + private String orderBy; + private String skipIf; public Builder(String queue) { this.queue = queue; @@ -130,6 +174,16 @@ public Builder timeout(Integer timeout) { this.timeout = timeout; return this; } + + public Builder orderBy(String orderBy) { + this.orderBy = orderBy; + return this; + } + + public Builder skipIf(String skipIf) { + this.skipIf = skipIf; + return this; + } public WorkflowRuleTarget build() { return new WorkflowRuleTarget(this); diff --git a/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java b/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java index c887a7de30..9d4ae0b4c1 100644 --- a/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java +++ b/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java @@ -16,10 +16,12 @@ public void testToJson() throws IOException { .expression("1==1") .priority(5) .timeout(30) + .orderBy("worker.english_level ASC") + .skipIf("workers.available == 0") .build(); Assert.assertEquals( - "{\"queue\":\"QS123\",\"expression\":\"1==1\",\"priority\":5,\"timeout\":30}", + "{\"queue\":\"QS123\",\"expression\":\"1==1\",\"priority\":5,\"timeout\":30,\"order_by\":\"worker.english_level ASC\",\"skip_if\":\"workers.available == 0\"}", target.toJson() ); } From 29cf449addd71c21258b2182b408eccf0799dc79 Mon Sep 17 00:00:00 2001 From: Nikhil VK Date: Fri, 6 Dec 2019 13:55:57 +0530 Subject: [PATCH 2/2] Added order_by and skip_if parameters in WorkflowRuleTarget --- .../twilio/taskrouter/WorkflowRuleTarget.java | 26 +++++-------------- .../taskrouter/WorkflowRuleTargetTest.java | 4 ++- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java b/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java index 3db74ffc6c..4c9e51b74b 100644 --- a/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java +++ b/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java @@ -28,22 +28,26 @@ public class WorkflowRuleTarget extends TaskRouterResource { private final Integer timeout; @JsonProperty("order_by") - private String orderBy; + private final String orderBy; @JsonProperty("skip_if") - private String skipIf; + private final String skipIf; @JsonCreator private WorkflowRuleTarget( @JsonProperty("queue") String queue, @JsonProperty("expression") String expression, @JsonProperty("priority") Integer priority, - @JsonProperty("timeout") Integer timeout + @JsonProperty("timeout") Integer timeout, + @JsonProperty("order_by") String orderBy, + @JsonProperty("skip_if") String skipIf ) { this.queue = queue; this.expression = expression; this.priority = priority; this.timeout = timeout; + this.orderBy = orderBy; + this.skipIf = skipIf; } private WorkflowRuleTarget(Builder b) throws IllegalArgumentException { @@ -95,14 +99,6 @@ public String getOrderBy() { return orderBy; } - /** - * Sets the orderBy for the workflow rule target. - * @param orderBy the orderBy - */ - public void setOrderBy(String orderBy) { - this.orderBy = orderBy; - } - /** * Get the skipIf for the workflow rule target. * @return the skipIf @@ -111,14 +107,6 @@ public String getSkipIf() { return skipIf; } - /** - * Sets the skipIf for the workflow rule target. - * @param skipIf the skipIf - */ - public void setSkipIf(String skipIf) { - this.skipIf = skipIf; - } - /** * Return a string representation of this workflow rule target. * @return string representation of target diff --git a/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java b/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java index 9d4ae0b4c1..9651c50033 100644 --- a/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java +++ b/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java @@ -29,11 +29,13 @@ public void testToJson() throws IOException { @Test public void testFromJson() throws IOException { WorkflowRuleTarget target = - WorkflowRuleTarget.fromJson("{\"queue\":\"QS123\",\"expression\":\"1==1\",\"priority\":5,\"timeout\":30}"); + WorkflowRuleTarget.fromJson("{\"queue\":\"QS123\",\"expression\":\"1==1\",\"priority\":5,\"timeout\":30,\"order_by\":\"worker.english_level ASC\",\"skip_if\":\"workers.available == 0\"}"); Assert.assertEquals("QS123", target.getQueue()); Assert.assertEquals("1==1", target.getExpression()); Assert.assertEquals(5, (int)target.getPriority()); Assert.assertEquals(30, (int)target.getTimeout()); + Assert.assertEquals("worker.english_level ASC", target.getOrderBy()); + Assert.assertEquals("workers.available == 0", target.getSkipIf()); } }