Skip to content

Issue-60 support bulk end points introduced for TestRail 6.7 and up #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
106 changes: 54 additions & 52 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,34 @@
<tag>testrailsdk-1.1</tag>
</scm>

<dependencies>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>[4.3.6,)</version>
</dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>[4.3.6,)</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.9</version>
<scope>test</scope>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencies>

<distributionManagement>
<snapshotRepository>
Expand All @@ -98,7 +92,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -111,7 +105,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<version>3.2.0</version>
<configuration>
<source>11</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -122,18 +119,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<groupId>org.simplify4u.plugins</groupId>
<artifactId>sign-maven-plugin</artifactId>
<version>0.3.0</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
Expand All @@ -152,20 +140,34 @@
</profiles>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
</build>
</project>
57 changes: 57 additions & 0 deletions src/main/java/com/rmn/testrail/entity/BasicPaged.java
Original file line number Diff line number Diff line change
@@ -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; }
}
}
57 changes: 57 additions & 0 deletions src/main/java/com/rmn/testrail/entity/BulkEntityCategory.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/EmptyMilestone.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;

import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author jsteigel
Expand Down
33 changes: 31 additions & 2 deletions src/main/java/com/rmn/testrail/entity/Milestone.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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; }
}

@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; }
}
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/PlanEntry.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/PlanEntryRun.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/Priority.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;

import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author vliao
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/Project.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/ProjectCreator.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/Section.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/SectionCreator.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.rmn.testrail.entity;

import org.codehaus.jackson.annotate.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author ragePowered
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rmn/testrail/entity/Step.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Loading