use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseDAO method readByKey.
@Override
public AnswerItem readByKey(String test, String testCase) {
AnswerItem ans = new AnswerItem();
TestCase result = null;
final String query = "SELECT * FROM `testcase` tec LEFT OUTER JOIN application app ON app.application=tec.application WHERE tec.`test` = ? AND tec.`testcase` = ?";
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query)) {
preStat.setString(1, test);
preStat.setString(2, testCase);
try (ResultSet resultSet = preStat.executeQuery()) {
if (resultSet.first()) {
result = loadFromResultSet(resultSet);
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
ans.setItem(result);
} else {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
}
} 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()));
}
} 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()));
}
// sets the message
ans.setResultMessage(msg);
return ans;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseExecutionQueueService method convertToTestCaseExecution.
@Override
public TestCaseExecution convertToTestCaseExecution(TestCaseExecutionQueue testCaseExecutionInQueue) {
String test = testCaseExecutionInQueue.getTest();
String testCase = testCaseExecutionInQueue.getTestCase();
String environment = testCaseExecutionInQueue.getEnvironment();
String country = testCaseExecutionInQueue.getCountry();
String browser = testCaseExecutionInQueue.getBrowser();
String robotDecli = testCaseExecutionInQueue.getRobot();
if (StringUtil.isNullOrEmpty(robotDecli)) {
if (!StringUtil.isNullOrEmpty(browser)) {
robotDecli = browser;
} else {
robotDecli = "";
}
}
String version = testCaseExecutionInQueue.getBrowserVersion();
String platform = testCaseExecutionInQueue.getPlatform();
long start = testCaseExecutionInQueue.getRequestDate() != null ? testCaseExecutionInQueue.getRequestDate().getTime() : 0;
long end = 0;
String controlStatus = TestCaseExecution.CONTROLSTATUS_QU;
String controlMessage = "Queued with State : " + testCaseExecutionInQueue.getState().name() + " - " + testCaseExecutionInQueue.getComment();
Application applicationObj = testCaseExecutionInQueue.getApplicationObj();
String application = testCaseExecutionInQueue.getApplicationObj() != null ? testCaseExecutionInQueue.getApplicationObj().getApplication() : "";
String ip = testCaseExecutionInQueue.getRobotIP();
String port = testCaseExecutionInQueue.getRobotPort();
String tag = testCaseExecutionInQueue.getTag();
int verbose = testCaseExecutionInQueue.getVerbose();
int screenshot = testCaseExecutionInQueue.getScreenshot();
int pageSource = testCaseExecutionInQueue.getPageSource();
int seleniumLog = testCaseExecutionInQueue.getSeleniumLog();
int retry = testCaseExecutionInQueue.getRetries();
boolean synchroneous = true;
String timeout = testCaseExecutionInQueue.getTimeout();
String outputFormat = "";
TestCase tCase = testCaseExecutionInQueue.getTestCaseObj();
boolean manualURL = (testCaseExecutionInQueue.getManualURL() >= 1);
String manualExecution = testCaseExecutionInQueue.getManualExecution();
String myHost = testCaseExecutionInQueue.getManualHost();
String myContextRoot = testCaseExecutionInQueue.getManualContextRoot();
String myLoginRelativeURL = testCaseExecutionInQueue.getManualLoginRelativeURL();
String myEnvData = testCaseExecutionInQueue.getManualEnvData();
String seleniumIP = testCaseExecutionInQueue.getRobotIP();
String seleniumPort = testCaseExecutionInQueue.getRobotPort();
String description = "";
if ((testCaseExecutionInQueue.getTestCaseObj() != null) && (testCaseExecutionInQueue.getTestCaseObj().getDescription() != null)) {
description = testCaseExecutionInQueue.getTestCaseObj().getDescription();
}
TestCaseExecution result = factoryTestCaseExecution.create(0, test, testCase, description, null, null, environment, country, browser, version, platform, browser, start, end, controlStatus, controlMessage, application, applicationObj, ip, "", port, tag, verbose, screenshot, pageSource, seleniumLog, synchroneous, timeout, outputFormat, "", "", tCase, null, null, manualURL, myHost, myContextRoot, myLoginRelativeURL, myEnvData, seleniumIP, seleniumPort, null, null, null, retry, "", null, "", "", "", "", "", manualExecution, "", 0, "", robotDecli);
result.setQueueID(testCaseExecutionInQueue.getId());
result.setQueueState(testCaseExecutionInQueue.getState().name());
result.setId(testCaseExecutionInQueue.getExeId());
return result;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseService method readByKeyWithDependency.
@Override
public AnswerItem readByKeyWithDependency(String test, String testCase) {
AnswerItem answer = new AnswerItem(new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED));
AnswerItem ai = testCaseDao.readByKey(test, testCase);
if (ai.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && ai.getItem() != null) {
TestCase tc = (TestCase) ai.getItem();
AnswerList al = testCaseStepService.readByTestTestCaseWithDependency(tc.getTest(), tc.getTestCase());
if (al.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && al.getDataList() != null) {
tc.setTestCaseStep(al.getDataList());
}
answer.setResultMessage(al.getResultMessage());
answer.setItem(tc);
}
return answer;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseService method findTestWithTestCaseActiveAutomatedBySystem.
@Override
public List<String> findTestWithTestCaseActiveAutomatedBySystem(String system) {
TestCase tCase = factoryTCase.create(null, null, null, null, null, null, null, null, null, null, null, null, null, null, -1, null, null, null, null, null, "Y", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
List<String> result = new ArrayList();
List<TestCase> testCases = findTestCaseByAllCriteria(tCase, null, system);
for (TestCase testCase : testCases) {
if (!testCase.getGroup().equals("PRIVATE")) {
result.add(testCase.getTest());
}
}
Set<String> uniqueResult = new HashSet<String>(result);
result = new ArrayList();
result.addAll(uniqueResult);
Collections.sort(result);
return result;
}
use of org.cerberus.crud.entity.TestCase in project cerberus-source by cerberustesting.
the class TestCaseService method findUseTestCaseList.
@Override
public List<TestCase> findUseTestCaseList(String test, String testCase) throws CerberusException {
List<TestCase> result = new ArrayList();
List<TestCaseStep> tcsList = testCaseStepService.getListOfSteps(test, testCase);
for (TestCaseStep tcs : tcsList) {
if (("Y").equals(tcs.getUseStep())) {
result.add(this.findTestCaseByKey(tcs.getUseStepTest(), tcs.getUseStepTestCase()));
}
}
return result;
}
Aggregations