package com.rmn.testrail.entity;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;

import java.io.Serializable;

/**
 * @author mmerrell
 *
 * If you have custom fields on TestResults in TestRails, it will be necessary to extend this class and add those fields in order to capture them.
 * Otherwise they will be ignored.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class TestResult extends BaseEntity implements Serializable {
    @JsonProperty("case_id")
    private Integer caseId;
    public Integer getCaseId() { return caseId; }
    public void setCaseId(Integer testId) { this.caseId = caseId; }

    @JsonProperty("test_id")
    private Integer testId;
    public Integer getTestId() { return testId; }
    public void setTestId(Integer testId) { this.testId = testId; }

    @JsonProperty("status_id")
    private Integer statusId;
    public Integer getStatusId() { return statusId; }
    public void setStatusId(Integer statusId) { this.statusId = statusId; }

    @JsonProperty("assignedto_id")
    private Integer assignedtoId;
    public Integer getAssignedtoId() { return assignedtoId; }
    public void setAssignedtoId(Integer assignedtoId) { this.assignedtoId = assignedtoId; }

    @JsonProperty("comment")
    private String comment = "";
    public String getComment() { return comment; }
    public void setComment(String comment) { this.comment = comment; }

    @JsonProperty("version")
    private String version;
    public String getVersion() { return version; }
    public void setVersion(String version) { this.version = version; }

    @JsonProperty("elapsed")
    private String elapsed;
    public String getElapsed() { return elapsed; }
    public void setElapsed(String elapsed) { this.elapsed = elapsed; }

    @JsonProperty("defects")
    private String defects;
    public String getDefects() { return defects; }
    public void setDefects(String defects) { this.defects = defects; }

    /**
     * Set the Verdict for this TestResult (does not actually send the update to the TestRails Service)
     * @param verdict
     */
    public void setVerdict(String verdict) {
        this.statusId = TestStatus.getStatus(verdict);
    }

    /**
     * Set the verdict by using the actual StatusId (useful for customizations). Alternatively, you can extend the TestStatus
     *  class and add custom status key-value pairs to it. This method can't be overloaded to match setVerdict(int), because
     *  it confuses Jackson's Serializer
     * @param verdict
     */
    public void setVerdictId(int verdict) {
        this.statusId = verdict;
    }
}

@@ -494,16 +494,159 @@
 zable %7B%0A
+    @JsonProperty(%22id%22)%0A    private Integer id;%0A    public Integer getId() %7B return id; %7D%0A    public void setId(Integer id) %7B this.id = id; %7D%0A%0A
     @Jso
@@ -1177,24 +1177,424 @@
 tatusId; %7D%0A%0A
+    @JsonProperty(%22created_by%22)%0A    private Integer createdBy;%0A    public Integer getCreatedBy() %7B return createdBy; %7D%0A    public void setCreatedBy(Integer createdBy) %7B this.createdBy = createdBy; %7D%0A%0A    @JsonProperty(%22created_on%22)%0A    private Integer createdOn;%0A    public Integer getCreatedOn() %7B return createdOn; %7D%0A    public void setCreatedOn(Integer createdOn) %7B this.createdOn = createdOn; %7D%0A%0A
     @JsonPro

revert taking needed fields out