use of org.cerberus.crud.entity.TestCaseStepActionControl in project cerberus-source by cerberustesting.
the class TestCaseStepActionControlDAO method findTestCaseStepActionControlByKey.
@Override
public TestCaseStepActionControl findTestCaseStepActionControlByKey(String test, String testcase, int stepNumber, int sequence, int controlSequence) {
TestCaseStepActionControl actionControl = null;
final String query = "SELECT * FROM testcasestepactioncontrol WHERE test = ? AND testcase = ? AND step = ? AND sequence = ? AND control = ?";
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query)) {
preStat.setString(1, test);
preStat.setString(2, testcase);
preStat.setInt(3, stepNumber);
preStat.setInt(4, sequence);
preStat.setInt(5, controlSequence);
try (ResultSet resultSet = preStat.executeQuery()) {
if (resultSet.first()) {
int sort = resultSet.getInt("Sort");
String conditionOper = resultSet.getString("conditionOper");
String conditionVal1 = resultSet.getString("conditionVal1");
String conditionVal2 = resultSet.getString("conditionVal2");
String control = resultSet.getString("Control");
String value1 = resultSet.getString("Value1");
String value2 = resultSet.getString("Value2");
String fatal = resultSet.getString("Fatal");
String description = resultSet.getString("Description");
String screenshotFilename = resultSet.getString("screenshotFilename");
actionControl = factoryTestCaseStepActionControl.create(test, testcase, stepNumber, sequence, controlSequence, sort, conditionOper, conditionVal1, conditionVal2, control, value1, value2, fatal, description, screenshotFilename);
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
}
return actionControl;
}
use of org.cerberus.crud.entity.TestCaseStepActionControl in project cerberus-source by cerberustesting.
the class TestCaseStepActionControlDAO method readByTestTestCase.
@Override
public AnswerList readByTestTestCase(String test, String testcase) {
AnswerList response = new AnswerList();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
List<TestCaseStepActionControl> controlList = new ArrayList<TestCaseStepActionControl>();
StringBuilder query = new StringBuilder();
query.append("SELECT * FROM testcasestepactioncontrol WHERE test = ? AND testcase = ?");
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());
Statement stm = connection.createStatement()) {
preStat.setString(1, test);
preStat.setString(2, testcase);
try (ResultSet resultSet = preStat.executeQuery();
ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()")) {
// gets the data
while (resultSet.next()) {
controlList.add(this.loadFromResultSet(resultSet));
}
// get the total number of rows
int nrTotalRows = 0;
if (rowSet != null && rowSet.next()) {
nrTotalRows = rowSet.getInt(1);
}
if (controlList.size() >= MAX_ROW_SELECTED) {
// Result of SQl was limited by MAX_ROW_SELECTED constrain. That means that we may miss some lines in the resultList.
LOG.error("Partial Result in the query.");
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Maximum row reached : " + MAX_ROW_SELECTED));
response = new AnswerList(controlList, controlList.size());
} else if (controlList.size() <= 0) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
response = new AnswerList(controlList, controlList.size());
} else {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
response = new AnswerList(controlList, controlList.size());
}
} 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%", "Unable to retrieve the list of entries!"));
}
} 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%", "Unable to retrieve the list of entries!"));
}
response.setResultMessage(msg);
return response;
}
use of org.cerberus.crud.entity.TestCaseStepActionControl in project cerberus-source by cerberustesting.
the class TestCaseStepActionControlDAO method readByVarious1.
@Override
public AnswerList readByVarious1(String test, String testcase, int step, int sequence) {
AnswerList response = new AnswerList();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
List<TestCaseStepActionControl> controlList = new ArrayList<TestCaseStepActionControl>();
StringBuilder query = new StringBuilder();
query.append("SELECT * FROM testcasestepactioncontrol WHERE test = ? AND testcase = ? AND step = ? AND sequence = ?");
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());
Statement stm = connection.createStatement()) {
preStat.setString(1, test);
preStat.setString(2, testcase);
preStat.setInt(3, step);
preStat.setInt(4, sequence);
try (ResultSet resultSet = preStat.executeQuery();
ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()")) {
// gets the data
while (resultSet.next()) {
controlList.add(this.loadFromResultSet(resultSet));
}
// get the total number of rows
int nrTotalRows = 0;
if (rowSet != null && rowSet.next()) {
nrTotalRows = rowSet.getInt(1);
}
if (controlList.size() >= MAX_ROW_SELECTED) {
// Result of SQl was limited by MAX_ROW_SELECTED constrain. That means that we may miss some lines in the resultList.
LOG.error("Partial Result in the query.");
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Maximum row reached : " + MAX_ROW_SELECTED));
response = new AnswerList(controlList, controlList.size());
} else if (controlList.size() <= 0) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
response = new AnswerList(controlList, controlList.size());
} else {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
response = new AnswerList(controlList, controlList.size());
}
} 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%", "Unable to retrieve the list of entries!"));
}
} 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%", "Unable to retrieve the list of entries!"));
}
response.setResultMessage(msg);
return response;
}
use of org.cerberus.crud.entity.TestCaseStepActionControl in project cerberus-source by cerberustesting.
the class TestCaseStepActionControlService method duplicateList.
@Override
public Answer duplicateList(List<TestCaseStepActionControl> objectList, String targetTest, String targetTestCase) {
Answer ans = new Answer(null);
List<TestCaseStepActionControl> listToCreate = new ArrayList();
for (TestCaseStepActionControl objectToDuplicate : objectList) {
objectToDuplicate.setTest(targetTest);
objectToDuplicate.setTestCase(targetTestCase);
listToCreate.add(objectToDuplicate);
}
ans = createList(listToCreate);
return ans;
}
use of org.cerberus.crud.entity.TestCaseStepActionControl in project cerberus-source by cerberustesting.
the class LoadTestCaseService method loadTestCaseStepAction.
public List<TestCaseStepAction> loadTestCaseStepAction(TestCaseStep testCaseStep, TestCaseStep UsedTestCaseStep) {
List<TestCaseStepAction> result = new ArrayList<TestCaseStepAction>();
List<TestCaseStepAction> tcsaToAdd;
/**
* If use Step, take the List of action and control of the used step
*/
boolean useStep = (UsedTestCaseStep != null);
if (!useStep) {
tcsaToAdd = this.testCaseStepActionService.getListOfAction(testCaseStep.getTest(), testCaseStep.getTestCase(), testCaseStep.getStep());
} else {
tcsaToAdd = this.testCaseStepActionService.getListOfAction(UsedTestCaseStep.getTest(), UsedTestCaseStep.getTestCase(), UsedTestCaseStep.getStep());
}
/**
* Iterate on the list of action to get the control
* In case of useStep, print the test,testcase,step of the executed test instead of the used step
*/
for (TestCaseStepAction testCaseStepAction : tcsaToAdd) {
LOG.debug("set list of action :" + testCaseStepAction.getAction());
/**
*/
List<TestCaseStepActionControl> tcsacList = this.loadTestCaseStepActionControl(testCaseStep, testCaseStepAction);
if (tcsacList != null) {
testCaseStepAction.setTestCaseStepActionControl(tcsacList);
}
/**
* Update the test, Testcase, Step in case of useStep
*/
testCaseStepAction.setTest(testCaseStep.getTest());
testCaseStepAction.setTestCase(testCaseStep.getTestCase());
testCaseStepAction.setStep(testCaseStep.getStep());
LOG.debug("adding testCaseStepAction" + testCaseStepAction.getAction());
result.add(testCaseStepAction);
LOG.debug("added testCaseStepAction" + testCaseStepAction.getAction());
}
LOG.debug("return List<TestCaseStepAction>");
return result;
}
Aggregations