Skip to content
Merged
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
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
<role>developer</role>
</roles>
</developer>
<developer>
<id>mario-fuentes</id>
<email>mario@gnome.cl</email>
<name>Mario Fuentes</name>
<timezone>-4</timezone>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>

<url>http://sourceforge.net/projects/testlinkjavaapi</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected void checkResponseError( Object response )
{
if ( response instanceof Object[] ) // may be an array of errors (IXError)
{
Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);

for (int i = 0; i < responseArray.length; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected Build createBuild(Integer testPlanId, String buildName, String buildNo
Map<String, Object> executionData = Util.getBuildMap(build);
Object response = this.executeXmlRpcCall(
TestLinkMethods.createBuild.toString(), executionData);
Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);
Map<String, Object> responseMap = (Map<String, Object>)responseArray[0];

id = Util.getInteger(responseMap, TestLinkResponseParams.id.toString());
Expand Down Expand Up @@ -84,7 +84,7 @@ protected Build[] getBuildsForTestPlan( Integer testPlanId )
TestLinkMethods.getBuildsForTestPlan.toString(), executionData);
if ( response instanceof Object[])
{
Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);
builds = new Build[ responseArray.length ];
for (int i = 0; i < responseArray.length; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ protected Execution getLastExecutionResult(
executionData.put( TestLinkParams.testCaseExternalId.toString(), testCaseExternalId );
Object response = this.executeXmlRpcCall(
TestLinkMethods.getLastExecutionResult.toString(), executionData);
Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);
Map<String, Object> responseMap = (Map<String, Object>)responseArray[0];
if ( responseMap instanceof Map<?, ?> && responseMap.size() > 0 )
{
Expand Down
116 changes: 110 additions & 6 deletions src/main/java/br/eti/kinoshita/testlinkjavaapi/TestCaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import br.eti.kinoshita.testlinkjavaapi.model.ResponseDetails;
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
import br.eti.kinoshita.testlinkjavaapi.model.TestCaseStep;
import br.eti.kinoshita.testlinkjavaapi.model.TestCaseStepAction;
import br.eti.kinoshita.testlinkjavaapi.model.TestImportance;
import br.eti.kinoshita.testlinkjavaapi.model.TestLinkMethods;
import br.eti.kinoshita.testlinkjavaapi.model.TestLinkParams;
Expand Down Expand Up @@ -121,7 +122,7 @@ protected TestCase createTestCase(
Map<String, Object> executionData = Util.getTestCaseMap(testCase);
Object response = this.executeXmlRpcCall(
TestLinkMethods.createTestCase.toString(), executionData);
Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);
Map<String, Object> responseMap = (Map<String, Object>)responseArray[0];

id = Util.getInteger(responseMap, TestLinkResponseParams.id.toString());
Expand All @@ -135,6 +136,74 @@ protected TestCase createTestCase(

return testCase;
}

@SuppressWarnings("unchecked")
public Map<String, Object> createTestCaseSteps(
String testCaseExternalId,
Integer version,
TestCaseStepAction action,
List<TestCaseStep> testCaseSteps
)
throws TestLinkAPIException
{
Map<String, Object> responseMap = null;

try
{
Map<String, Object> executionData = new HashMap<String, Object>();

executionData.put(TestLinkParams.testCaseExternalId.toString(), testCaseExternalId);
executionData.put(TestLinkParams.version.toString(), version);
executionData.put(TestLinkParams.action.toString(), action.toString());

List<Map<String, Object>> steps = Util.getTestCaseStepsMap(testCaseSteps);
executionData.put(TestLinkParams.steps.toString(), steps);

Object response = this.executeXmlRpcCall(
TestLinkMethods.createTestCaseSteps.toString(), executionData);
responseMap = (Map<String, Object>) response;
}
catch ( XmlRpcException xmlrpcex )
{
throw new TestLinkAPIException(
"Error adding steps to test case: " + xmlrpcex.getMessage(), xmlrpcex);
}

return responseMap;
}

@SuppressWarnings("unchecked")
public Map<String, Object> deleteTestCaseSteps(
String testCaseExternalId,
Integer version,
List<TestCaseStep> testCaseSteps
)
throws TestLinkAPIException
{
Map<String, Object> responseMap = null;

try
{
Map<String, Object> executionData = new HashMap<String, Object>();

executionData.put(TestLinkParams.testCaseExternalId.toString(), testCaseExternalId);
executionData.put(TestLinkParams.version.toString(), version);

List<Integer> steps = Util.getTestCaseStepsIdList(testCaseSteps);
executionData.put(TestLinkParams.steps.toString(), steps);

Object response = this.executeXmlRpcCall(
TestLinkMethods.deleteTestCaseSteps.toString(), executionData);
responseMap = (Map<String, Object>) response;
}
catch ( XmlRpcException xmlrpcex )
{
throw new TestLinkAPIException(
"Error deleting steps from test case: " + xmlrpcex.getMessage(), xmlrpcex);
}

return responseMap;
}

@SuppressWarnings("unchecked")
protected Integer addTestCaseToTestPlan(
Expand Down Expand Up @@ -201,7 +270,7 @@ protected TestCase[] getTestCasesForTestSuite(
executionData.put(TestLinkParams.details.toString(), details);
Object response = this.executeXmlRpcCall(
TestLinkMethods.getTestCasesForTestSuite.toString(), executionData);
Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);

testCases = new TestCase[ responseArray.length ];

Expand Down Expand Up @@ -312,7 +381,6 @@ else if(entry.getValue() instanceof Map<?, ?>)
return testCases;
}


/**
*
* @param testCaseId
Expand All @@ -339,7 +407,7 @@ protected TestCase getTestCase(Integer testCaseId,

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

Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);
Map<String, Object> responseMap = (Map<String, Object>)responseArray[0];

testCase = Util.getTestCase( responseMap );
Expand All @@ -352,6 +420,42 @@ protected TestCase getTestCase(Integer testCaseId,
return testCase;
}

/**
*
* @param fullTestCaseExternalId Full external id: prefix-externalId
* @param version
* @return
* @throws TestLinkAPIException
*/
@SuppressWarnings("unchecked")
protected TestCase getTestCaseByExternalId(
String fullTestCaseExternalId,
Integer version)
throws TestLinkAPIException
{
TestCase testCase = null;

try
{
Map<String, Object> executionData = new HashMap<String, Object>();

executionData.put(TestLinkParams.testCaseExternalId.toString(), fullTestCaseExternalId);
executionData.put(TestLinkParams.version.toString(), version);

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

Object[] responseArray = Util.castToArray(response);
Map<String, Object> responseMap = (Map<String, Object>)responseArray[0];

testCase = Util.getTestCase( responseMap );
}
catch ( XmlRpcException xmlrpcex )
{
throw new TestLinkAPIException( "Error getting test case info : " + xmlrpcex.getMessage(), xmlrpcex );
}

return testCase;
}

/**
*
Expand Down Expand Up @@ -385,7 +489,7 @@ protected Integer getTestCaseIDByName(
Object response = this.executeXmlRpcCall(
TestLinkMethods.getTestCaseIDByName.toString(), executionData);

Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);
Map<String, Object> responseMap = (Map<String, Object>)responseArray[0];

testCaseID = Util.getInteger(responseMap, TestLinkResponseParams.id.toString());
Expand Down Expand Up @@ -636,7 +740,7 @@ protected ReportTCResultResponse reportTCResult(
// the error verification routine is called inside super.executeXml...
if ( response instanceof Object[] )
{
Object[] responseArray = (Object[])response;
Object[] responseArray = Util.castToArray(response);
Map<String, Object> responseMap = (Map<String, Object>)responseArray[0];

reportTCResultResponse = Util.getReportTCResultResponse( responseMap );
Expand Down
146 changes: 146 additions & 0 deletions src/main/java/br/eti/kinoshita/testlinkjavaapi/TestLinkAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import br.eti.kinoshita.testlinkjavaapi.model.ResponseDetails;
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
import br.eti.kinoshita.testlinkjavaapi.model.TestCaseStep;
import br.eti.kinoshita.testlinkjavaapi.model.TestCaseStepAction;
import br.eti.kinoshita.testlinkjavaapi.model.TestImportance;
import br.eti.kinoshita.testlinkjavaapi.model.TestPlan;
import br.eti.kinoshita.testlinkjavaapi.model.TestProject;
Expand Down Expand Up @@ -862,6 +863,133 @@ public TestCase createTestCase(
);
}

/**
* Create, Update or Push a list of TestCaseSteps in a Test Case.
*
* @param testCaseExternalId
* @param version
* @param testCaseSteps
* @return a Map with results.
* @throws TestLinkAPIException
*/
public Map<String, Object> createTestCaseSteps(
String testCaseExternalId,
Integer version,
TestCaseStepAction action,
List<TestCaseStep> testCaseSteps
)
throws TestLinkAPIException
{
return this.testCaseService.createTestCaseSteps(
testCaseExternalId,
version,
TestCaseStepAction.Create,
testCaseSteps
);
}

/**
* Add a list of TestCaseSteps in a Test Case.
* A convenient method to add steps, internally call to the
* {@link #createTestCaseSteps(Integer, Integer, TestCaseStepAction, List)} method with 'Create' action.
*
* @param testCaseExternalId
* @param version
* @param testCaseSteps
* @return a Map with results.
* @throws TestLinkAPIException
*/
public Map<String, Object> addTestCaseSteps(
String testCaseExternalId,
Integer version,
List<TestCaseStep> testCaseSteps
)
throws TestLinkAPIException
{
return createTestCaseSteps(
testCaseExternalId,
version,
TestCaseStepAction.Create,
testCaseSteps
);
}

/**
* Update (override) a list of TestCaseSteps in a Test Case.
* A convenient method to update steps, internally call to the
* {@link #createTestCaseSteps(Integer, Integer, TestCaseStepAction, List)} method with 'Update' action.
*
* @param testCaseExternalId
* @param version
* @param testCaseSteps
* @return a Map with results.
* @throws TestLinkAPIException
*/
public Map<String, Object> updateTestCaseSteps(
String testCaseExternalId,
Integer version,
List<TestCaseStep> testCaseSteps
)
throws TestLinkAPIException
{
return createTestCaseSteps(
testCaseExternalId,
version,
TestCaseStepAction.Update,
testCaseSteps
);
}

/**
* Push (insert and move down previous steps) a list of
* TestCaseSteps in a TestCase.
* A convenient method to push steps, internally call to the
* {@link #createTestCaseSteps(Integer, Integer, TestCaseStepAction, List)} method with 'Push' action.
*
* @param testCaseExternalId
* @param version
* @param testCaseSteps
* @return a Map with results.
* @throws TestLinkAPIException
*/
public Map<String, Object> pushTestCaseSteps(
String testCaseExternalId,
Integer version,
List<TestCaseStep> testCaseSteps
)
throws TestLinkAPIException
{
return createTestCaseSteps(
testCaseExternalId,
version,
TestCaseStepAction.Push,
testCaseSteps
);
}

/**
* Delete a list if TestCaseSteps from a Test Case.
*
* @param testCaseExternalId
* @param version
* @param testCaseSteps
* @return a Map with results.
* @throws TestLinkAPIException
*/
public Map<String, Object> deleteTestCaseSteps(
String testCaseExternalId,
Integer version,
List<TestCaseStep> testCaseSteps
)
throws TestLinkAPIException
{
return this.testCaseService.deleteTestCaseSteps(
testCaseExternalId,
version,
testCaseSteps
);
}

/**
* Adds a Test Case to a Test Plan.
* @param testProjectId
Expand Down Expand Up @@ -933,6 +1061,24 @@ public TestCase getTestCase(
return this.testCaseService.getTestCase(testCaseId, testCaseExternalId, version);
}

/**
* Get a Test Case using the full external id, composed by the prefix and
* the external id: prefix-externalId
*
* @param fullTestCaseExternalId Full external id: prefix-externalId
* @param version
* @return Test Case.
* @throws TestLinkAPIException
*/
public TestCase getTestCaseByExternalId(
String fullTestCaseExternalId,
Integer version
)
throws TestLinkAPIException
{
return this.testCaseService.getTestCaseByExternalId(fullTestCaseExternalId, version);
}

/**
* Retrieves Test Cases for Test Plans.
*
Expand Down
Loading