Skip to content
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

added API function to retrieve a testsuite's attachments #86

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/java/br/eti/kinoshita/testlinkjavaapi/TestLinkAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,19 @@ public Attachment[] getTestCaseAttachments(Integer testCaseId, Integer testCaseE
return this.testCaseService.getTestCaseAttachments(testCaseId, testCaseExternalId);
}

/**
* Return an array of attachments of a Test Suite.
*
* @param testSuiteId test suite ID
* @return Array of Attachments.
* @throws TestLinkAPIException if service return error
* @author dennis@etern-it.de
*/
public Attachment[] getTestSuiteAttachments(Integer testSuiteId)
throws TestLinkAPIException {
return this.testSuiteService.getTestSuiteAttachments(testSuiteId);
}

/**
* Upload an execution attachment.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,45 @@ protected TestSuite[] getFirstLevelTestSuitesForTestProject(Integer testProjectI

return testSuites;
}

/**
* Get attachments of a test suite.
*
* @param testSuiteId test suite ID
* @return Array of attachments for test suite
* @throws TestLinkAPIException if an error occurs
* @author dennis@etern-it.de
*/
public Attachment[] getTestSuiteAttachments(Integer testSuiteId) {
Attachment[] attachments = null;

try {
Map<String, Object> executionData = new HashMap<String, Object>();
executionData.put(TestLinkParams.TEST_SUITE_ID.toString(), testSuiteId);
Object response = this.executeXmlRpcCall(TestLinkMethods.GET_TEST_SUITE_ATTACHMENTS.toString(), executionData);
if (response instanceof Map<?, ?>) {
Map<String, Object> responseMap = Util.castToMap(response);
Set<Entry<String, Object>> entrySet = responseMap.entrySet();

attachments = new Attachment[entrySet.size()];

int index = 0;
for (Entry<String, Object> entry : entrySet) {
String key = entry.getKey();
Map<String, Object> attachmentMap = (Map<String, Object>) entry.getValue();
attachmentMap.put(TestLinkResponseParams.ID.toString(), key);
attachments[index] = Util.getAttachment(attachmentMap);
index += 1;
}
} else {
attachments = new Attachment[0];
}

} catch (XmlRpcException xmlrpcex) {
throw new TestLinkAPIException("Error retrieving test case's attachments: " + xmlrpcex.getMessage(),
xmlrpcex);
}

return attachments;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public enum TestLinkMethods {
UPLOAD_TEST_PROJECT_ATTACHMENT("tl.uploadTestProjectAttachment"),
UPLOAD_REQUIREMENT_ATTACHMENT("tl.uploadRequirementAttachment"),
UPLOAD_REQUIREMENT_SPECIFICATION_ATTACHMENT("tl.uploadRequirementSpecificationAttachment"),
GET_TEST_CASE_ATTACHMENTS("tl.getTestCaseAttachments"),
GET_TEST_CASE_ATTACHMENTS("tl.getTestCaseAttachments"),
GET_TEST_SUITE_ATTACHMENTS("tl.getTestSuiteAttachments"),
UPLOAD_EXECUTION_ATTACHMENT("tl.uploadExecutionAttachment"),
DELETE_EXECUTION("tl.deleteExecution"),
GET_FULL_PATH("tl.getFullPath"),
Expand Down