use of org.cerberus.crud.entity.TestCaseExecutionQueue in project cerberus-source by cerberustesting.
the class TestCaseExecutionQueueDAO method readBySystemByVarious.
@Override
public AnswerList readBySystemByVarious(String system, List<String> testList, List<String> applicationList, List<String> projectList, List<String> tcstatusList, List<String> groupList, List<String> tcactiveList, List<String> priorityList, List<String> targetsprintList, List<String> targetrevisionList, List<String> creatorList, List<String> implementerList, List<String> buildList, List<String> revisionList, List<String> environmentList, List<String> countryList, List<String> browserList, List<String> tcestatusList, String ip, String port, String tag, String browserversion, String comment, String bugid, String ticket) {
AnswerList answer = new AnswerList();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
List<TestCaseExecutionQueue> tceList = new ArrayList<TestCaseExecutionQueue>();
List<String> whereClauses = new LinkedList<String>();
StringBuilder query = new StringBuilder();
int paramNumber = 0;
query.append(" select t.ID as statusExecutionID, t.* from ( ");
query.append(" select exq.*, tec.*, app.* ");
query.append(" from testcaseexecutionqueue exq ");
query.append(" inner join testcase tec on exq.test = tec.test and exq.testcase = tec.testcase ");
query.append(" inner join application app on tec.application = app.application ");
String testClause = SqlUtil.generateInClause("exq.test", testList);
if (!StringUtil.isNullOrEmpty(testClause)) {
whereClauses.add(testClause);
}
String applicationClause = SqlUtil.generateInClause("tec.application", applicationList);
if (!StringUtil.isNullOrEmpty(applicationClause)) {
whereClauses.add(applicationClause);
}
String projectClause = SqlUtil.generateInClause("tec.project", projectList);
if (!StringUtil.isNullOrEmpty(projectClause)) {
whereClauses.add(projectClause);
}
// test case status: working, fully_implemented, ...
String tcsClause = SqlUtil.generateInClause("exq.status", tcstatusList);
if (!StringUtil.isNullOrEmpty(tcsClause)) {
whereClauses.add(tcsClause);
}
// group
String groupClause = SqlUtil.generateInClause("tec.group", groupList);
if (!StringUtil.isNullOrEmpty(groupClause)) {
whereClauses.add(groupClause);
}
// test case active
String tcactiveClause = SqlUtil.generateInClause("tec.tcactive", tcactiveList);
if (!StringUtil.isNullOrEmpty(tcactiveClause)) {
whereClauses.add(tcactiveClause);
}
// test case active
String priorityClause = SqlUtil.generateInClause("tec.Priority", priorityList);
if (!StringUtil.isNullOrEmpty(priorityClause)) {
whereClauses.add(priorityClause);
}
// target sprint
String targetsprintClause = SqlUtil.generateInClause("tec.TargetBuild", targetsprintList);
if (!StringUtil.isNullOrEmpty(targetsprintClause)) {
whereClauses.add(targetsprintClause);
}
// target revision
String targetrevisionClause = SqlUtil.generateInClause("tec.TargetRev", targetrevisionList);
if (!StringUtil.isNullOrEmpty(targetrevisionClause)) {
whereClauses.add(targetrevisionClause);
}
// creator
String creatorClause = SqlUtil.generateInClause("tec.UsrCreated", creatorList);
if (!StringUtil.isNullOrEmpty(creatorClause)) {
whereClauses.add(creatorClause);
}
// implementer
String implementerClause = SqlUtil.generateInClause("tec.Implementer", implementerList);
if (!StringUtil.isNullOrEmpty(implementerClause)) {
whereClauses.add(implementerClause);
}
// build
String buildClause = SqlUtil.generateInClause("exq.Build", buildList);
if (!StringUtil.isNullOrEmpty(buildClause)) {
whereClauses.add(buildClause);
}
// revision
String revisionClause = SqlUtil.generateInClause("exq.Revision", revisionList);
if (!StringUtil.isNullOrEmpty(revisionClause)) {
whereClauses.add(revisionClause);
}
// environment
String environmentClause = SqlUtil.generateInClause("exq.Environment", environmentList);
if (!StringUtil.isNullOrEmpty(environmentClause)) {
whereClauses.add(environmentClause);
}
// country
String countryClause = SqlUtil.generateInClause("exq.Country", countryList);
if (!StringUtil.isNullOrEmpty(countryClause)) {
whereClauses.add(countryClause);
}
// browser
String browserClause = SqlUtil.generateInClause("exq.Browser", browserList);
if (!StringUtil.isNullOrEmpty(browserClause)) {
whereClauses.add(browserClause);
}
// test case execution
String tcestatusClause = SqlUtil.generateInClause("exq.ControlStatus", tcestatusList);
if (!StringUtil.isNullOrEmpty(tcestatusClause)) {
whereClauses.add(tcestatusClause);
}
if (!StringUtil.isNullOrEmpty(system)) {
whereClauses.add(" app.system like ? ");
}
if (!StringUtil.isNullOrEmpty(ip)) {
whereClauses.add(" exq.IP like ? ");
}
if (!StringUtil.isNullOrEmpty(port)) {
whereClauses.add(" exq.port like ? ");
}
if (!StringUtil.isNullOrEmpty(tag)) {
whereClauses.add(" exq.tag like ? ");
}
if (!StringUtil.isNullOrEmpty(browserversion)) {
whereClauses.add(" exq.browserfullversion like ? ");
}
if (!StringUtil.isNullOrEmpty(comment)) {
whereClauses.add(" exq.comment like ? ");
}
if (!StringUtil.isNullOrEmpty(bugid)) {
whereClauses.add(" tec.BugID like ? ");
}
if (!StringUtil.isNullOrEmpty(ticket)) {
whereClauses.add(" tec.Ticket like ? ");
}
if (whereClauses.size() > 0) {
query.append("where ");
String joined = StringUtils.join(whereClauses, " and ");
query.append(joined);
}
query.append(" order by exq.ID desc ");
query.append(" ) as t group by t.test, t.testcase, t.environment, t.browser, t.country");
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
if (testList != null) {
for (String param : testList) {
preStat.setString(++paramNumber, param);
}
}
if (applicationList != null) {
for (String param : applicationList) {
preStat.setString(++paramNumber, param);
}
}
if (projectList != null) {
for (String param : projectList) {
preStat.setString(++paramNumber, param);
}
}
if (tcstatusList != null) {
for (String param : tcstatusList) {
preStat.setString(++paramNumber, param);
}
}
if (groupList != null) {
for (String param : groupList) {
preStat.setString(++paramNumber, param);
}
}
if (tcactiveList != null) {
for (String param : tcactiveList) {
preStat.setString(++paramNumber, param);
}
}
if (priorityList != null) {
for (String param : priorityList) {
preStat.setString(++paramNumber, param);
}
}
if (targetsprintList != null) {
for (String param : targetsprintList) {
preStat.setString(++paramNumber, param);
}
}
if (targetrevisionList != null) {
for (String param : targetrevisionList) {
preStat.setString(++paramNumber, param);
}
}
if (creatorList != null) {
for (String param : creatorList) {
preStat.setString(++paramNumber, param);
}
}
if (implementerList != null) {
for (String param : implementerList) {
preStat.setString(++paramNumber, param);
}
}
if (buildList != null) {
for (String param : buildList) {
preStat.setString(++paramNumber, param);
}
}
if (revisionList != null) {
for (String param : revisionList) {
preStat.setString(++paramNumber, param);
}
}
// environment
if (environmentList != null) {
for (String param : environmentList) {
preStat.setString(++paramNumber, param);
}
}
// country
if (countryList != null) {
for (String param : countryList) {
preStat.setString(++paramNumber, param);
}
}
// browser
if (browserList != null) {
for (String param : browserList) {
preStat.setString(++paramNumber, param);
}
}
// controlstatus
if (tcestatusList != null) {
for (String param : tcestatusList) {
preStat.setString(++paramNumber, param);
}
}
if (!StringUtil.isNullOrEmpty(system)) {
preStat.setString(++paramNumber, system);
}
if (!StringUtil.isNullOrEmpty(ip)) {
preStat.setString(++paramNumber, "%" + ip + "%");
}
if (!StringUtil.isNullOrEmpty(port)) {
preStat.setString(++paramNumber, "%" + port + "%");
}
if (!StringUtil.isNullOrEmpty(tag)) {
preStat.setString(++paramNumber, "%" + tag + "%");
}
if (!StringUtil.isNullOrEmpty(browserversion)) {
preStat.setString(++paramNumber, "%" + browserversion + "%");
}
if (!StringUtil.isNullOrEmpty(comment)) {
preStat.setString(++paramNumber, "%" + comment + "%");
}
if (!StringUtil.isNullOrEmpty(bugid)) {
preStat.setString(++paramNumber, "%" + bugid + "%");
}
if (!StringUtil.isNullOrEmpty(ticket)) {
preStat.setString(++paramNumber, "%" + ticket + "%");
}
try {
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
tceList.add(this.loadWithDependenciesFromResultSet(resultSet));
}
if (tceList.isEmpty()) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
} else {
msg.setDescription(msg.getDescription().replace("%ITEM%", "TestCaseExecutionInQueue").replace("%OPERATION%", "SELECT"));
}
} catch (SQLException exception) {
LOG.warn("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!"));
tceList.clear();
} catch (FactoryCreationException ex) {
LOG.warn("Unable to execute query : " + ex.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));
tceList.clear();
} finally {
if (resultSet != null) {
resultSet.close();
}
}
} catch (SQLException ex) {
LOG.warn("Unable to execute query : " + ex.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));
} finally {
if (preStat != null) {
preStat.close();
}
}
} catch (SQLException ex) {
LOG.warn(ex.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException ex) {
LOG.warn("Unable to execute query : " + ex.toString());
}
}
answer.setTotalRows(tceList.size());
answer.setDataList(tceList);
answer.setResultMessage(msg);
return answer;
}
use of org.cerberus.crud.entity.TestCaseExecutionQueue in project cerberus-source by cerberustesting.
the class TestCaseExecutionQueueDAO method readByTagByCriteria.
@Override
public AnswerList readByTagByCriteria(String tag, int start, int amount, String sort, String searchTerm, Map<String, List<String>> individualSearch) throws CerberusException {
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
AnswerList answer = new AnswerList();
List<String> individalColumnSearchValues = new ArrayList<String>();
final StringBuilder query = new StringBuilder();
query.append("SELECT * FROM testcaseexecutionqueue exq ");
query.append("left join testcase tec on exq.Test = tec.Test and exq.TestCase = tec.TestCase ");
query.append("left join application app on tec.application = app.application ");
query.append("where exq.ID IN ");
query.append("(select MAX(exq.ID) from testcaseexecutionqueue exq ");
query.append("where 1=1 ");
if (!StringUtil.isNullOrEmpty(tag)) {
query.append("and exq.tag = ? ");
}
query.append("group by exq.test, exq.testcase, exq.Environment, exq.Browser, exq.Country) ");
if (!StringUtil.isNullOrEmpty(searchTerm)) {
query.append("and (exq.`test` like ? ");
query.append(" or exq.`testCase` like ? ");
query.append(" or tec.`application` like ? ");
query.append(" or tec.`bugid` like ? ");
query.append(" or tec.`priority` like ? ");
query.append(" or tec.`description` like ? )");
}
if (individualSearch != null && !individualSearch.isEmpty()) {
query.append(" and ( 1=1 ");
for (Map.Entry<String, List<String>> entry : individualSearch.entrySet()) {
query.append(" and ");
query.append(SqlUtil.getInSQLClauseForPreparedStatement(entry.getKey(), entry.getValue()));
individalColumnSearchValues.addAll(entry.getValue());
}
query.append(" ) ");
}
if (!StringUtil.isNullOrEmpty(sort)) {
query.append(" order by ").append(sort);
}
if ((amount <= 0) || (amount >= MAX_ROW_SELECTED)) {
query.append(" limit ").append(start).append(" , ").append(MAX_ROW_SELECTED);
} else {
query.append(" limit ").append(start).append(" , ").append(amount);
}
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query.toString());
}
List<TestCaseExecutionQueue> testCaseExecutionInQueueList = new ArrayList<TestCaseExecutionQueue>();
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
int i = 1;
if (!StringUtil.isNullOrEmpty(tag)) {
preStat.setString(i++, tag);
}
if (!Strings.isNullOrEmpty(searchTerm)) {
preStat.setString(i++, "%" + searchTerm + "%");
preStat.setString(i++, "%" + searchTerm + "%");
preStat.setString(i++, "%" + searchTerm + "%");
preStat.setString(i++, "%" + searchTerm + "%");
preStat.setString(i++, "%" + searchTerm + "%");
preStat.setString(i++, "%" + searchTerm + "%");
}
for (String individualColumnSearchValue : individalColumnSearchValues) {
preStat.setString(i++, individualColumnSearchValue);
}
try {
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
testCaseExecutionInQueueList.add(this.loadWithDependenciesFromResultSet(resultSet));
}
msg.setDescription(msg.getDescription().replace("%ITEM%", "TestCaseExecutionInQueue").replace("%OPERATION%", "SELECT"));
answer = new AnswerList(testCaseExecutionInQueueList, testCaseExecutionInQueueList.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!"));
testCaseExecutionInQueueList = null;
} catch (FactoryCreationException ex) {
LOG.error("Unable to execute query : " + ex.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));
} finally {
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%", "Unable to retrieve the list of entries!"));
testCaseExecutionInQueueList = null;
} finally {
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%", "Unable to retrieve the list of entries!"));
testCaseExecutionInQueueList = null;
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));
}
}
answer.setResultMessage(msg);
return answer;
}
use of org.cerberus.crud.entity.TestCaseExecutionQueue in project cerberus-source by cerberustesting.
the class TestCaseExecutionQueueDAO method readByKey.
@Override
public AnswerItem<TestCaseExecutionQueue> readByKey(long queueid) {
AnswerItem<TestCaseExecutionQueue> ans = new AnswerItem<>();
TestCaseExecutionQueue result = null;
final String query = "SELECT * FROM `testcaseexecutionqueue` WHERE `ID` = ?";
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);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setLong(1, queueid);
ResultSet resultSet = preStat.executeQuery();
try {
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 (FactoryCreationException ex) {
LOG.error("Error in factory : " + ex.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ex.toString()));
} finally {
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 {
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());
}
}
// sets the message
ans.setResultMessage(msg);
return ans;
}
use of org.cerberus.crud.entity.TestCaseExecutionQueue in project cerberus-source by cerberustesting.
the class TestCaseExecutionQueueDAO method create.
@Override
public AnswerItem<TestCaseExecutionQueue> create(TestCaseExecutionQueue object) {
TestCaseExecutionQueue newObject = object;
MessageEvent msg = null;
StringBuilder query = new StringBuilder();
query.append("INSERT INTO `" + TABLE + "` (`" + COLUMN_TEST + "`, `" + COLUMN_TEST_CASE + "`, `" + COLUMN_COUNTRY + "`, `" + COLUMN_ENVIRONMENT + "`, `" + COLUMN_ROBOT + "`, `" + COLUMN_ROBOT_IP + "`, `" + COLUMN_ROBOT_PORT + "`, `" + COLUMN_BROWSER + "`, `" + COLUMN_BROWSER_VERSION + "`, `" + COLUMN_PLATFORM + "`, `" + COLUMN_SCREENSIZE + "`, `" + COLUMN_MANUAL_URL + "`, `" + COLUMN_MANUAL_HOST + "`, `" + COLUMN_MANUAL_CONTEXT_ROOT + "`, `" + COLUMN_MANUAL_LOGIN_RELATIVE_URL + "`, `" + COLUMN_MANUAL_ENV_DATA + "`, `" + COLUMN_TAG + "`, `" + COLUMN_SCREENSHOT + "`, `" + COLUMN_VERBOSE + "`, `" + COLUMN_TIMEOUT + "`, `" + COLUMN_PAGE_SOURCE + "`, `" + COLUMN_SELENIUM_LOG + "`, `" + COLUMN_RETRIES + "`, `" + COLUMN_MANUAL_EXECUTION + "`, `" + COLUMN_USRCREATED + "`, `" + COLUMN_STATE + "`, `" + COLUMN_COMMENT + "`, `" + COLUMN_DEBUGFLAG + "`, `" + COLUMN_PRIORITY + "`) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query.toString());
LOG.debug("SQL.param.prio : " + object.getPriority());
LOG.debug("SQL.param.debug : " + object.getDebugFlag());
LOG.debug("SQL.param.exeid : " + object.getExeId());
LOG.debug("SQL.param.comment : " + object.getComment());
LOG.debug("SQL.param.state : " + object.getState());
}
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS)) {
int i = 1;
preStat.setString(i++, object.getTest());
preStat.setString(i++, object.getTestCase());
preStat.setString(i++, object.getCountry());
preStat.setString(i++, object.getEnvironment());
preStat.setString(i++, object.getRobot());
preStat.setString(i++, object.getRobotIP());
preStat.setString(i++, object.getRobotPort());
preStat.setString(i++, object.getBrowser());
preStat.setString(i++, object.getBrowserVersion());
preStat.setString(i++, object.getPlatform());
preStat.setString(i++, object.getScreenSize());
preStat.setInt(i++, object.getManualURL());
preStat.setString(i++, object.getManualHost());
preStat.setString(i++, object.getManualContextRoot());
preStat.setString(i++, object.getManualLoginRelativeURL());
preStat.setString(i++, object.getManualEnvData());
preStat.setString(i++, object.getTag());
preStat.setInt(i++, object.getScreenshot());
preStat.setInt(i++, object.getVerbose());
preStat.setString(i++, object.getTimeout());
preStat.setInt(i++, object.getPageSource());
preStat.setInt(i++, object.getSeleniumLog());
preStat.setInt(i++, object.getRetries());
preStat.setString(i++, object.getManualExecution());
String user = object.getUsrCreated() == null ? "" : object.getUsrCreated();
preStat.setString(i++, user);
if (object.getState() == null) {
preStat.setString(i++, object.getState().WAITING.name());
} else {
preStat.setString(i++, object.getState().name());
}
preStat.setString(i++, object.getComment());
preStat.setString(i++, object.getDebugFlag());
preStat.setInt(i++, object.getPriority());
preStat.executeUpdate();
try (ResultSet resultSet = preStat.getGeneratedKeys()) {
if (resultSet.first()) {
newObject.setId(resultSet.getInt(1));
}
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "INSERT"));
} 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()));
}
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "INSERT"));
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
if (exception.getSQLState().equals(SQL_DUPLICATED_CODE)) {
// 23000 is the sql state for duplicate entries
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_DUPLICATE);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "INSERT").replace("%REASON%", exception.toString()));
} else {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
}
}
return new AnswerItem(newObject, msg);
}
use of org.cerberus.crud.entity.TestCaseExecutionQueue in project cerberus-source by cerberustesting.
the class GetReportData method hashExecution.
// </editor-fold>
private List<TestCaseExecution> hashExecution(List<TestCaseExecution> testCaseExecutions, List<TestCaseExecutionQueue> testCaseExecutionsInQueue) throws ParseException {
Map<String, TestCaseExecution> testCaseExecutionsList = new LinkedHashMap();
SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
for (TestCaseExecution testCaseExecution : testCaseExecutions) {
String key = testCaseExecution.getBrowser() + "_" + testCaseExecution.getCountry() + "_" + testCaseExecution.getEnvironment() + "_" + testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();
testCaseExecutionsList.put(key, testCaseExecution);
}
for (TestCaseExecutionQueue testCaseExecutionInQueue : testCaseExecutionsInQueue) {
TestCaseExecution testCaseExecution = testCaseExecutionInQueueService.convertToTestCaseExecution(testCaseExecutionInQueue);
String key = testCaseExecution.getBrowser() + "_" + testCaseExecution.getCountry() + "_" + testCaseExecution.getEnvironment() + "_" + testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();
if ((testCaseExecutionsList.containsKey(key) && testCaseExecutionsList.get(key).getStart() < testCaseExecution.getStart()) || !testCaseExecutionsList.containsKey(key)) {
testCaseExecutionsList.put(key, testCaseExecution);
}
}
List<TestCaseExecution> result = new ArrayList<TestCaseExecution>(testCaseExecutionsList.values());
return result;
}
Aggregations