Skip to content

Commit 38b965a

Browse files
authored
Merge pull request #71 from mazimkhan/master
Introduced API for updating Build custom fields values
2 parents 48efcfd + 85223b0 commit 38b965a

File tree

5 files changed

+200
-54
lines changed

5 files changed

+200
-54
lines changed

src/main/java/br/eti/kinoshita/testlinkjavaapi/BuildService.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,37 @@ protected Map<String, Object> getExecCountersByBuild(Integer testPlanId) {
149149
return responseMap;
150150
}
151151

152+
/**
153+
*
154+
* @param buildId
155+
* @param testProjectId
156+
* @param customFields
157+
*/
158+
protected Map<String, Object> updateBuildCustomFields(Integer buildId, Integer testProjectId, Integer testPlanId, Map<String, String> customFields) {
159+
160+
Map<String, Object> responseMap =null;
161+
162+
try {
163+
Map<String, Object> executionData = new HashMap<String, Object>();
164+
165+
executionData.put(TestLinkParams.BUILD_ID.toString(), buildId);
166+
executionData.put(TestLinkParams.TEST_PROJECT_ID.toString(), testProjectId);
167+
executionData.put(TestLinkParams.TEST_PLAN_ID.toString(), testPlanId);
168+
executionData.put(TestLinkParams.CUSTOM_FIELDS.toString(), customFields);
169+
170+
Object response = this.executeXmlRpcCall(TestLinkMethods.UPDATE_BUILD_CUSTOM_FIELDS.toString(),
171+
executionData);
172+
if (response instanceof Map<?, ?>) {
173+
responseMap = Util.castToMap(response);
174+
} else if (! (response instanceof String) ) {
175+
responseMap = Util.castToMap(((Object[]) response)[0]);
176+
}
177+
} catch (XmlRpcException xmlrpcex) {
178+
throw new TestLinkAPIException("Error updating Build custom fields. " + xmlrpcex.getMessage(),
179+
xmlrpcex);
180+
}
181+
182+
return responseMap;
183+
184+
}
152185
}

src/main/java/br/eti/kinoshita/testlinkjavaapi/TestLinkAPI.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,20 @@ public Map<String, Object> addPlatformToTestPlan(Integer testProjectId, Integer
603603
/**
604604
* Creates a Build.
605605
*
606+
* @param buildId Build ID
607+
* @param testProjectId Test Project ID
608+
* @param testPlanId Test Plan ID
609+
* @param customFields Custom Fields name,value pairs
610+
* @return Response XML-RPC Response
611+
* @throws TestLinkAPIException if the service returns as error
612+
*/
613+
public Map<String, Object> updateBuildCustomFields(Integer buildId, Integer testProjectId, Integer testPlanId, Map<String, String> customFields) throws TestLinkAPIException {
614+
return this.buildService.updateBuildCustomFields(buildId, testProjectId, testPlanId, customFields);
615+
}
616+
617+
/**
618+
* Creates a Build.
619+
*
606620
* @param testPlanId test plan ID
607621
* @param buildName build name
608622
* @param buildNotes build notes

0 commit comments

Comments
 (0)