diff --git a/README.md b/README.md
index 16c08fb..93d8444 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,10 @@ This project has been in general use within our offices for over a year, having
* TestInstance - A single instance of a Test Case in the context of a Test Run. Results of "PASS", "FAIL", "WARNING", etc are reported directly against this entity
* TestResult - The execution record of a single Test Instance within a given Test Run
+## Entities NOT supported
+
+* Attachment entity is not implemented
+
## Modeling Custom Fields
TestRail allows you to add custom fields to many entities. We support this, but you'll have to work a little harder to implement. When parsing the JSON entities that support custom fields, the Jackson processor ignores "unknown" fields
diff --git a/pom.xml b/pom.xml
index a7e0b53..fa3a51f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,40 +44,34 @@
testrailsdk-1.1
-
-
- org.codehaus.jackson
- jackson-mapper-asl
- 1.9.9
-
-
- org.slf4j
- slf4j-api
- 1.6.6
-
+
- org.apache.commons
- commons-lang3
- 3.1
-
-
- org.apache.httpcomponents
- httpclient
- [4.3.6,)
-
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.11.4
+
+
+ org.apache.commons
+ commons-lang3
+ 3.11
+
+
+ org.apache.httpcomponents
+ httpclient
+ [4.3.6,)
+
ch.qos.logback
logback-classic
- 1.0.9
- test
+ 1.2.3
junit
junit
- 4.10
+ 4.12
test
-
+
@@ -98,7 +92,7 @@
org.apache.maven.plugins
maven-source-plugin
- 3.0.0
+ 3.2.1
attach-sources
@@ -111,7 +105,10 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 2.10.3
+ 3.2.0
+
+ 11
+
attach-javadocs
@@ -122,18 +119,9 @@
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.6
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
+ org.simplify4u.plugins
+ sign-maven-plugin
+ 0.3.0
org.sonatype.plugins
@@ -152,20 +140,34 @@
-
-
- maven-compiler-plugin
- 3.5.1
-
- 1.6
- 1.6
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.19.1
+
+
+ maven-compiler-plugin
+ 3.8.1
+
+ 11
+ 11
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.2
-
+
diff --git a/src/main/java/com/rmn/testrail/entity/BasicPaged.java b/src/main/java/com/rmn/testrail/entity/BasicPaged.java
new file mode 100644
index 0000000..a12b35b
--- /dev/null
+++ b/src/main/java/com/rmn/testrail/entity/BasicPaged.java
@@ -0,0 +1,57 @@
+package com.rmn.testrail.entity;
+
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+/**
+ * This object represents paginated response from TestRail API for bulk artifacts that reflect v6.7 and
+ * are specified on the {@link JsonAlias} annotation on "list" field
+ *
+ * @author mgage
+ */
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class BasicPaged extends BaseEntity {
+
+ @JsonProperty("offset")
+ private Integer offset;
+ public Integer getOffset() { return offset; }
+ public void setOffset(Integer offset) { this.offset = offset; }
+
+ @JsonProperty("limit")
+ private Integer limit;
+ public Integer getLimit() { return limit; }
+ public void setLimit(Integer limit) { this.limit = limit; }
+
+ @JsonProperty("size")
+ private Integer size;
+ public Integer getSize() { return size; }
+ public void setSize(Integer size) { this.size = size; }
+
+ @JsonProperty("_links")
+ private Links links;
+ public Links getLinks() { return links; }
+ public void setLinks(Links links) { this.links = links; }
+
+ @JsonAlias({ "attachments", "cases", "milestones", "plans", "projects", "results", "runs", "sections", "tests" })
+ private List> list;
+ public List> getList() { return list; }
+ public void setList(List> list) { this.list = list; }
+
+
+ private static class Links {
+
+ @JsonProperty("next")
+ private String next;
+ public String getNext() { return next; }
+ public void setNext(String next) { this.next = next; }
+
+ @JsonProperty("prev")
+ private String prev;
+ public String getPrev() { return prev; }
+ public void setPrev(String prev) { this.prev = prev; }
+ }
+}
diff --git a/src/main/java/com/rmn/testrail/entity/BulkEntityCategory.java b/src/main/java/com/rmn/testrail/entity/BulkEntityCategory.java
new file mode 100644
index 0000000..7f6d5a7
--- /dev/null
+++ b/src/main/java/com/rmn/testrail/entity/BulkEntityCategory.java
@@ -0,0 +1,57 @@
+package com.rmn.testrail.entity;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.NoSuchElementException;
+
+/**
+ * This Enumeration represents bulk end-point api Json types for returned paginated entity
+ * bulktype - represents short type name in lower case for entities in the data model
+ *
+ * Note: Includes only APIs supporting pagination as of TestRail 6.7
+ */
+
+public enum BulkEntityCategory {
+
+ ATTACHMENT("attachment"),
+ MILESTONE("milestone"),
+ PROJECT("project"),
+ RESULT("result"),
+ TESTCASE("testcase"), //The free standing test case used as a template for test entity
+ TESTINSTANCE("testinstance"), //The test entity attached to either run or plan to report against
+ TESTPLAN("testplan"),
+ TESTRUN("testrun"),
+ SECTION("section"),
+ TESTRESULT("testresult");
+
+ private static final Logger log = LoggerFactory.getLogger(BulkEntityCategory.class);
+ private final String bulkType;
+
+ BulkEntityCategory(String bulkType) {
+ this.bulkType = bulkType;
+ }
+
+ public String getBulkType() {
+ return bulkType;
+ }
+
+ public static boolean isBulkCategory(String category) {
+ try {
+ fromBulkType(category);
+ return true;
+ } catch (NoSuchElementException ex) {
+ log.debug("Non-paged (bulk) object type detected. '{}'", ex.toString());
+ return false;
+ }
+ }
+
+ public static BulkEntityCategory fromBulkType(String bulkType) {
+
+ return Arrays.stream(BulkEntityCategory.values())
+ .filter(t -> t.getBulkType().equals(bulkType))
+ .findFirst()
+ .orElseThrow();
+ }
+}
diff --git a/src/main/java/com/rmn/testrail/entity/EmptyMilestone.java b/src/main/java/com/rmn/testrail/entity/EmptyMilestone.java
index f32f636..b6c31d3 100644
--- a/src/main/java/com/rmn/testrail/entity/EmptyMilestone.java
+++ b/src/main/java/com/rmn/testrail/entity/EmptyMilestone.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author jsteigel
diff --git a/src/main/java/com/rmn/testrail/entity/Milestone.java b/src/main/java/com/rmn/testrail/entity/Milestone.java
index 2b01717..add8ca5 100644
--- a/src/main/java/com/rmn/testrail/entity/Milestone.java
+++ b/src/main/java/com/rmn/testrail/entity/Milestone.java
@@ -1,10 +1,19 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
+ * 'milestones' - optional field is not implemented. TestRail 5.3 data type 'array'. Only available with get_milestone
+ * Note: milestone could be included with {@link JsonInclude}
+ * example: @JsonInclude(value=Include.NON_NULL, content=Include.NON_NULL)
+ * or consider @JsonInclude(value=Include.NON_ABSENT)
+ *
* @author jsteigel
*/
+
+@JsonIgnoreProperties(ignoreUnknown = true)
public class Milestone extends BaseEntity {
@JsonProperty("id")
private Integer id;
@@ -45,4 +54,24 @@ public class Milestone extends BaseEntity {
private Integer projectId;
public Integer getProjectId() { return projectId; }
public void setProjectId(Integer projectId) { this.projectId = projectId; }
-}
\ No newline at end of file
+
+ @JsonProperty("start_on")
+ private String startOn;
+ public String getStartOn() { return startOn; }
+ public void setStartOn(String startOn) { this.startOn = startOn; }
+
+ @JsonProperty("started_on")
+ private String startedOn;
+ public String getStartedOn() { return startedOn; }
+ public void setStartedOn(String startedOn) { this.startedOn = startedOn; }
+
+ @JsonProperty("is_started")
+ private String isStarted;
+ public String getIsStarted() { return isStarted; }
+ public void setIsStarted(String isStarted) { this.isStarted = isStarted; }
+
+ @JsonProperty("parent_id")
+ private String parentId;
+ public String getParentId() { return parentId; }
+ public void setParentId(String parentId) { this.parentId = parentId; }
+}
diff --git a/src/main/java/com/rmn/testrail/entity/PlanEntry.java b/src/main/java/com/rmn/testrail/entity/PlanEntry.java
index b7b2ebc..04bff7e 100644
--- a/src/main/java/com/rmn/testrail/entity/PlanEntry.java
+++ b/src/main/java/com/rmn/testrail/entity/PlanEntry.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/PlanEntryRun.java b/src/main/java/com/rmn/testrail/entity/PlanEntryRun.java
index ea289fa..6ebd2c8 100644
--- a/src/main/java/com/rmn/testrail/entity/PlanEntryRun.java
+++ b/src/main/java/com/rmn/testrail/entity/PlanEntryRun.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/Priority.java b/src/main/java/com/rmn/testrail/entity/Priority.java
index c866e4d..b147640 100644
--- a/src/main/java/com/rmn/testrail/entity/Priority.java
+++ b/src/main/java/com/rmn/testrail/entity/Priority.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author vliao
diff --git a/src/main/java/com/rmn/testrail/entity/Project.java b/src/main/java/com/rmn/testrail/entity/Project.java
index 8f55e1e..abb5a0f 100644
--- a/src/main/java/com/rmn/testrail/entity/Project.java
+++ b/src/main/java/com/rmn/testrail/entity/Project.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/ProjectCreator.java b/src/main/java/com/rmn/testrail/entity/ProjectCreator.java
index e00e710..87fcc4b 100644
--- a/src/main/java/com/rmn/testrail/entity/ProjectCreator.java
+++ b/src/main/java/com/rmn/testrail/entity/ProjectCreator.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/Section.java b/src/main/java/com/rmn/testrail/entity/Section.java
index 72e9378..38741f2 100644
--- a/src/main/java/com/rmn/testrail/entity/Section.java
+++ b/src/main/java/com/rmn/testrail/entity/Section.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/SectionCreator.java b/src/main/java/com/rmn/testrail/entity/SectionCreator.java
index 6acb759..5406a04 100644
--- a/src/main/java/com/rmn/testrail/entity/SectionCreator.java
+++ b/src/main/java/com/rmn/testrail/entity/SectionCreator.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author ragePowered
diff --git a/src/main/java/com/rmn/testrail/entity/Step.java b/src/main/java/com/rmn/testrail/entity/Step.java
index 2448335..6e078d2 100644
--- a/src/main/java/com/rmn/testrail/entity/Step.java
+++ b/src/main/java/com/rmn/testrail/entity/Step.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
public class Step extends BaseEntity {
diff --git a/src/main/java/com/rmn/testrail/entity/StepResult.java b/src/main/java/com/rmn/testrail/entity/StepResult.java
index 9b4c15a..503319a 100644
--- a/src/main/java/com/rmn/testrail/entity/StepResult.java
+++ b/src/main/java/com/rmn/testrail/entity/StepResult.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
public class StepResult extends Step {
diff --git a/src/main/java/com/rmn/testrail/entity/TestCase.java b/src/main/java/com/rmn/testrail/entity/TestCase.java
index 015a3fe..95c8972 100644
--- a/src/main/java/com/rmn/testrail/entity/TestCase.java
+++ b/src/main/java/com/rmn/testrail/entity/TestCase.java
@@ -1,7 +1,7 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/TestInstance.java b/src/main/java/com/rmn/testrail/entity/TestInstance.java
index 969e5e5..9a302dc 100644
--- a/src/main/java/com/rmn/testrail/entity/TestInstance.java
+++ b/src/main/java/com/rmn/testrail/entity/TestInstance.java
@@ -2,8 +2,8 @@
import com.rmn.testrail.parameters.ApiFilterValue;
import com.rmn.testrail.parameters.GetResultsFilter;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@@ -11,6 +11,8 @@
* The TestRail top-level entity is actually called a "Test", but that collides with the @Test annotation we're
* using in the unit tests. Calling it a TestInstance will avoid ambiguity
*
+ * Note: Custom Fields are ignored in this object
+ *
* @author mmerrell
*/
@JsonIgnoreProperties(ignoreUnknown = true)
diff --git a/src/main/java/com/rmn/testrail/entity/TestPlan.java b/src/main/java/com/rmn/testrail/entity/TestPlan.java
index 153a4d3..b51493c 100644
--- a/src/main/java/com/rmn/testrail/entity/TestPlan.java
+++ b/src/main/java/com/rmn/testrail/entity/TestPlan.java
@@ -1,12 +1,14 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
/**
+ * 'refs' - optional field is not implemented. TestRail 6.3 data type 'string'.
+ *
* @author mmerrell
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -122,7 +124,7 @@ public List getTestRuns() {
//Get the first TestRun in each "entry:run" element and pile it up with the first entries in all the other TestRunGroups to form one list of TestRuns. Not sure this is the ideal way to do
// things, but by leaving getEntries() public you can get to the other test runs on your own
- List testRuns = new ArrayList(entries.size());
+ List testRuns = new ArrayList<>(entries.size());
for (TestRunGroup group: entries) {
TestRun testRun = group.getRuns().get(0);
if (null != testRun) {
diff --git a/src/main/java/com/rmn/testrail/entity/TestPlanCreator.java b/src/main/java/com/rmn/testrail/entity/TestPlanCreator.java
index 1bcb78a..8db0a2a 100644
--- a/src/main/java/com/rmn/testrail/entity/TestPlanCreator.java
+++ b/src/main/java/com/rmn/testrail/entity/TestPlanCreator.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/TestResult.java b/src/main/java/com/rmn/testrail/entity/TestResult.java
index 448a2c3..af1c4ff 100644
--- a/src/main/java/com/rmn/testrail/entity/TestResult.java
+++ b/src/main/java/com/rmn/testrail/entity/TestResult.java
@@ -1,7 +1,7 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/TestResults.java b/src/main/java/com/rmn/testrail/entity/TestResults.java
index 268492c..3b3f716 100644
--- a/src/main/java/com/rmn/testrail/entity/TestResults.java
+++ b/src/main/java/com/rmn/testrail/entity/TestResults.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
@@ -12,7 +12,7 @@
*/
public class TestResults extends BaseEntity {
@JsonProperty("results")
- private List results = new ArrayList();
+ private List results = new ArrayList<>();
public List getResults() { return results; }
public void setResults(List results) { this.results = results; }
diff --git a/src/main/java/com/rmn/testrail/entity/TestRun.java b/src/main/java/com/rmn/testrail/entity/TestRun.java
index 949bd91..21b5526 100644
--- a/src/main/java/com/rmn/testrail/entity/TestRun.java
+++ b/src/main/java/com/rmn/testrail/entity/TestRun.java
@@ -1,13 +1,16 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* This class has all the fields in a TestRun API request.
*
+ * 'updated_on' - optional field is not implemented (timestamp)
+ * 'refs' - optional field is not implemented (string)
+ *
* @author mmerrell
*/
@JsonIgnoreProperties(ignoreUnknown = true)
diff --git a/src/main/java/com/rmn/testrail/entity/TestRunCreator.java b/src/main/java/com/rmn/testrail/entity/TestRunCreator.java
index d197ad1..ea5904b 100644
--- a/src/main/java/com/rmn/testrail/entity/TestRunCreator.java
+++ b/src/main/java/com/rmn/testrail/entity/TestRunCreator.java
@@ -1,7 +1,7 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* This class has all the fields that you can provide when creating a TestRun
diff --git a/src/main/java/com/rmn/testrail/entity/TestRunGroup.java b/src/main/java/com/rmn/testrail/entity/TestRunGroup.java
index 058d1c4..51b4d4c 100644
--- a/src/main/java/com/rmn/testrail/entity/TestRunGroup.java
+++ b/src/main/java/com/rmn/testrail/entity/TestRunGroup.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/TestRunUpdater.java b/src/main/java/com/rmn/testrail/entity/TestRunUpdater.java
index a83a272..a19c1b3 100644
--- a/src/main/java/com/rmn/testrail/entity/TestRunUpdater.java
+++ b/src/main/java/com/rmn/testrail/entity/TestRunUpdater.java
@@ -1,7 +1,7 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* This class has the available fields when updating a TestRun.
diff --git a/src/main/java/com/rmn/testrail/entity/TestStatus.java b/src/main/java/com/rmn/testrail/entity/TestStatus.java
index 06450c6..1d8ce5c 100644
--- a/src/main/java/com/rmn/testrail/entity/TestStatus.java
+++ b/src/main/java/com/rmn/testrail/entity/TestStatus.java
@@ -12,7 +12,7 @@
* @author mmerrell
*/
public class TestStatus {
- private static Map allStatus = new HashMap();
+ private static Map allStatus = new HashMap<>();
static {
allStatus.put("Passed", 1);
diff --git a/src/main/java/com/rmn/testrail/entity/TestSuite.java b/src/main/java/com/rmn/testrail/entity/TestSuite.java
index 6b19a35..10be270 100644
--- a/src/main/java/com/rmn/testrail/entity/TestSuite.java
+++ b/src/main/java/com/rmn/testrail/entity/TestSuite.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/TestSuiteCreator.java b/src/main/java/com/rmn/testrail/entity/TestSuiteCreator.java
index eb70d14..f47aae8 100644
--- a/src/main/java/com/rmn/testrail/entity/TestSuiteCreator.java
+++ b/src/main/java/com/rmn/testrail/entity/TestSuiteCreator.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author mmerrell
diff --git a/src/main/java/com/rmn/testrail/entity/UpdatePlanEntry.java b/src/main/java/com/rmn/testrail/entity/UpdatePlanEntry.java
index 6627fa4..ecce97a 100644
--- a/src/main/java/com/rmn/testrail/entity/UpdatePlanEntry.java
+++ b/src/main/java/com/rmn/testrail/entity/UpdatePlanEntry.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/src/main/java/com/rmn/testrail/entity/User.java b/src/main/java/com/rmn/testrail/entity/User.java
index 1d5869d..f2a7e18 100644
--- a/src/main/java/com/rmn/testrail/entity/User.java
+++ b/src/main/java/com/rmn/testrail/entity/User.java
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author mmerrell
diff --git a/src/main/java/com/rmn/testrail/parameters/GetCasesFilter.java b/src/main/java/com/rmn/testrail/parameters/GetCasesFilter.java
index 1a890f9..61e244c 100644
--- a/src/main/java/com/rmn/testrail/parameters/GetCasesFilter.java
+++ b/src/main/java/com/rmn/testrail/parameters/GetCasesFilter.java
@@ -10,7 +10,9 @@ public enum GetCasesFilter implements ApiFilter {
CREATED_AFTER("created_after"),
CREATED_BEFORE("created_before"),
CREATED_BY("created_by"),
+ LIMIT("limit"), //250 by default. requires TestRail 6.7 or later
MILESTONE_ID("milestone_id"),
+ OFFSET("offset"), //requires TestRail 6.7 or later
PRIORITY_ID("priority_id"),
TEMPLATE_ID("template_id"),
TYPE_ID("type_id"),
@@ -18,8 +20,10 @@ public enum GetCasesFilter implements ApiFilter {
UPDATED_BEFORE("updated_before"),
UPDATED_BY("updated_by");
- private String filter;
- GetCasesFilter(String filter) { this.filter = filter; }
+ private final String filter;
+ GetCasesFilter(String filter) {
+ this.filter = filter;
+ }
public String getFilter() {
return filter;
diff --git a/src/main/java/com/rmn/testrail/parameters/GetMilestonesFilter.java b/src/main/java/com/rmn/testrail/parameters/GetMilestonesFilter.java
index b60965e..3bfcb1c 100644
--- a/src/main/java/com/rmn/testrail/parameters/GetMilestonesFilter.java
+++ b/src/main/java/com/rmn/testrail/parameters/GetMilestonesFilter.java
@@ -7,10 +7,15 @@
*/
public enum GetMilestonesFilter implements ApiFilter {
//Request filter for get_milestones
- IS_COMPLETED("is_completed");
+ IS_COMPLETED("is_completed"),
+ IS_STARTED("is_started"),
+ LIMIT("limit"), //250 by default. requires TestRail 6.7 or later
+ OFFSET("offset"); //requires TestRail 6.7 or later
- private String filter;
- GetMilestonesFilter(String filter) { this.filter = filter; }
+ private final String filter;
+ GetMilestonesFilter(String filter) {
+ this.filter = filter;
+ }
public String getFilter() {
return filter;
diff --git a/src/main/java/com/rmn/testrail/parameters/GetPlansFilter.java b/src/main/java/com/rmn/testrail/parameters/GetPlansFilter.java
index eede747..edc4b30 100644
--- a/src/main/java/com/rmn/testrail/parameters/GetPlansFilter.java
+++ b/src/main/java/com/rmn/testrail/parameters/GetPlansFilter.java
@@ -12,10 +12,13 @@ public enum GetPlansFilter implements ApiFilter{
CREATED_BY("created_by"),
IS_COMPLETED("is_completed"),
LIMIT("limit"),
- MILESTONE_ID("milestone_id");
+ MILESTONE_ID("milestone_id"),
+ OFFSET("offset"); //requires TestRail 6.7 or later
- private String filter;
- GetPlansFilter(String filter) { this.filter = filter; }
+ private final String filter;
+ GetPlansFilter(String filter) {
+ this.filter = filter;
+ }
public String getFilter() {
return filter;
diff --git a/src/main/java/com/rmn/testrail/parameters/GetProjectsFilter.java b/src/main/java/com/rmn/testrail/parameters/GetProjectsFilter.java
index 6edaa19..175058b 100644
--- a/src/main/java/com/rmn/testrail/parameters/GetProjectsFilter.java
+++ b/src/main/java/com/rmn/testrail/parameters/GetProjectsFilter.java
@@ -7,10 +7,14 @@
*/
public enum GetProjectsFilter implements ApiFilter {
//Request filter for get_projects
- IS_COMPLETED("is_completed");
+ IS_COMPLETED("is_completed"),
+ LIMIT("limit"), //250 by default. requires TestRail 6.7 or later
+ OFFSET("offset"); //requires TestRail 6.7 or later
- private String filter;
- GetProjectsFilter(String filter) { this.filter = filter; }
+ private final String filter;
+ GetProjectsFilter(String filter) {
+ this.filter = filter;
+ }
public String getFilter() {
return filter;
diff --git a/src/main/java/com/rmn/testrail/parameters/GetResultsFilter.java b/src/main/java/com/rmn/testrail/parameters/GetResultsFilter.java
index 62dfbb9..10af1a8 100644
--- a/src/main/java/com/rmn/testrail/parameters/GetResultsFilter.java
+++ b/src/main/java/com/rmn/testrail/parameters/GetResultsFilter.java
@@ -11,8 +11,10 @@ public enum GetResultsFilter implements ApiFilter {
OFFSET("offset"),
STATUS_ID("status_id");
- private String filter;
- GetResultsFilter(String filter) { this.filter = filter; }
+ private final String filter;
+ GetResultsFilter(String filter) {
+ this.filter = filter;
+ }
public String getFilter() {
return filter;
diff --git a/src/main/java/com/rmn/testrail/parameters/GetResultsForRunFilter.java b/src/main/java/com/rmn/testrail/parameters/GetResultsForRunFilter.java
index b809828..fb6845f 100644
--- a/src/main/java/com/rmn/testrail/parameters/GetResultsForRunFilter.java
+++ b/src/main/java/com/rmn/testrail/parameters/GetResultsForRunFilter.java
@@ -11,10 +11,13 @@ public enum GetResultsForRunFilter implements ApiFilter {
CREATED_BEFORE("created_before"),
CREATED_BY("created_by"),
LIMIT("limit"),
+ OFFSET("offset"), //requires TestRail 6.7 or later
STATUS_ID("status_id");
- private String filter;
- GetResultsForRunFilter(String filter) { this.filter = filter; }
+ private final String filter;
+ GetResultsForRunFilter(String filter) {
+ this.filter = filter;
+ }
public String getFilter() {
return filter;
diff --git a/src/main/java/com/rmn/testrail/parameters/GetRunsFilter.java b/src/main/java/com/rmn/testrail/parameters/GetRunsFilter.java
index e975c55..c9ed2b9 100644
--- a/src/main/java/com/rmn/testrail/parameters/GetRunsFilter.java
+++ b/src/main/java/com/rmn/testrail/parameters/GetRunsFilter.java
@@ -13,10 +13,13 @@ public enum GetRunsFilter implements ApiFilter {
IS_COMPLETED("is_completed"),
LIMIT("limit"),
MILESTONE_ID("milestone_id"),
- SUITE_ID("suite_id");
+ SUITE_ID("suite_id"),
+ OFFSET("offset");
- private String filter;
- GetRunsFilter(String filter) { this.filter = filter; }
+ private final String filter;
+ GetRunsFilter(String filter) {
+ this.filter = filter;
+ }
public String getFilter() {
return filter;
diff --git a/src/main/java/com/rmn/testrail/parameters/GetTestsFilter.java b/src/main/java/com/rmn/testrail/parameters/GetTestsFilter.java
index d777813..06f449a 100644
--- a/src/main/java/com/rmn/testrail/parameters/GetTestsFilter.java
+++ b/src/main/java/com/rmn/testrail/parameters/GetTestsFilter.java
@@ -7,10 +7,14 @@
*/
public enum GetTestsFilter implements ApiFilter {
//Request filters for get_tests
- STATUS_ID("status_id");
+ STATUS_ID("status_id"),
+ LIMIT("limit"), //250 by default. requires TestRail 6.7 or later
+ OFFSET("offset"); //requires TestRail 6.7 or later
- private String filter;
- GetTestsFilter(String filter) { this.filter = filter; }
+ private final String filter;
+ GetTestsFilter(String filter) {
+ this.filter = filter;
+ }
public String getFilter() {
return filter;
diff --git a/src/main/java/com/rmn/testrail/service/TestRailCommand.java b/src/main/java/com/rmn/testrail/service/TestRailCommand.java
index f466754..5f8f812 100644
--- a/src/main/java/com/rmn/testrail/service/TestRailCommand.java
+++ b/src/main/java/com/rmn/testrail/service/TestRailCommand.java
@@ -105,7 +105,7 @@ public enum TestRailCommand {
GET_USER_BY_EMAIL("get_user_by_email"),
GET_USERS("get_users");
- private String command;
+ private final String command;
private TestRailCommand(String command) {
this.command = command;
}
diff --git a/src/main/java/com/rmn/testrail/service/TestRailService.java b/src/main/java/com/rmn/testrail/service/TestRailService.java
index d88e5d8..1fa8e24 100644
--- a/src/main/java/com/rmn/testrail/service/TestRailService.java
+++ b/src/main/java/com/rmn/testrail/service/TestRailService.java
@@ -1,7 +1,29 @@
package com.rmn.testrail.service;
-import com.rmn.testrail.entity.*;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.rmn.testrail.entity.BaseEntity;
+import com.rmn.testrail.entity.EmptyMilestone;
import com.rmn.testrail.entity.Error;
+import com.rmn.testrail.entity.Milestone;
+import com.rmn.testrail.entity.PlanEntry;
+import com.rmn.testrail.entity.Priority;
+import com.rmn.testrail.entity.Project;
+import com.rmn.testrail.entity.ProjectCreator;
+import com.rmn.testrail.entity.Section;
+import com.rmn.testrail.entity.SectionCreator;
+import com.rmn.testrail.entity.TestCase;
+import com.rmn.testrail.entity.TestInstance;
+import com.rmn.testrail.entity.TestPlan;
+import com.rmn.testrail.entity.TestPlanCreator;
+import com.rmn.testrail.entity.TestResult;
+import com.rmn.testrail.entity.TestResults;
+import com.rmn.testrail.entity.TestRun;
+import com.rmn.testrail.entity.TestRunCreator;
+import com.rmn.testrail.entity.TestRunUpdater;
+import com.rmn.testrail.entity.TestSuite;
+import com.rmn.testrail.entity.TestSuiteCreator;
+import com.rmn.testrail.entity.UpdatePlanEntry;
+import com.rmn.testrail.entity.User;
import com.rmn.testrail.parameters.ApiFilterValue;
import com.rmn.testrail.parameters.ApiParameter;
import com.rmn.testrail.parameters.ApiParameters;
@@ -10,13 +32,12 @@
import com.rmn.testrail.util.JSONUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,7 +53,7 @@
* @author mmerrell
*/
public class TestRailService implements Serializable {
- private Logger log = LoggerFactory.getLogger(getClass());
+ private final Logger log = LoggerFactory.getLogger(TestRailService.class);
/**
* This might not last forever--we'll need to make "v2" a variable at some point--but this works for the moment
@@ -123,7 +144,7 @@ public void setApiEndpoint(URL apiEndpoint) {
*/
protected List getEntityList(Class clazz, String apiCall, String param) {
HttpURLConnection connection = getRESTRequest(apiCall, param);
- log.debug("");
+ log.debug("Get Entity List for '{}' class type.", clazz.getSimpleName().toLowerCase());
String contents = utils.getContentsFromConnection(connection);
List entities = JSONUtils.getMappedJsonObjectList(clazz, contents);
for (T suite: entities) {
@@ -1021,15 +1042,15 @@ private HttpURLConnection getRESTRequest(String apiCall, String urlParams) {
String completeUrl = buildRequestURL(apiCall, urlParams);
try {
- //log the complete url
- log.debug("url: {}", completeUrl);
+ log.debug("Complete url: {}", completeUrl);
//Add the application/json header
- Map headers = new HashMap();
+ Map headers = new HashMap<>();
headers.put("Content-Type", "application/json");
+ headers.put("x-api-ident", "beta"); //Temporary header for beta API on TestRail 6.7 TODO - remove
- //Log the curl call for easy reproduction
-// log.warn(utils.getCurlCommandStringGet(completeUrl, headers));
+ /*Log the curl call for easy reproduction
+ log.warn(utils.getCurlCommandStringGet(completeUrl, headers));*/
String authentication = utils.encodeAuthenticationBase64(username, password);
return utils.getHTTPRequest(completeUrl, authentication, headers);
@@ -1048,7 +1069,7 @@ private HttpURLConnection getRESTRequest(String apiCall, String urlParams) {
* @return The Content of the HTTP Response
*/
private HttpResponse postRESTBody(String apiCall, String urlParams, BaseEntity entity) {
- HttpClient httpClient = new DefaultHttpClient();
+ CloseableHttpClient httpClient = HttpClientBuilder.create().build();
String completeUrl = buildRequestURL( apiCall, urlParams );
try {
@@ -1058,7 +1079,7 @@ private HttpResponse postRESTBody(String apiCall, String urlParams, BaseEntity e
request.addHeader("Content-Type", "application/json");
ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
byte[] body = mapper.writeValueAsBytes(entity);
request.setEntity(new ByteArrayEntity(body));
@@ -1075,7 +1096,13 @@ private HttpResponse postRESTBody(String apiCall, String urlParams, BaseEntity e
log.error(String.format("An IOException was thrown while trying to process a REST Request against URL: [%s]", completeUrl), e.toString());
throw new RuntimeException(String.format("Connection is null, check URL: %s", completeUrl));
} finally {
- httpClient.getConnectionManager().shutdown();
+ try {
+ httpClient.close();
+ }
+ catch (IOException ex) {
+ log.error("An IOException thrown while trying to close the HTTP client against URL: {}", completeUrl);
+ throw new RuntimeException("Unable to close HTTP client against URL: " + completeUrl, ex);
+ }
}
}
@@ -1089,7 +1116,7 @@ private HttpResponse postRESTBody(String apiCall, String urlParams, BaseEntity e
* @return The Content of the HTTP Response
*/
private T postRESTBodyReturn(String apiCall, String urlParams, BaseEntity entity, Class returnEntityType) {
- HttpClient httpClient = new DefaultHttpClient();
+ CloseableHttpClient httpClient = HttpClientBuilder.create().build();
String completeUrl = buildRequestURL( apiCall, urlParams );
try {
@@ -1100,7 +1127,7 @@ private T postRESTBodyReturn(String apiCall, String urlPa
request.addHeader("Encoding", "UTF-8");
ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
byte[] body = mapper.writeValueAsBytes(entity);
request.setEntity(new ByteArrayEntity(body));
@@ -1121,7 +1148,13 @@ private T postRESTBodyReturn(String apiCall, String urlPa
log.error(String.format("An IOException was thrown while trying to process a REST Request against URL: [%s]", completeUrl), e);
throw new RuntimeException(String.format("Connection is null, check URL: %s", completeUrl), e);
} finally {
- httpClient.getConnectionManager().shutdown();
+ try {
+ httpClient.close();
+ }
+ catch (IOException ex) {
+ log.error("An IOException thrown while trying to close the HTTP client against URL: {}", completeUrl);
+ throw new RuntimeException("Unable to close HTTP client against URL: " + completeUrl, ex);
+ }
}
return null;
}
@@ -1138,7 +1171,7 @@ private HttpResponse executeRequestWithRetry(HttpPost request, int retries) thro
int RETRY_DELAY_MS = 0;
int retryDelayInMS;
- HttpClient httpClient = new DefaultHttpClient();
+ CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpResponse response = null;
for (int retry = 0; retry < retries && !connected; retry++) {
diff --git a/src/main/java/com/rmn/testrail/util/JSONUtils.java b/src/main/java/com/rmn/testrail/util/JSONUtils.java
index defd841..ad4cbd4 100644
--- a/src/main/java/com/rmn/testrail/util/JSONUtils.java
+++ b/src/main/java/com/rmn/testrail/util/JSONUtils.java
@@ -1,8 +1,13 @@
package com.rmn.testrail.util;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.type.TypeFactory;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.rmn.testrail.entity.BasicPaged;
+import com.rmn.testrail.entity.BulkEntityCategory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
@@ -12,6 +17,8 @@
*/
public class JSONUtils {
+ private static final Logger log = LoggerFactory.getLogger(JSONUtils.class);
+
/**
* Takes a JSON string and attempts to "map" it to the given class. It assumes the JSON
* string is valid, and that it maps to the object you've indicated, and any problem with
@@ -39,7 +46,7 @@ public static T getMappedJsonObject(Class jsonObjectClass, String json) {
public static T getMappedJsonObject( Class jsonObjectClass, String json, boolean failOnUnknownProperties ) {
TypeFactory t = TypeFactory.defaultInstance();
ObjectMapper mapper = new ObjectMapper();
- mapper.configure( DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, failOnUnknownProperties );
+ mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES , failOnUnknownProperties );
T mappedObject;
try {
@@ -58,11 +65,43 @@ public static T getMappedJsonObject( Class jsonObjectClass, String json,
* @param jsonObjectClass The Class you wish to map the json to
* @param json The JSON you wish to map to the given Class
* @return An instance of the given Class, based on the attributes of the given JSON
+ *
+ * Note: To accommodate TestRail 6.7 changes to bulk API response this method (as only strict mode used) has
+ * been updated to get returned paged object and extract the json string representing entity list. This done
+ * conditionally only on types that are part of the bulk API with the help of {@link BulkEntityCategory}.
*/
public static List getMappedJsonObjectList(Class jsonObjectClass, String json) {
- return getMappedJsonObjectList(jsonObjectClass, json, true);
+ String entityType = jsonObjectClass.getSimpleName().toLowerCase();
+ log.debug("The entity type to process the list has simple name: {}", entityType);
+ if(BulkEntityCategory.isBulkCategory(entityType)) {
+ log.debug("The enum type used to determine if bulk: '{}'", BulkEntityCategory.fromBulkType(entityType));
+ String jsonObjectList = extractObjectList(json);
+ return getMappedJsonObjectList(jsonObjectClass, jsonObjectList, false);
+ }
+ return getMappedJsonObjectList(jsonObjectClass, json, false);
}
+ /**
+ * Private helper method to extract list of entities defined in {@link BulkEntityCategory} from paged bulk api
+ * defined as {@link BasicPaged}
+ * @param json - The JSON object returned by paged bulk API introduced in TestRail 6.7
+ * @return - Json String that represents a list of extracted entities in compliance with API before 6.7
+ */
+ private static String extractObjectList(String json) {
+ log.debug("Attempting to parse out the list of entities from json string for paged object.");
+ BasicPaged multiPage = getMappedJsonObject(BasicPaged.class, json, false);
+ List> entitiesObjectList = multiPage.getList();
+ //log.debug("Expose entity list for debugging: '{}'", entitiesObjectList);
+ String jsonEntityList = "";
+ try {
+ jsonEntityList = new ObjectMapper().writeValueAsString(entitiesObjectList);
+ } catch (JsonProcessingException ex) {
+ log.debug("The list will be empty due to exception '{}'", ex.toString());
+ }
+ return jsonEntityList;
+ }
+
+
/**
* Returns a list of objects of the specified type. If you send "false" in the 3rd parameter, it will be
* forgiving of JSON properties that are not defined or inaccessible in the specified jsonObjectClass
@@ -74,7 +113,7 @@ public static List getMappedJsonObjectList(Class jsonObjectClass, Stri
public static List getMappedJsonObjectList(Class jsonObjectClass, String json, boolean failOnUnknownProperties) {
List list;
ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, failOnUnknownProperties);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, failOnUnknownProperties);
TypeFactory t = TypeFactory.defaultInstance();
try {
diff --git a/src/test/java/com/rmn/testrail/entity/TestRunCreatorTest.java b/src/test/java/com/rmn/testrail/entity/TestRunCreatorTest.java
index 75c25c4..cb25c62 100644
--- a/src/test/java/com/rmn/testrail/entity/TestRunCreatorTest.java
+++ b/src/test/java/com/rmn/testrail/entity/TestRunCreatorTest.java
@@ -59,6 +59,7 @@ public void caseIdsGettersAndSettersShouldWorksCorrectly() {
Assert.assertNull(testRunCreator.getCaseIds());
testRunCreator.setCaseIds(new Integer[]{111, 22, 3});
Integer[] expectedCasesId = {111, 22, 3};
- Assert.assertEquals(expectedCasesId, testRunCreator.getCaseIds());
+ //Assert.assertEquals(expectedCasesId, testRunCreator.getCaseIds());
+ Assert.assertArrayEquals(expectedCasesId, testRunCreator.getCaseIds());
}
}
\ No newline at end of file
diff --git a/src/test/java/com/rmn/testrail/service/TestIntegrationSuite.java b/src/test/java/com/rmn/testrail/service/TestIntegrationSuite.java
index 97f5548..896c9e6 100644
--- a/src/test/java/com/rmn/testrail/service/TestIntegrationSuite.java
+++ b/src/test/java/com/rmn/testrail/service/TestIntegrationSuite.java
@@ -27,7 +27,7 @@
@RunWith(value = Suite.class)
@Suite.SuiteClasses(value = { TestRailServiceIntegrationTest.class })
public class TestIntegrationSuite {
- private static Logger log = LoggerFactory.getLogger(TestIntegrationSuite.class.getSimpleName());
+ private static final Logger log = LoggerFactory.getLogger(TestIntegrationSuite.class);
//The setUp method initializes the list of projects, and the rest of the suite uses information from there
protected static TestRailService service = new TestRailService();
@@ -45,7 +45,7 @@ public class TestIntegrationSuite {
protected static boolean destructiveTestsOk = false;
@BeforeClass
- public static void setUp() throws IOException, InterruptedException {
+ public static void setUp() throws IOException {
//Get the TestRails credentials from the testrails.properties file
Properties properties = new Properties();
InputStream resource = TestRailServiceIntegrationTest.class.getClassLoader().getResourceAsStream("testrails.properties");
@@ -65,7 +65,7 @@ public static void setUp() throws IOException, InterruptedException {
destructiveTestsOk = false;
log.info("Your testrails.properties file does not contain the 'destructiveTestsOk' property--shutting off destructive tests");
} else {
- destructiveTestsOk = Boolean.valueOf(destructiveTestsOkProperty);
+ destructiveTestsOk = Boolean.parseBoolean(destructiveTestsOkProperty);
log.info("Located 'destructiveTestsOk' property--setting to " + destructiveTestsOk);
}
diff --git a/src/test/java/com/rmn/testrail/service/TestRailServiceIntegrationTest.java b/src/test/java/com/rmn/testrail/service/TestRailServiceIntegrationTest.java
index 060ea6d..59821db 100644
--- a/src/test/java/com/rmn/testrail/service/TestRailServiceIntegrationTest.java
+++ b/src/test/java/com/rmn/testrail/service/TestRailServiceIntegrationTest.java
@@ -27,7 +27,7 @@
import java.util.Properties;
public class TestRailServiceIntegrationTest {
- private static Logger log = LoggerFactory.getLogger(TestRailServiceIntegrationTest.class.getSimpleName());
+ private static final Logger log = LoggerFactory.getLogger(TestRailServiceIntegrationTest.class);
/**
* Test the getTestSuites (plural) API call
diff --git a/src/test/java/com/rmn/testrail/service/TestRailServiceTest.java b/src/test/java/com/rmn/testrail/service/TestRailServiceTest.java
index f4bc207..7ad0a20 100644
--- a/src/test/java/com/rmn/testrail/service/TestRailServiceTest.java
+++ b/src/test/java/com/rmn/testrail/service/TestRailServiceTest.java
@@ -1,8 +1,16 @@
package com.rmn.testrail.service;
-import com.rmn.testrail.entity.*;
+
+import com.rmn.testrail.entity.Project;
+import com.rmn.testrail.entity.Section;
+import com.rmn.testrail.entity.TestCase;
+import com.rmn.testrail.entity.TestInstance;
+import com.rmn.testrail.entity.TestPlan;
+import com.rmn.testrail.entity.TestResult;
+import com.rmn.testrail.entity.TestRun;
+import com.rmn.testrail.entity.TestSuite;
import com.rmn.testrail.util.MockHTTPUtils;
-import junit.framework.Assert;
+import org.junit.Assert;
import org.junit.Test;
import java.io.BufferedReader;
@@ -24,7 +32,7 @@ private TestRailService getTestRailsEntities(String fileName) {
@Test
public void testGetProjects() {
- TestRailService service = getTestRailsEntities("Projects.json");
+ TestRailService service = getTestRailsEntities("ProjectsPaged.json");
List projects = service.getProjects();
Assert.assertEquals("Sandbox", projects.get(0).getName());
}
@@ -38,7 +46,7 @@ public void testGetTestSuites() {
@Test
public void testGetSections() {
- TestRailService service = getTestRailsEntities("Sections.json");
+ TestRailService service = getTestRailsEntities("SectionsPaged.json");
List sections = service.getSections(0, 0);
Assert.assertEquals("All Test Cases", sections.get(0).getName());
}
@@ -47,27 +55,27 @@ public void testGetSections() {
public void testGetTestCase() {
TestRailService service = getTestRailsEntities("TestCase.json");
TestCase testCase = service.getTestCase(0);
- Assert.assertEquals(new Integer(5), testCase.getCreatedBy());
- Assert.assertEquals(new Integer(1392300984), testCase.getCreatedOn());
+ Assert.assertEquals(Integer.valueOf(5), testCase.getCreatedBy());
+ Assert.assertEquals(Integer.valueOf(1392300984), testCase.getCreatedOn());
Assert.assertEquals("1m 5s", testCase.getEstimate());
- Assert.assertEquals(null, testCase.getEstimateForecast());
- Assert.assertEquals(new Integer(1), testCase.getId());
- Assert.assertEquals(new Integer(7), testCase.getMilestoneId());
- Assert.assertEquals(new Integer(2), testCase.getPriorityId());
+ Assert.assertNull(testCase.getEstimateForecast());
+ Assert.assertEquals(Integer.valueOf(1), testCase.getId());
+ Assert.assertEquals(Integer.valueOf(7), testCase.getMilestoneId());
+ Assert.assertEquals(Integer.valueOf(2), testCase.getPriorityId());
Assert.assertEquals("RF-1, RF-2", testCase.getRefs());
- Assert.assertEquals(new Integer(1), testCase.getSectionId());
- Assert.assertEquals(new Integer(1), testCase.getSuiteId());
+ Assert.assertEquals(Integer.valueOf(1), testCase.getSectionId());
+ Assert.assertEquals(Integer.valueOf(1), testCase.getSuiteId());
Assert.assertEquals("Change document attributes (author, title, organization)", testCase.getTitle());
- Assert.assertEquals(new Integer(4), testCase.getTypeId());
- Assert.assertEquals(new Integer(1), testCase.getUpdatedBy());
- Assert.assertEquals(new Integer(1393586511), testCase.getUpdatedOn());
- Assert.assertEquals(new Integer(1), testCase.getTemplateId());
+ Assert.assertEquals(Integer.valueOf(4), testCase.getTypeId());
+ Assert.assertEquals(Integer.valueOf(1), testCase.getUpdatedBy());
+ Assert.assertEquals(Integer.valueOf(1393586511), testCase.getUpdatedOn());
+ Assert.assertEquals(Integer.valueOf(1), testCase.getTemplateId());
}
@Test
public void testGetTestCases() {
- TestRailService service = getTestRailsEntities("TestCases.json");
+ TestRailService service = getTestRailsEntities("TestCasesPaged.json");
List testCases = service.getTestCases(0, 0);
Assert.assertEquals("Test Case", testCases.get(0).getTitle());
Assert.assertEquals("Steve - First Test Case", testCases.get(1).getTitle());
@@ -105,18 +113,32 @@ public void testGetConfigurations() {
@Test
public void testGetTestRuns() {
- TestRailService service = getTestRailsEntities("TestRuns.json");
+ TestRailService service = getTestRailsEntities("TestRunsPaged.json");
List testRuns = service.getTestRuns(0);
Assert.assertEquals("Test Suite", testRuns.get(0).getName());
}
@Test
public void testGetTestPlans() {
- TestRailService service = getTestRailsEntities("TestPlans.json");
+ TestRailService service = getTestRailsEntities("TestPlansPaged.json");
List testPlans = service.getTestPlans(0);
Assert.assertEquals("Test Plan 2", testPlans.get(0).getName());
}
+ @Test
+ public void testGetTestResults() {
+ TestRailService service = getTestRailsEntities("TestResultsPaged.json");
+ List testResults = service.getTestResults(0);
+ Assert.assertEquals(186187, (int) testResults.get(0).getId());
+ }
+
+ @Test
+ public void testGetTests() {
+ TestRailService service = getTestRailsEntities("TestInstancesPaged.json");
+ List testResults = service.getTests(0);
+ Assert.assertEquals(6408, (int) testResults.get(0).getCaseId());
+ }
+
/**
* Returns the contents of the given file as a List of Strings
* @param filename The name of the file to read. This file must be on the classpath at runtime
diff --git a/src/test/resources/ProjectsPaged.json b/src/test/resources/ProjectsPaged.json
new file mode 100644
index 0000000..45db867
--- /dev/null
+++ b/src/test/resources/ProjectsPaged.json
@@ -0,0 +1,61 @@
+{
+ "offset": 0,
+ "limit": 250,
+ "size": 5,
+ "_links": {
+ "next": null,
+ "prev": null
+ },
+ "projects": [
+ {
+ "id": 3,
+ "name": "Sandbox",
+ "announcement": "Evaluate :: Test Run & Test Plan - multiple Test Suite",
+ "show_announcement": true,
+ "is_completed": false,
+ "completed_on": null,
+ "suite_mode": 3,
+ "url": "https://company_name.testrail.net/index.php?/projects/overview/3"
+ },
+ {
+ "id": 10,
+ "name": "Name Project 10",
+ "announcement": "Sin City Gateway System",
+ "show_announcement": false,
+ "is_completed": false,
+ "completed_on": null,
+ "suite_mode": 3,
+ "url": "https://company_name.testrail.net/index.php?/projects/overview/10"
+ },
+ {
+ "id": 11,
+ "name": "Name Project 11",
+ "announcement": "Sin City Gateway System",
+ "show_announcement": false,
+ "is_completed": false,
+ "completed_on": null,
+ "suite_mode": 3,
+ "url": "https://company_name.testrail.net/index.php?/projects/overview/11"
+ },
+ {
+ "id": 12,
+ "name": "Name Project 12",
+ "announcement": null,
+ "show_announcement": false,
+ "is_completed": false,
+ "completed_on": null,
+ "suite_mode": 3,
+ "url": "https://company_name.testrail.net/index.php?/projects/overview/12"
+ },
+ {
+ "id": 43,
+ "name": "SName Project 43",
+ "announcement": null,
+ "show_announcement": false,
+ "is_completed": false,
+ "completed_on": null,
+ "suite_mode": 3,
+ "url": "https://company_name.testrail.net/index.php?/projects/overview/43"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/test/resources/SectionsPaged.json b/src/test/resources/SectionsPaged.json
new file mode 100644
index 0000000..ed81886
--- /dev/null
+++ b/src/test/resources/SectionsPaged.json
@@ -0,0 +1,56 @@
+{
+ "offset": 0,
+ "limit": 250,
+ "size": 5,
+ "_links": {
+ "next": null,
+ "prev": null
+ },
+ "sections": [
+ {
+ "id": 63892,
+ "suite_id": 3398,
+ "name": "All Test Cases",
+ "description": null,
+ "parent_id": null,
+ "display_order": 1,
+ "depth": 0
+ },
+ {
+ "id": 146508,
+ "suite_id": 3398,
+ "name": "Error Handling",
+ "description": null,
+ "parent_id": 63892,
+ "display_order": 2,
+ "depth": 1
+ },
+ {
+ "id": 88174,
+ "suite_id": 3398,
+ "name": "Management",
+ "description": null,
+ "parent_id": null,
+ "display_order": 5,
+ "depth": 0
+ },
+ {
+ "id": 88175,
+ "suite_id": 3398,
+ "name": "Logging",
+ "description": null,
+ "parent_id": 88174,
+ "display_order": 6,
+ "depth": 1
+ },
+ {
+ "id": 88178,
+ "suite_id": 3398,
+ "name": "Config",
+ "description": null,
+ "parent_id": 88174,
+ "display_order": 10,
+ "depth": 1
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/test/resources/TestCasesPaged.json b/src/test/resources/TestCasesPaged.json
new file mode 100644
index 0000000..f454c89
--- /dev/null
+++ b/src/test/resources/TestCasesPaged.json
@@ -0,0 +1,51 @@
+{
+ "offset": 0,
+ "limit": 250,
+ "size": 2,
+ "_links": {
+ "next": null,
+ "prev": null
+ },
+ "cases": [
+ {
+ "id": 1241,
+ "title": "Test Case",
+ "section_id": 302,
+ "type_id": 4,
+ "priority_id": 6,
+ "milestone_id": null,
+ "refs": null,
+ "created_by": 1,
+ "created_on": 1357864553,
+ "estimate": null,
+ "estimate_forecast": "22s",
+ "suite_id": 17,
+ "custom_automation_priority": 1,
+ "custom_notes": null,
+ "custom_steps_separated": [{
+ "content": "This is a test step",
+ "expected": "This is a test result"
+ }]
+ },
+ {
+ "id": 1243,
+ "title": "Steve - First Test Case",
+ "section_id": 302,
+ "type_id": 4,
+ "priority_id": 6,
+ "milestone_id": null,
+ "refs": null,
+ "created_by": 8,
+ "created_on": 1358190068,
+ "estimate": null,
+ "estimate_forecast": null,
+ "suite_id": 17,
+ "custom_automation_priority": 1,
+ "custom_notes": null,
+ "custom_steps_separated": [{
+ "content": "1. Step1\n1. Step2\n1. Step3",
+ "expected": "Expected Results 1"
+ }]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/test/resources/TestInstancesPaged.json b/src/test/resources/TestInstancesPaged.json
new file mode 100644
index 0000000..6e14f61
--- /dev/null
+++ b/src/test/resources/TestInstancesPaged.json
@@ -0,0 +1,41 @@
+{
+ "offset": 0,
+ "limit": 250,
+ "size": 2,
+ "_links": {
+ "next": null,
+ "prev": null
+ },
+ "tests": [
+ {
+ "id": 51899,
+ "case_id": 6408,
+ "status_id": 1,
+ "assignedto_id": 10,
+ "run_id": 1239,
+ "title": "Home Page - Universal Tags",
+ "type_id": 1,
+ "priority_id": 6,
+ "estimate": null,
+ "estimate_forecast": "13s",
+ "custom_automation_priority": null,
+ "custom_notes": null,
+ "custom_steps_separated": null
+ },
+ {
+ "id": 51900,
+ "case_id": 6409,
+ "status_id": 3,
+ "assignedto_id": null,
+ "run_id": 1239,
+ "title": "Store Page - Universal Tags",
+ "type_id": 1,
+ "priority_id": 6,
+ "estimate": null,
+ "estimate_forecast": "27s",
+ "custom_automation_priority": null,
+ "custom_notes": null,
+ "custom_steps_separated": null
+ }
+ ]
+}
diff --git a/src/test/resources/TestPlansPaged.json b/src/test/resources/TestPlansPaged.json
new file mode 100644
index 0000000..b2e97c8
--- /dev/null
+++ b/src/test/resources/TestPlansPaged.json
@@ -0,0 +1,61 @@
+{
+ "offset": 0,
+ "limit": 250,
+ "size": 2,
+ "_links": {
+ "next": null,
+ "prev": null
+ },
+ "plans": [
+ {
+ "id": 112233,
+ "name": "Test Plan 2",
+ "description": null,
+ "milestone_id": 456,
+ "assignedto_id": null,
+ "is_completed": false,
+ "completed_on": null,
+ "passed_count": 0,
+ "blocked_count": 0,
+ "untested_count": 64,
+ "retest_count": 0,
+ "failed_count": 0,
+ "custom_status1_count": 0,
+ "custom_status2_count": 0,
+ "custom_status3_count": 0,
+ "custom_status4_count": 0,
+ "custom_status5_count": 0,
+ "custom_status6_count": 0,
+ "custom_status7_count": 0,
+ "project_id": 3,
+ "created_on": 1533826280,
+ "created_by": 1,
+ "url": "https://coname.testrail.net/index.php?/plans/view/112233"
+ },
+ {
+ "id": 1234,
+ "name": "Test Plan 1234",
+ "description": null,
+ "milestone_id": 456,
+ "assignedto_id": null,
+ "is_completed": false,
+ "completed_on": null,
+ "passed_count": 2,
+ "blocked_count": 0,
+ "untested_count": 63,
+ "retest_count": 0,
+ "failed_count": 1,
+ "custom_status1_count": 0,
+ "custom_status2_count": 0,
+ "custom_status3_count": 0,
+ "custom_status4_count": 0,
+ "custom_status5_count": 0,
+ "custom_status6_count": 0,
+ "custom_status7_count": 0,
+ "project_id": 3,
+ "created_on": 1492011469,
+ "created_by": 7,
+ "url": "https://coname.testrail.net/index.php?/plans/view/1234"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/test/resources/TestResultsPaged.json b/src/test/resources/TestResultsPaged.json
new file mode 100644
index 0000000..b75bb5b
--- /dev/null
+++ b/src/test/resources/TestResultsPaged.json
@@ -0,0 +1,37 @@
+{
+ "offset": 0,
+ "limit": 250,
+ "size": 2,
+ "_links": {
+ "next": null,
+ "prev": null
+ },
+ "results": [
+ {
+ "id": 186187,
+ "test_id": 51899,
+ "status_id": 1,
+ "created_by": 10,
+ "created_on": 1382800478,
+ "assignedto_id": 10,
+ "comment": "It worked!!",
+ "version": null,
+ "elapsed": null,
+ "defects": null,
+ "custom_step_results": null
+ },
+ {
+ "id": 186186,
+ "test_id": 51899,
+ "status_id": 1,
+ "created_by": 10,
+ "created_on": 1382800307,
+ "assignedto_id": 10,
+ "comment": "It worked!!",
+ "version": null,
+ "elapsed": null,
+ "defects": null,
+ "custom_step_results": null
+ }
+ ]
+}
diff --git a/src/test/resources/TestRunsPaged.json b/src/test/resources/TestRunsPaged.json
new file mode 100644
index 0000000..506806e
--- /dev/null
+++ b/src/test/resources/TestRunsPaged.json
@@ -0,0 +1,51 @@
+{
+ "offset": 0,
+ "limit": 250,
+ "size": 2,
+ "_links": {
+ "next": null,
+ "prev": null
+ },
+ "runs": [
+ {
+ "id": 15,
+ "suite_id": 17,
+ "name": "Test Suite",
+ "description": null,
+ "milestone_id": null,
+ "assignedto_id": null,
+ "include_all": false,
+ "is_completed": false,
+ "completed_on": null,
+ "config": null,
+ "passed_count": 1,
+ "blocked_count": 0,
+ "untested_count": 0,
+ "retest_count": 0,
+ "failed_count": 0,
+ "project_id": 2,
+ "plan_id": null,
+ "url": "https://rmn.testrail.com/index.php?/runs/view/15"
+ },
+ {
+ "id": 17,
+ "suite_id": 17,
+ "name": "MM Test Run",
+ "description": null,
+ "milestone_id": null,
+ "assignedto_id": 2,
+ "include_all": true,
+ "is_completed": false,
+ "completed_on": null,
+ "config": null,
+ "passed_count": 0,
+ "blocked_count": 0,
+ "untested_count": 2,
+ "retest_count": 0,
+ "failed_count": 0,
+ "project_id": 2,
+ "plan_id": null,
+ "url": "https://rmn.testrail.com/index.php?/runs/view/17"
+ }
+ ]
+}
\ No newline at end of file