use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.
the class TestCaseStepActionExecutionDAO method readByVarious1.
@Override
public AnswerList readByVarious1(long executionId, String test, String testCase, int step, int index) {
MessageEvent msg;
AnswerList answer = new AnswerList();
List<TestCaseStepActionExecution> list = new ArrayList<TestCaseStepActionExecution>();
StringBuilder query = new StringBuilder();
query.append("SELECT * FROM testcasestepactionexecution exa ");
query.append("where exa.id = ? and exa.test = ? and exa.testcase = ? and exa.step = ? and exa.index = ? ");
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query.toString());
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setLong(1, executionId);
preStat.setString(2, test);
preStat.setString(3, testCase);
preStat.setInt(4, step);
preStat.setInt(5, index);
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
list.add(this.loadFromResultset(resultSet));
}
if (list.isEmpty()) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
} else {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
list.clear();
} finally {
if (resultSet != null) {
resultSet.close();
}
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
} finally {
if (preStat != null) {
preStat.close();
}
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to close connection : " + exception.toString());
}
}
answer.setTotalRows(list.size());
answer.setDataList(list);
answer.setResultMessage(msg);
return answer;
}
use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.
the class TestCaseStepActionExecutionDAO method readByKey.
@Override
public AnswerItem readByKey(long executionId, String test, String testCase, int step, int index, int sequence) {
MessageEvent msg;
AnswerItem answer = new AnswerItem();
TestCaseStepActionExecution tcsa = null;
StringBuilder query = new StringBuilder();
query.append("SELECT * FROM testcasestepactionexecution exa ");
query.append("where exa.id = ? and exa.test = ? and exa.testcase = ? and exa.step = ? and exa.index = ? and exa.sequence = .");
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query.toString());
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setLong(1, executionId);
preStat.setString(2, test);
preStat.setString(3, testCase);
preStat.setInt(4, step);
preStat.setInt(5, index);
preStat.setInt(6, sequence);
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
tcsa = this.loadFromResultset(resultSet);
}
if (tcsa == null) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
} else {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
} finally {
if (resultSet != null) {
resultSet.close();
}
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
} finally {
if (preStat != null) {
preStat.close();
}
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to close connection : " + exception.toString());
}
}
answer.setItem(tcsa);
answer.setResultMessage(msg);
return answer;
}
use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.
the class UpdateTestCaseExecution method createTestCaseStepActionExecution.
// create a TestCaseStepActionExecution with the parameters
private TestCaseStepActionExecution createTestCaseStepActionExecution(long id, String test, String testCase, int step, int index, int sequence, int sort, String returnCode, String returnMessage, String conditionOper, String conditionVal1Init, String conditionVal2Init, String conditionVal1, String conditionVal2, String action, String value1Init, String value2Init, String value1, String value2, String forceExeStatus, long start, long end, long startLong, long endLong, MessageEvent resultMessage, String description, TestCaseStepAction testCaseStepAction, TestCaseStepExecution testCaseStepExecution) {
TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();
testCaseStepActionExecution.setAction(action);
testCaseStepActionExecution.setEnd(end);
testCaseStepActionExecution.setEndLong(endLong);
testCaseStepActionExecution.setId(id);
testCaseStepActionExecution.setConditionOper(conditionOper);
testCaseStepActionExecution.setConditionVal1Init(conditionVal1Init);
testCaseStepActionExecution.setConditionVal2Init(conditionVal2Init);
testCaseStepActionExecution.setConditionVal1(conditionVal1);
testCaseStepActionExecution.setConditionVal2(conditionVal2);
testCaseStepActionExecution.setValue1(value1);
testCaseStepActionExecution.setValue2(value2);
testCaseStepActionExecution.setValue1Init(value1Init);
testCaseStepActionExecution.setValue2Init(value2Init);
testCaseStepActionExecution.setForceExeStatus(forceExeStatus);
testCaseStepActionExecution.setReturnCode(returnCode);
testCaseStepActionExecution.setReturnMessage(returnMessage);
testCaseStepActionExecution.setSequence(sequence);
testCaseStepActionExecution.setSort(sort);
testCaseStepActionExecution.setStart(start);
testCaseStepActionExecution.setStartLong(startLong);
testCaseStepActionExecution.setStep(step);
testCaseStepActionExecution.setIndex(index);
testCaseStepActionExecution.setTest(test);
testCaseStepActionExecution.setTestCase(testCase);
testCaseStepActionExecution.setActionResultMessage(resultMessage);
testCaseStepActionExecution.setTestCaseStepAction(testCaseStepAction);
testCaseStepActionExecution.setTestCaseStepExecution(testCaseStepExecution);
testCaseStepActionExecution.setDescription(description);
return testCaseStepActionExecution;
}
use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.
the class CreateUpdateTestCaseExecutionFile method createTestCaseStepActionExecution.
// create a TestCaseStepActionExecution with the parameters
private TestCaseStepActionExecution createTestCaseStepActionExecution(long id, String test, String testCase, int step, int index, int sequence, int sort, String returnCode, String returnMessage, String conditionOper, String conditionVal1Init, String conditionVal2Init, String conditionVal1, String conditionVal2, String action, String value1Init, String value2Init, String value1, String value2, String forceExeStatus, long start, long end, long startLong, long endLong, MessageEvent resultMessage, String description, TestCaseStepAction testCaseStepAction, TestCaseStepExecution testCaseStepExecution) {
TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();
testCaseStepActionExecution.setAction(action);
testCaseStepActionExecution.setEnd(end);
testCaseStepActionExecution.setEndLong(endLong);
testCaseStepActionExecution.setId(id);
testCaseStepActionExecution.setConditionOper(conditionOper);
testCaseStepActionExecution.setConditionVal1Init(conditionVal1Init);
testCaseStepActionExecution.setConditionVal2Init(conditionVal2Init);
testCaseStepActionExecution.setConditionVal1(conditionVal1);
testCaseStepActionExecution.setConditionVal2(conditionVal2);
testCaseStepActionExecution.setValue1(value1);
testCaseStepActionExecution.setValue2(value2);
testCaseStepActionExecution.setValue1Init(value1Init);
testCaseStepActionExecution.setValue2Init(value2Init);
testCaseStepActionExecution.setForceExeStatus(forceExeStatus);
testCaseStepActionExecution.setReturnCode(returnCode);
testCaseStepActionExecution.setReturnMessage(returnMessage);
testCaseStepActionExecution.setSequence(sequence);
testCaseStepActionExecution.setSort(sort);
testCaseStepActionExecution.setStart(start);
testCaseStepActionExecution.setStartLong(startLong);
testCaseStepActionExecution.setStep(step);
testCaseStepActionExecution.setIndex(index);
testCaseStepActionExecution.setTest(test);
testCaseStepActionExecution.setTestCase(testCase);
testCaseStepActionExecution.setActionResultMessage(resultMessage);
testCaseStepActionExecution.setTestCaseStepAction(testCaseStepAction);
testCaseStepActionExecution.setTestCaseStepExecution(testCaseStepExecution);
testCaseStepActionExecution.setDescription(description);
return testCaseStepActionExecution;
}
use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.
the class CreateUpdateTestCaseExecutionFile method updateTestCaseStepActionExecutionFromJsonArray.
/**
* update action execution with testCaseStepActionJson and all the parameter belonging to it (control)
* @param JSONObject testCaseJson
* @param ApplicationContext appContext
* @throws JSONException
* @throws IOException
*/
TestCaseStepActionExecution updateTestCaseStepActionExecutionFromJsonArray(JSONArray testCaseStepActionJson, ApplicationContext appContext) throws JSONException, IOException {
JSONObject currentAction = testCaseStepActionJson.getJSONObject(0);
long id = currentAction.getLong("id");
String test = currentAction.getString("test");
String testCase = currentAction.getString("testcase");
int step = currentAction.getInt("step");
int index = currentAction.getInt("index");
int sort = currentAction.getInt("sort");
int sequence = currentAction.getInt("sequence");
String conditionOper = currentAction.getString("conditionOper");
String conditionVal1Init = currentAction.getString("conditionVal1Init");
String conditionVal2Init = currentAction.getString("conditionVal2Init");
String conditionVal1 = currentAction.getString("conditionVal1");
String conditionVal2 = currentAction.getString("conditionVal2");
String action = currentAction.getString("action");
String value1Init = currentAction.getString("value1init");
String value2Init = currentAction.getString("value2init");
String value1 = currentAction.getString("value1");
String value2 = currentAction.getString("value2");
String forceExeStatus = currentAction.getString("forceExeStatus");
String description = currentAction.getString("description");
String returnCode = currentAction.getString("returnCode");
// String wrote by the user
String returnMessage = StringUtil.sanitize(currentAction.getString("returnMessage"));
// default message unchanged
if (returnMessage.equals("Action not executed"))
returnMessage = "Action executed manually";
long start = currentAction.getLong("start");
long end = currentAction.getLong("end");
// currentAction.getLong("fullStart");
long fullStart = 0;
// currentAction.getLong("fullEnd");
long fullEnd = 0;
// create this testCaseStepActionExecution and update the bdd with it
TestCaseStepActionExecution currentTestCaseStepActionExecution = createTestCaseStepActionExecution(id, test, testCase, step, index, sequence, sort, returnCode, returnMessage, conditionOper, conditionVal1Init, conditionVal2Init, conditionVal1, conditionVal2, action, value1Init, value2Init, value1, value2, forceExeStatus, start, end, fullStart, fullEnd, null, description, null, null);
return currentTestCaseStepActionExecution;
}
Aggregations