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())));
}
}
}
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)));
}
}
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)));
}
}
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()));
}
}
}
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;
}
Aggregations