Search in sources :

Example 1 with Subtask

use of com.atlassian.jira.rest.client.api.domain.Subtask in project staf by simpleworks-gmbh.

the class DebugTestFLOClientMojo method dumpIssue.

public void dumpIssue() {
    final Issue issue = client.getIssue(testPlanId).claim();
    DebugTestFLOClientMojo.logger.debug(String.format("key: '%s', issue: id: %d.", issue.getKey(), issue.getId()));
    final IssueType type = issue.getIssueType();
    DebugTestFLOClientMojo.logger.debug(String.format("issue type: id: %d, name: '%s'.", type.getId(), type.getName()));
    final Status status = issue.getStatus();
    DebugTestFLOClientMojo.logger.debug(String.format("status: id: %d, name: '%s'.", status.getId(), status.getName()));
    DebugTestFLOClientMojo.dumpFields("fields for issue.", issue.getFields());
    DebugTestFLOClientMojo.logger.debug("attachments:");
    for (final Attachment attachment : issue.getAttachments()) {
        DebugTestFLOClientMojo.logger.debug(String.format("attachment: '%s'.", attachment));
    }
    final IssueField field = issue.getField("Test Plan Iteration");
    Assert.assertNotNull("field \"Test Plan Iteration\" can't be null.", field);
    final Object obj = field.getValue();
    DebugTestFLOClientMojo.logger.debug(String.format("class for field: \"Iteration\" is: '%s'.", obj.getClass().getName()));
    {
        DebugTestFLOClientMojo.logger.debug("transition:");
        final Iterable<Transition> transitions = client.getTransitions(issue).claim();
        for (final Transition transition : transitions) {
            DebugTestFLOClientMojo.logger.debug(String.format("transition: name: '%s', id: %d.", transition.getName(), Integer.valueOf(transition.getId())));
        }
    }
    for (final Subtask subtask : issue.getSubtasks()) {
        final Issue i = client.getIssue(subtask.getIssueKey()).claim();
        final IssueField steps = i.getFieldByName("Steps");
        DebugTestFLOClientMojo.logger.debug(String.format("steps: '%s'.", steps.getValue()));
        final IssueField template = i.getFieldByName("TC Template");
        DebugTestFLOClientMojo.logger.debug(String.format("template: '%s'.", template.getValue()));
        final Iterable<Transition> transitions = client.getTransitions(i).claim();
        for (final Transition transition : transitions) {
            DebugTestFLOClientMojo.logger.debug(String.format("subtask: '%s', transition: name: '%s', id: %d.", subtask.getIssueKey(), transition.getName(), Integer.valueOf(transition.getId())));
        }
    }
}
Also used : Status(com.atlassian.jira.rest.client.api.domain.Status) Subtask(com.atlassian.jira.rest.client.api.domain.Subtask) Issue(com.atlassian.jira.rest.client.api.domain.Issue) IssueField(com.atlassian.jira.rest.client.api.domain.IssueField) IssueType(com.atlassian.jira.rest.client.api.domain.IssueType) Transition(com.atlassian.jira.rest.client.api.domain.Transition) Attachment(com.atlassian.jira.rest.client.api.domain.Attachment)

Example 2 with Subtask

use of com.atlassian.jira.rest.client.api.domain.Subtask in project staf by simpleworks-gmbh.

the class TestFlo method startTestPlan.

public void startTestPlan(final TestPlan testPlan) throws SystemException {
    if (testPlan == null) {
        throw new IllegalArgumentException("testPlan can't be null or empty string.");
    }
    if (TestFlo.logger.isInfoEnabled()) {
        TestFlo.logger.info(String.format("start test plan '%s'.", testPlan.getId()));
    }
    final Issue issue = jira.getIssue(testPlan.getId()).claim();
    Assert.assertNotNull(String.format("can't get issue for: '%s'.", testPlan.getId()), issue);
    TestFloUtils.checkTestPlanStatus(issue, TestPlanStatus.Open, TestCaseStatus.Open);
    final StringBuilder builder = new StringBuilder();
    try {
        transition(issue, TestPlanStatus.Open, TestPlanTransition.Start);
    } catch (final SystemException ex) {
        TestFlo.logger.error("error on transition for test plan.", ex);
        builder.append(", '").append(ex.getMessage()).append("'");
    }
    for (final Subtask subtask : issue.getSubtasks()) {
        try {
            transition(subtask, TestCaseStatus.Open, TestCaseTransition.Test);
        } catch (final SystemException ex) {
            TestFlo.logger.error("error on transition for test case.", ex);
            builder.append(", '").append(ex.getMessage()).append("'");
        }
    }
    final String errors = builder.toString();
    if (!Convert.isEmpty(errors)) {
        throw new SystemException(String.format("can't start test plan: '%s'. Reason(s): %s.", issue.getKey(), errors.substring(2)));
    }
}
Also used : Subtask(com.atlassian.jira.rest.client.api.domain.Subtask) Issue(com.atlassian.jira.rest.client.api.domain.Issue) SystemException(de.simpleworks.staf.commons.exceptions.SystemException)

Example 3 with Subtask

use of com.atlassian.jira.rest.client.api.domain.Subtask in project staf by simpleworks-gmbh.

the class TestFloUtils method checkTestPlanStatus.

public static void checkTestPlanStatus(final Issue issue, final TestPlanStatus testPlanStatus, final TestCaseStatus testCaseStatus) throws SystemException {
    Assert.assertNotNull("issue type can't be null.", issue);
    Assert.assertNotNull("testPlanStatus type can't be null.", testPlanStatus);
    if (TestFloUtils.logger.isDebugEnabled()) {
        TestFloUtils.logger.debug(String.format("check status, expected for test plan '%s', expected for test case: '%s'.", testPlanStatus, testCaseStatus));
    }
    final StringBuilder builder = new StringBuilder();
    try {
        TestFloUtils.checkType(issue, TestFloTypes.TestPlan);
    } catch (final SystemException ex) {
        TestFloUtils.logger.error(String.format("test plan '%s'.. is no test plan..", issue.getKey()), ex);
        builder.append(", '").append(ex.getMessage()).append("'");
    }
    try {
        TestFloUtils.checkStatus(issue, testPlanStatus.getTestFloName());
    } catch (final SystemException ex) {
        TestFloUtils.logger.error(String.format("test plan '%s' unexpected status (expected is: '%s').", issue.getKey(), testPlanStatus.getTestFloName()), ex);
        builder.append(", '").append(ex.getMessage()).append("'");
    }
    if (testCaseStatus != null) {
        for (final Subtask subtask : issue.getSubtasks()) {
            try {
                TestFloUtils.checkType(subtask, TestFloTypes.TestCase);
                TestFloUtils.checkStatus(subtask, testCaseStatus);
            } catch (final SystemException ex) {
                TestFloUtils.logger.error(String.format("subtask '%s' can't be started.", subtask.getIssueKey()), ex);
                builder.append(", '").append(ex.getMessage()).append("'");
            }
        }
    }
    final String errors = builder.toString();
    if (!Convert.isEmpty(errors)) {
        throw new SystemException(String.format("can't start test plan: '%s'. Reason(s): %s.", issue.getKey(), errors.substring(2)));
    }
}
Also used : Subtask(com.atlassian.jira.rest.client.api.domain.Subtask) SystemException(de.simpleworks.staf.commons.exceptions.SystemException)

Example 4 with Subtask

use of com.atlassian.jira.rest.client.api.domain.Subtask in project staf by simpleworks-gmbh.

the class TestFlo method testPlanReset.

public void testPlanReset(final String testPlanId) {
    if (Convert.isEmpty(testPlanId)) {
        throw new IllegalArgumentException("testPlanId can't be null or empty string.");
    }
    final Issue issue = jira.getIssue(testPlanId).claim();
    Assert.assertNotNull(String.format("can't get issue for: '%s'.", testPlanId), issue);
    try {
        transition(issue, TestPlanStatus.InProgress, TestPlanTransition.Stop);
    } catch (final SystemException ex) {
        TestFlo.logger.info(String.format("ignore error '%s'.", ex.getMessage()));
    }
    for (final Subtask subtask : issue.getSubtasks()) {
        try {
            transition(subtask, TestCaseStatus.InProgress, TestCaseTransition.Open);
        } catch (final SystemException ex) {
            TestFlo.logger.info(String.format("ignore error '%s'.", ex.getMessage()));
        }
    }
}
Also used : Subtask(com.atlassian.jira.rest.client.api.domain.Subtask) Issue(com.atlassian.jira.rest.client.api.domain.Issue) SystemException(de.simpleworks.staf.commons.exceptions.SystemException)

Example 5 with Subtask

use of com.atlassian.jira.rest.client.api.domain.Subtask in project staf by simpleworks-gmbh.

the class TestFlo method readTestPlan.

public TestPlan readTestPlan(final String testPlanId) throws SystemException {
    if (Convert.isEmpty(testPlanId)) {
        throw new IllegalArgumentException("testPlanId can't be null or empty string.");
    }
    if (TestFlo.logger.isInfoEnabled()) {
        TestFlo.logger.info(String.format("read test plan '%s'.", testPlanId));
    }
    final TestPlan result = new TestPlan();
    result.setId(testPlanId);
    if (TestFlo.logger.isDebugEnabled()) {
        TestFlo.logger.debug(String.format("get issue for testPlanId: '%s'.", testPlanId));
    }
    final Issue issue = jira.getIssue(testPlanId).claim();
    Assert.assertNotNull(String.format("can't get issue for: '%s'.", testPlanId), issue);
    TestFloUtils.checkTestPlanStatus(issue, TestPlanStatus.Open, TestCaseStatus.Open);
    for (final Subtask subtask : issue.getSubtasks()) {
        Assert.assertNotNull("subtask can't be null.", subtask);
        readTestCase(subtask, result);
    }
    return result;
}
Also used : Subtask(com.atlassian.jira.rest.client.api.domain.Subtask) Issue(com.atlassian.jira.rest.client.api.domain.Issue) TestPlan(de.simpleworks.staf.commons.elements.TestPlan)

Aggregations

Subtask (com.atlassian.jira.rest.client.api.domain.Subtask)5 Issue (com.atlassian.jira.rest.client.api.domain.Issue)4 SystemException (de.simpleworks.staf.commons.exceptions.SystemException)3 Attachment (com.atlassian.jira.rest.client.api.domain.Attachment)1 IssueField (com.atlassian.jira.rest.client.api.domain.IssueField)1 IssueType (com.atlassian.jira.rest.client.api.domain.IssueType)1 Status (com.atlassian.jira.rest.client.api.domain.Status)1 Transition (com.atlassian.jira.rest.client.api.domain.Transition)1 TestPlan (de.simpleworks.staf.commons.elements.TestPlan)1