Skip to content

Commit

Permalink
implemented support for testplan custom fields values obtaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Saravayskiy committed Jan 13, 2016
1 parent c173b57 commit bd0cd4f
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>br.eti.kinoshita</groupId>
<artifactId>testlink-java-api</artifactId>
<version>1.9.13-1-SNAPSHOT</version>
<version>1.9.13-3-SNAPSHOT</version>
<name>TestLink Java API</name>
<description>TestLink Java API interfaces TestLink PHP xml-rpc API.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

/**
* Class responsible for Test Case services.
*
*
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
* @since 1.9.0-1
*/
Expand All @@ -70,7 +70,7 @@ public TestCaseService(XmlRpcClient xmlRpcClient, String devKey) {

/**
* Creates a Test Case.
*
*
* @param testCaseName
* @param testSuiteId
* @param testProjectId
Expand Down Expand Up @@ -197,7 +197,6 @@ protected Integer addTestCaseToTestPlan(Integer testProjectId, Integer testPlanI
/**
* @param testSuiteId
* @param deep
* @param DETAILS
* @return
*/
protected TestCase[] getTestCasesForTestSuite(Integer testSuiteId, Boolean deep, TestCaseDetails detail)
Expand Down Expand Up @@ -303,7 +302,7 @@ protected TestCase[] getTestCasesForTestPlan(Integer testPlanId, List<Integer> t
}

/**
*
*
* @param testCaseId
* @param testCaseExternalId
* @param version
Expand Down Expand Up @@ -335,7 +334,7 @@ protected TestCase getTestCase(Integer testCaseId, Integer testCaseExternalId, I
}

/**
*
*
* @param fullTestCaseExternalId Full external id: prefix-externalId
* @param version
* @return
Expand Down Expand Up @@ -365,8 +364,6 @@ protected TestCase getTestCaseByExternalId(String fullTestCaseExternalId, Intege
}

/**
*
* @param DEV_KEY
* @param testCaseName
* @param testSuiteName
* @param testProjectName
Expand Down Expand Up @@ -536,7 +533,7 @@ protected void deleteExecution(Integer executionId) throws TestLinkAPIException
*/
protected ReportTCResultResponse reportTCResult(Integer testCaseId, Integer testCaseExternalId, Integer testPlanId,
ExecutionStatus status, Integer buildId, String buildName, String notes, Boolean guess, String bugId,
Integer platformId, String platformName, Map<String, String> customFields,
Integer platformId, String platformName, Map<String, String> customFields,
Boolean overwrite) throws TestLinkAPIException {
// TODO: Map<String, String> customFields =>
// change for a list of custom fields. After implementing method getTestCaseCustomFieldDesignValue this
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/br/eti/kinoshita/testlinkjavaapi/TestLinkAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,21 @@ public CustomField getTestCaseCustomFieldDesignValue(Integer testCaseId, Integer
testProjectId, customFieldName, details);
}

/**
* Gets the test plan custom field value
*
* @param testPlanId
* @param testProjectId
* @param customFieldName
* @param details
* @return
* @throws TestLinkAPIException
*/
public CustomField getTestPlanCustomFieldDesignValue(Integer testPlanId, Integer testProjectId,
String customFieldName, ResponseDetails details) throws TestLinkAPIException{
return this.testPlanService.getTestPlanCustomFieldDesignValue(testPlanId, testProjectId, customFieldName, details);
}

/**
* Gets the test case custom field value on test plan design scope.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.HashMap;
import java.util.Map;

import br.eti.kinoshita.testlinkjavaapi.constants.ResponseDetails;
import br.eti.kinoshita.testlinkjavaapi.model.CustomField;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
Expand Down Expand Up @@ -117,6 +119,44 @@ protected TestPlan getTestPlanByName(String planName, String projectName)
return testPlan;
}

/**
*
* @param testPlanId
* @param testProjectId
* @param customFieldName
* @param details
* @return
* @throws TestLinkAPIException
*/
protected CustomField getTestPlanCustomFieldDesignValue(Integer testPlanId, Integer testProjectId, String customFieldName, ResponseDetails details)
throws TestLinkAPIException {
CustomField customField = null;
try {
Map<String, Object> executionData = new HashMap<String, Object>();
executionData.put(TestLinkParams.TEST_PLAN_ID.toString(), testPlanId);
executionData.put(TestLinkParams.TEST_PROJECT_ID.toString(), testProjectId);
executionData.put(TestLinkParams.CUSTOM_FIELD_NAME.toString(), customFieldName);
executionData.put(TestLinkParams.DETAILS.toString(), Util.getStringValueOrNull(details));

Object response = this.executeXmlRpcCall(
TestLinkMethods.GET_TEST_PLAN_CUSTOM_FIELD_DESIGN_VALUE.toString(), executionData);

if (response instanceof String) {
customField = new CustomField();
customField.setValue(response.toString());
} else if (response instanceof Map<?, ?>) {
Map<String, Object> responseMap = Util.castToMap(response);
customField = Util.getCustomField(responseMap);
}
}
catch (XmlRpcException xmlrpcex) {
throw new TestLinkAPIException("Error retrieving test case custom field value: " + xmlrpcex.getMessage(),
xmlrpcex);
}

return customField;
}

/**
* @param planId
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public enum TestLinkMethods {
GET_LATEST_BUILD_FOR_TEST_PLAN("tl.getLatestBuildForTestPlan"),
GET_TEST_CASE_CUSTOM_FIELD_DESIGN_VALUE("tl.getTestCaseCustomFieldDesignValue"),
GET_TEST_CASE_CUSTOM_FIELD_TEST_PLAN_DESIGN_VALUE("tl.getTestCaseCustomFieldTestPlanDesignValue"),
GET_TEST_CASE_CUSTOM_FIELD_EXECUTION_VALUE("tl.getTestCaseCustomFieldExecutionValue"),
GET_TEST_CASE_CUSTOM_FIELD_EXECUTION_VALUE("tl.getTestCaseCustomFieldExecutionValue"),
GET_TEST_PLAN_CUSTOM_FIELD_DESIGN_VALUE("tl.getTestPlanCustomFieldDesignValue"),
GET_TOTALS_FOR_TEST_PLAN("tl.getTotalsForTestPlan"),
GET_EXEC_COUNTERS_BY_BUILD("tl.getExecCountersByBuild"),
UPDATE_TEST_CASE_CUSTOM_FIELD_VALUE("tl.updateTestCaseCustomFieldDesignValue"),
Expand Down
33 changes: 30 additions & 3 deletions src/main/java/br/eti/kinoshita/testlinkjavaapi/model/TestPlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package br.eti.kinoshita.testlinkjavaapi.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
Expand All @@ -39,15 +41,17 @@ public class TestPlan implements Serializable {
private String notes;
private Boolean isActive;
private Boolean isPublic;

private List<CustomField> customFields;
/**
*
*/
public TestPlan() {
super();
super();
this.customFields = new ArrayList<CustomField>();
}

/**
*
* @param id
* @param name
* @param projectName
Expand All @@ -56,14 +60,29 @@ public TestPlan() {
* @param isPublic
*/
public TestPlan(Integer id, String name, String projectName, String notes,
Boolean isActive, Boolean isPublic) {
Boolean isActive, Boolean isPublic){
this(id, name, projectName, notes, isActive, isPublic, new ArrayList<CustomField>());
}

/**
* @param id
* @param name
* @param projectName
* @param notes
* @param isActive
* @param isPublic
* @param customFields
*/
public TestPlan(Integer id, String name, String projectName, String notes,
Boolean isActive, Boolean isPublic, List<CustomField> customFields) {
super();
this.id = id;
this.name = name;
this.projectName = projectName;
this.notes = notes;
this.isActive = isActive;
this.isPublic = isPublic;
this.customFields = customFields;
}

/**
Expand Down Expand Up @@ -156,6 +175,14 @@ public void setPublic(Boolean isPublic) {
this.isPublic = isPublic;
}

public List<CustomField> getCustomFields() {
return customFields;
}

public void setCustomFields(List<CustomField> customFields) {
this.customFields = customFields;
}

/*
* (non-Javadoc)
*
Expand Down

0 comments on commit bd0cd4f

Please sign in to comment.