diff --git a/src/main/java/br/eti/kinoshita/testlinkjavaapi/TestLinkAPI.java b/src/main/java/br/eti/kinoshita/testlinkjavaapi/TestLinkAPI.java index f2de6b98..3184d8ef 100644 --- a/src/main/java/br/eti/kinoshita/testlinkjavaapi/TestLinkAPI.java +++ b/src/main/java/br/eti/kinoshita/testlinkjavaapi/TestLinkAPI.java @@ -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. * diff --git a/src/main/java/br/eti/kinoshita/testlinkjavaapi/TestSuiteService.java b/src/main/java/br/eti/kinoshita/testlinkjavaapi/TestSuiteService.java index 69973252..885ee70e 100644 --- a/src/main/java/br/eti/kinoshita/testlinkjavaapi/TestSuiteService.java +++ b/src/main/java/br/eti/kinoshita/testlinkjavaapi/TestSuiteService.java @@ -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 executionData = new HashMap(); + executionData.put(TestLinkParams.TEST_SUITE_ID.toString(), testSuiteId); + Object response = this.executeXmlRpcCall(TestLinkMethods.GET_TEST_SUITE_ATTACHMENTS.toString(), executionData); + if (response instanceof Map) { + Map responseMap = Util.castToMap(response); + Set> entrySet = responseMap.entrySet(); + + attachments = new Attachment[entrySet.size()]; + + int index = 0; + for (Entry entry : entrySet) { + String key = entry.getKey(); + Map attachmentMap = (Map) 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; + } } diff --git a/src/main/java/br/eti/kinoshita/testlinkjavaapi/constants/TestLinkMethods.java b/src/main/java/br/eti/kinoshita/testlinkjavaapi/constants/TestLinkMethods.java index 42eb1996..81479cab 100644 --- a/src/main/java/br/eti/kinoshita/testlinkjavaapi/constants/TestLinkMethods.java +++ b/src/main/java/br/eti/kinoshita/testlinkjavaapi/constants/TestLinkMethods.java @@ -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"),