How to use loadFromResultSet method of org.cerberus.crud.dao.impl.TestCaseExecutionQueueDAO class

Best Cerberus-source code snippet using org.cerberus.crud.dao.impl.TestCaseExecutionQueueDAO.loadFromResultSet

Source:TestCaseExecutionQueueDAO.java Github

copy

Full Screen

...126 preStat.setLong(1, queueid);127 ResultSet resultSet = preStat.executeQuery();128 try {129 if (resultSet.first()) {130 result = loadFromResultSet(resultSet);131 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);132 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));133 ans.setItem(result);134 } else {135 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);136 }137 } catch (SQLException exception) {138 LOG.error("Unable to execute query : " + exception.toString());139 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);140 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));141 } catch (FactoryCreationException ex) {142 LOG.error("Error in factory : " + ex.toString());143 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);144 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ex.toString()));145 } finally {146 resultSet.close();147 }148 } catch (SQLException exception) {149 LOG.error("Unable to execute query : " + exception.toString());150 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);151 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));152 } finally {153 preStat.close();154 }155 } catch (SQLException exception) {156 LOG.error("Unable to execute query : " + exception.toString());157 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);158 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));159 } finally {160 try {161 if (connection != null) {162 connection.close();163 }164 } catch (SQLException exception) {165 LOG.warn("Unable to close connection : " + exception.toString());166 }167 }168 //sets the message169 ans.setResultMessage(msg);170 return ans;171 }172 @Override173 public List<TestCaseExecutionQueue> findTestCaseExecutionInQueuebyTag(String tag) throws CerberusException {174 boolean throwEx = false;175 final StringBuilder query = new StringBuilder("select exq.*, tec.*, app.* from ( select exq.* ")176 .append("from testcaseexecutionqueue exq ")177 .append("where exq.tag = ? ")178 .append(" order by exq.test, exq.testcase, exq.ID desc) as exq ")179 .append("LEFT JOIN testcase tec on exq.Test = tec.Test and exq.TestCase = tec.TestCase ")180 .append("LEFT JOIN application app ON tec.application = app.application ")181 .append("GROUP BY exq.test, exq.testcase, exq.Environment, exq.Browser, exq.Country ");182 List<TestCaseExecutionQueue> testCaseExecutionInQueueList = new ArrayList<TestCaseExecutionQueue>();183 Connection connection = this.databaseSpring.connect();184 try {185 PreparedStatement preStat = connection.prepareStatement(query.toString());186 preStat.setString(1, tag);187 try {188 ResultSet resultSet = preStat.executeQuery();189 try {190 while (resultSet.next()) {191 testCaseExecutionInQueueList.add(this.loadWithDependenciesFromResultSet(resultSet));192 }193 } catch (SQLException exception) {194 LOG.error("Unable to execute query : " + exception.toString());195 testCaseExecutionInQueueList = null;196 } catch (FactoryCreationException ex) {197 LOG.error("Unable to execute query : " + ex.toString());198 } finally {199 resultSet.close();200 }201 } catch (SQLException exception) {202 LOG.error("Unable to execute query : " + exception.toString());203 testCaseExecutionInQueueList = null;204 } finally {205 preStat.close();206 }207 } catch (SQLException exception) {208 LOG.error("Unable to execute query : " + exception.toString());209 testCaseExecutionInQueueList = null;210 } finally {211 try {212 if (connection != null) {213 connection.close();214 }215 } catch (SQLException e) {216 LOG.warn(e.toString());217 }218 }219 if (throwEx) {220 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));221 }222 return testCaseExecutionInQueueList;223 }224 @Override225 public AnswerList readByTagByCriteria(String tag, int start, int amount, String sort, String searchTerm, Map<String, List<String>> individualSearch) throws CerberusException {226 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);227 AnswerList answer = new AnswerList();228 List<String> individalColumnSearchValues = new ArrayList<String>();229 final StringBuilder query = new StringBuilder();230 query.append("SELECT * FROM testcaseexecutionqueue exq ");231 query.append("left join testcase tec on exq.Test = tec.Test and exq.TestCase = tec.TestCase ");232 query.append("left join application app on tec.application = app.application ");233 query.append("where exq.ID IN ");234 query.append("(select MAX(exq.ID) from testcaseexecutionqueue exq ");235 query.append("where 1=1 ");236 if (!StringUtil.isNullOrEmpty(tag)) {237 query.append("and exq.tag = ? ");238 }239 query.append("group by exq.test, exq.testcase, exq.Environment, exq.Browser, exq.Country) ");240 if (!StringUtil.isNullOrEmpty(searchTerm)) {241 query.append("and (exq.`test` like ? ");242 query.append(" or exq.`testCase` like ? ");243 query.append(" or tec.`application` like ? ");244 query.append(" or tec.`bugid` like ? ");245 query.append(" or tec.`priority` like ? ");246 query.append(" or tec.`description` like ? )");247 }248 if (individualSearch != null && !individualSearch.isEmpty()) {249 query.append(" and ( 1=1 ");250 for (Map.Entry<String, List<String>> entry : individualSearch.entrySet()) {251 query.append(" and ");252 query.append(SqlUtil.getInSQLClauseForPreparedStatement(entry.getKey(), entry.getValue()));253 individalColumnSearchValues.addAll(entry.getValue());254 }255 query.append(" ) ");256 }257 if (!StringUtil.isNullOrEmpty(sort)) {258 query.append(" order by ").append(sort);259 }260 if ((amount <= 0) || (amount >= MAX_ROW_SELECTED)) {261 query.append(" limit ").append(start).append(" , ").append(MAX_ROW_SELECTED);262 } else {263 query.append(" limit ").append(start).append(" , ").append(amount);264 }265 // Debug message on SQL.266 if (LOG.isDebugEnabled()) {267 LOG.debug("SQL : " + query.toString());268 }269 List<TestCaseExecutionQueue> testCaseExecutionInQueueList = new ArrayList<TestCaseExecutionQueue>();270 Connection connection = this.databaseSpring.connect();271 try {272 PreparedStatement preStat = connection.prepareStatement(query.toString());273 int i = 1;274 if (!StringUtil.isNullOrEmpty(tag)) {275 preStat.setString(i++, tag);276 }277 if (!Strings.isNullOrEmpty(searchTerm)) {278 preStat.setString(i++, "%" + searchTerm + "%");279 preStat.setString(i++, "%" + searchTerm + "%");280 preStat.setString(i++, "%" + searchTerm + "%");281 preStat.setString(i++, "%" + searchTerm + "%");282 preStat.setString(i++, "%" + searchTerm + "%");283 preStat.setString(i++, "%" + searchTerm + "%");284 }285 for (String individualColumnSearchValue : individalColumnSearchValues) {286 preStat.setString(i++, individualColumnSearchValue);287 }288 try {289 ResultSet resultSet = preStat.executeQuery();290 try {291 while (resultSet.next()) {292 testCaseExecutionInQueueList.add(this.loadWithDependenciesFromResultSet(resultSet));293 }294 msg.setDescription(msg.getDescription().replace("%ITEM%", "TestCaseExecutionInQueue").replace("%OPERATION%", "SELECT"));295 answer = new AnswerList(testCaseExecutionInQueueList, testCaseExecutionInQueueList.size());296 } catch (SQLException exception) {297 LOG.error("Unable to execute query : " + exception.toString());298 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);299 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));300 testCaseExecutionInQueueList = null;301 } catch (FactoryCreationException ex) {302 LOG.error("Unable to execute query : " + ex.toString());303 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);304 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));305 } finally {306 resultSet.close();307 }308 } catch (SQLException exception) {309 LOG.error("Unable to execute query : " + exception.toString());310 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);311 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));312 testCaseExecutionInQueueList = null;313 } finally {314 preStat.close();315 }316 } catch (SQLException exception) {317 LOG.error("Unable to execute query : " + exception.toString());318 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);319 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));320 testCaseExecutionInQueueList = null;321 } finally {322 try {323 if (connection != null) {324 connection.close();325 }326 } catch (SQLException e) {327 LOG.warn(e.toString());328 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);329 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));330 }331 }332 answer.setResultMessage(msg);333 return answer;334 }335 @Override336 public AnswerList readByVarious1(String tag, List<String> stateList, boolean withDependencies) throws CerberusException {337 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);338 AnswerList answer = new AnswerList();339 final StringBuilder query = new StringBuilder();340 query.append("SELECT * FROM testcaseexecutionqueue exq ");341 if (withDependencies) {342 query.append("left join testcase tec on exq.Test = tec.Test and exq.TestCase = tec.TestCase ");343 query.append("left join application app on tec.application = app.application ");344 }345 query.append("where exq.tag = ? ");346 query.append(SqlUtil.createWhereInClause(" AND exq.state", stateList, true));347 // Debug message on SQL.348 if (LOG.isDebugEnabled()) {349 LOG.debug("SQL : " + query.toString());350 LOG.debug("SQL.param.tag : " + tag);351 }352 List<TestCaseExecutionQueue> testCaseExecutionInQueueList = new ArrayList<TestCaseExecutionQueue>();353 Connection connection = this.databaseSpring.connect();354 try {355 PreparedStatement preStat = connection.prepareStatement(query.toString());356 preStat.setString(1, tag);357 try {358 ResultSet resultSet = preStat.executeQuery();359 try {360 while (resultSet.next()) {361 if (withDependencies) {362 testCaseExecutionInQueueList.add(this.loadWithDependenciesFromResultSet(resultSet));363 } else {364 testCaseExecutionInQueueList.add(this.loadFromResultSet(resultSet));365 }366 }367 msg.setDescription(msg.getDescription().replace("%ITEM%", "TestCaseExecutionInQueue").replace("%OPERATION%", "SELECT"));368 answer = new AnswerList(testCaseExecutionInQueueList, testCaseExecutionInQueueList.size());369 } catch (SQLException exception) {370 LOG.error("Unable to execute query : " + exception.toString());371 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);372 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));373 testCaseExecutionInQueueList = null;374 } catch (FactoryCreationException ex) {375 LOG.error("Unable to execute query : " + ex.toString());376 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);377 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));378 } finally {379 resultSet.close();380 }381 } catch (SQLException exception) {382 LOG.error("Unable to execute query : " + exception.toString());383 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);384 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));385 testCaseExecutionInQueueList = null;386 } finally {387 preStat.close();388 }389 } catch (SQLException exception) {390 LOG.error("Unable to execute query : " + exception.toString());391 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);392 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));393 testCaseExecutionInQueueList = null;394 } finally {395 try {396 if (connection != null) {397 connection.close();398 }399 } catch (SQLException e) {400 LOG.warn(e.toString());401 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);402 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));403 }404 }405 answer.setResultMessage(msg);406 return answer;407 }408 @Override409 public AnswerList readByVarious2(List<String> stateList) throws CerberusException {410 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);411 AnswerList answer = new AnswerList();412 final StringBuilder query = new StringBuilder();413 query.append("SELECT exq.id, exq.manualexecution, app.System, cea.environment, cea.country, cea.application, cea.poolsize, exq.robotIP, rbt.host, exq.DebugFlag, app.type ");414 query.append("from testcaseexecutionqueue exq ");415 query.append("left join testcase tec on tec.test=exq.test and tec.testcase=exq.testcase ");416 query.append("left join application app on app.application=tec.application ");417 query.append("left join robot rbt on rbt.robot=exq.robot ");418 query.append("left join countryenvironmentparameters cea on cea.system=app.system and cea.environment=exq.environment and cea.country=exq.country and cea.application=tec.application ");419 query.append("WHERE 1=1 ");420 query.append(SqlUtil.createWhereInClause(" AND exq.state", stateList, true));421 query.append("order by exq.priority, exq.id asc;");422 // Debug message on SQL.423 if (LOG.isDebugEnabled()) {424 LOG.debug("SQL : " + query.toString());425 }426 List<TestCaseExecutionQueueToTreat> testCaseExecutionInQueueList = new ArrayList<TestCaseExecutionQueueToTreat>();427 Connection connection = this.databaseSpring.connect();428 try {429 PreparedStatement preStat = connection.prepareStatement(query.toString());430 try {431 ResultSet resultSet = preStat.executeQuery();432 try {433 while (resultSet.next()) {434 testCaseExecutionInQueueList.add(loadQueueToTreatFromResultSet(resultSet));435 }436 msg.setDescription(msg.getDescription().replace("%ITEM%", "TestCaseExecutionInQueue").replace("%OPERATION%", "SELECT"));437 answer = new AnswerList(testCaseExecutionInQueueList, testCaseExecutionInQueueList.size());438 } catch (SQLException exception) {439 LOG.error("Unable to execute query : " + exception.toString());440 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);441 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));442 testCaseExecutionInQueueList = null;443 } finally {444 resultSet.close();445 }446 } catch (SQLException exception) {447 LOG.error("Unable to execute query : " + exception.toString());448 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);449 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));450 testCaseExecutionInQueueList = null;451 } finally {452 preStat.close();453 }454 } catch (SQLException exception) {455 LOG.error("Unable to execute query : " + exception.toString());456 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);457 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));458 testCaseExecutionInQueueList = null;459 } finally {460 try {461 if (connection != null) {462 connection.close();463 }464 } catch (SQLException e) {465 LOG.warn(e.toString());466 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);467 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));468 }469 }470 answer.setResultMessage(msg);471 return answer;472 }473 @Override474 public AnswerList readByCriteria(int start, int amount, String column, String dir, String searchTerm, Map<String, List<String>> individualSearch) {475 AnswerList response = new AnswerList();476 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);477 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));478 List<TestCaseExecutionQueue> objectList = new ArrayList<TestCaseExecutionQueue>();479 StringBuilder searchSQL = new StringBuilder();480 List<String> individalColumnSearchValues = new ArrayList<String>();481 StringBuilder query = new StringBuilder();482 //SQL_CALC_FOUND_ROWS allows to retrieve the total number of columns by disrearding the limit clauses that483 //were applied -- used for pagination p484 query.append("SELECT SQL_CALC_FOUND_ROWS * FROM testcaseexecutionqueue exq ");485 query.append(" WHERE 1=1");486 if (!StringUtil.isNullOrEmpty(searchTerm)) {487 searchSQL.append(" and (exq.ID like ?");488 searchSQL.append(" or exq.Test like ?");489 searchSQL.append(" or exq.TestCase like ?");490 searchSQL.append(" or exq.Country like ?");491 searchSQL.append(" or exq.Environment like ?");492 searchSQL.append(" or exq.Browser like ?");493 searchSQL.append(" or exq.Tag like ?");494 searchSQL.append(" or exq.State like ?)");495 }496 if (individualSearch != null && !individualSearch.isEmpty()) {497 searchSQL.append(" and ( 1=1 ");498 for (Map.Entry<String, List<String>> entry : individualSearch.entrySet()) {499 searchSQL.append(" and ");500 String q = SqlUtil.getInSQLClauseForPreparedStatement(entry.getKey(), entry.getValue());501 if (q == null || q == "") {502 q = "(exq." + entry.getKey() + " IS NULL OR " + entry.getKey() + " = '')";503 }504 searchSQL.append(q);505 individalColumnSearchValues.addAll(entry.getValue());506 }507 searchSQL.append(" )");508 }509 query.append(searchSQL);510 if (!StringUtil.isNullOrEmpty(column)) {511 query.append(" order by exq.").append(column).append(" ").append(dir);512 }513 if ((amount <= 0) || (amount >= MAX_ROW_SELECTED)) {514 query.append(" limit ").append(start).append(" , ").append(MAX_ROW_SELECTED);515 } else {516 query.append(" limit ").append(start).append(" , ").append(amount);517 }518 // Debug message on SQL.519 if (LOG.isDebugEnabled()) {520 LOG.debug("SQL : " + query.toString());521 }522 Connection connection = this.databaseSpring.connect();523 try {524 PreparedStatement preStat = connection.prepareStatement(query.toString());525 try {526 int i = 1;527 if (!StringUtil.isNullOrEmpty(searchTerm)) {528 preStat.setString(i++, "%" + searchTerm + "%");529 preStat.setString(i++, "%" + searchTerm + "%");530 preStat.setString(i++, "%" + searchTerm + "%");531 preStat.setString(i++, "%" + searchTerm + "%");532 preStat.setString(i++, "%" + searchTerm + "%");533 preStat.setString(i++, "%" + searchTerm + "%");534 preStat.setString(i++, "%" + searchTerm + "%");535 preStat.setString(i++, "%" + searchTerm + "%");536 }537 for (String individualColumnSearchValue : individalColumnSearchValues) {538 preStat.setString(i++, individualColumnSearchValue);539 }540 ResultSet resultSet = preStat.executeQuery();541 try {542 //gets the data543 while (resultSet.next()) {544 objectList.add(this.loadFromResultSet(resultSet));545 }546 //get the total number of rows547 resultSet = preStat.executeQuery("SELECT FOUND_ROWS()");548 int nrTotalRows = 0;549 if (resultSet != null && resultSet.next()) {550 nrTotalRows = resultSet.getInt(1);551 }552 if (objectList.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.553 LOG.error("Partial Result in the query.");554 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT);555 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Maximum row reached : " + MAX_ROW_SELECTED));556 response = new AnswerList(objectList, nrTotalRows);557 } else if (objectList.size() <= 0) {558 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);559 response = new AnswerList(objectList, nrTotalRows);560 } else {561 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);562 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));563 response = new AnswerList(objectList, nrTotalRows);564 }565 } catch (SQLException exception) {566 LOG.error("Unable to execute query : " + exception.toString());567 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);568 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));569 } catch (FactoryCreationException exception) {570 LOG.error("Unable to create Test Case Execution In Queue from Factory : " + exception.toString());571 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);572 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));573 } finally {574 if (resultSet != null) {575 resultSet.close();576 }577 }578 } catch (SQLException exception) {579 LOG.error("Unable to execute query : " + exception.toString());580 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);581 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));582 } finally {583 if (preStat != null) {584 preStat.close();585 }586 }587 } catch (SQLException exception) {588 LOG.error("Unable to execute query : " + exception.toString());589 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);590 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));591 } finally {592 try {593 if (!this.databaseSpring.isOnTransaction()) {594 if (connection != null) {595 connection.close();596 }597 }598 } catch (SQLException exception) {599 LOG.warn("Unable to close connection : " + exception.toString());600 }601 }602 response.setResultMessage(msg);603 response.setDataList(objectList);604 return response;605 }606 @Override607 public int getNbEntryToGo(long id, int prio) {608 AnswerItem<TestCaseExecutionQueue> ans = new AnswerItem<>();609 TestCaseExecutionQueue result = null;610 final String query = "SELECT count(*) FROM testcaseexecutionqueue WHERE State = 'QUEUED' and (ID < ? and Priority <= ?);";611 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);612 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));613 // Debug message on SQL.614 if (LOG.isDebugEnabled()) {615 LOG.debug("SQL : " + query);616 }617 Connection connection = this.databaseSpring.connect();618 try {619 PreparedStatement preStat = connection.prepareStatement(query);620 try {621 int i = 1;622 preStat.setLong(i++, id);623 preStat.setInt(i++, prio);624 ResultSet resultSet = preStat.executeQuery();625 try {626 if (resultSet.first()) {627 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);628 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));629 return resultSet.getInt(1);630 } else {631 LOG.error("No record found : " + query);632 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);633 }634 } catch (SQLException exception) {635 LOG.error("Unable to execute query : " + exception.toString());636 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);637 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));638 } finally {639 resultSet.close();640 }641 } catch (SQLException exception) {642 LOG.error("Unable to execute query : " + exception.toString());643 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);644 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));645 } finally {646 preStat.close();647 }648 } catch (SQLException exception) {649 LOG.error("Unable to execute query : " + exception.toString());650 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);651 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));652 } finally {653 try {654 if (connection != null) {655 connection.close();656 }657 } catch (SQLException exception) {658 LOG.warn("Unable to close connection : " + exception.toString());659 }660 }661 //sets the message662 ans.setResultMessage(msg);663 return 999999;664 }665 @Override666 public AnswerList readDistinctEnvCountryBrowserByTag(String tag) {667 AnswerList answer = new AnswerList();668 StringBuilder query = new StringBuilder();669 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);670 query.append("SELECT exq.* FROM testcaseexecutionqueue exq WHERE tag = ? GROUP BY Environment, Country, Browser");671 Connection connection = this.databaseSpring.connect();672 List<TestCaseExecutionQueue> EnvCountryBrowserList = new ArrayList<TestCaseExecutionQueue>();673 try {674 PreparedStatement preStat = connection.prepareStatement(query.toString());675 preStat.setString(1, tag);676 try {677 ResultSet resultSet = preStat.executeQuery();678 try {679 while (resultSet.next()) {680 EnvCountryBrowserList.add(this.loadFromResultSet(resultSet));681 }682 msg.setDescription(msg.getDescription().replace("%ITEM%", "TestCaseExecutionInQueue").replace("%OPERATION%", "SELECT"));683 answer = new AnswerList(EnvCountryBrowserList, EnvCountryBrowserList.size());684 } catch (SQLException exception) {685 LOG.warn("Unable to execute query : " + exception.toString());686 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);687 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));688 EnvCountryBrowserList = null;689 } catch (FactoryCreationException ex) {690 LOG.warn("Unable to execute query : " + ex.toString());691 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);692 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));693 EnvCountryBrowserList = null;694 } finally {695 if (resultSet != null) {696 resultSet.close();697 }698 }699 } catch (SQLException ex) {700 LOG.warn("Unable to execute query : " + ex.toString());701 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);702 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));703 EnvCountryBrowserList = null;704 } finally {705 if (preStat != null) {706 preStat.close();707 }708 }709 } catch (SQLException ex) {710 LOG.warn(ex.toString());711 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);712 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));713 } finally {714 try {715 if (connection != null) {716 connection.close();717 }718 } catch (SQLException ex) {719 LOG.warn("Unable to execute query : " + ex.toString());720 }721 }722 answer.setResultMessage(msg);723 return answer;724 }725 @Override726 public AnswerList readDistinctColumnByTag(String tag, boolean env, boolean country, boolean browser, boolean app) {727 AnswerList answer = new AnswerList();728 StringBuilder query = new StringBuilder();729 StringBuilder distinct = new StringBuilder();730 int prev = 0;731 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);732 if (!(!env && !country && !app && !browser)) {733 if (env) {734 distinct.append("exq.Environment");735 prev++;736 }737 if (country) {738 if (prev != 0) {739 prev = 0;740 distinct.append(",");741 }742 distinct.append("exq.Country");743 prev++;744 }745 if (browser) {746 if (prev != 0) {747 prev = 0;748 distinct.append(",");749 }750 distinct.append("exq.Browser");751 prev++;752 }753 if (app) {754 if (prev != 0) {755 prev = 0;756 distinct.append(",");757 }758 distinct.append("tec.Application");759 }760 query.append("SELECT tec.test, tec.testcase, exq.tag, ");761 query.append(distinct.toString());762 query.append(" FROM testcase tec LEFT JOIN testcaseexecutionqueue exq ON exq.Test = tec.Test AND exq.TestCase = tec.TestCase WHERE tag = ? GROUP BY ");763 query.append(distinct.toString());764 } else {765 //If there is no distinct, select nothing766 query.append("SELECT * FROM testcaseexecutionqueue exq WHERE 1=0 AND tag = ?");767 }768 Connection connection = this.databaseSpring.connect();769 List<TestCaseExecutionQueue> column = new ArrayList<TestCaseExecutionQueue>();770 try {771 PreparedStatement preStat = connection.prepareStatement(query.toString());772 preStat.setString(1, tag);773 try {774 ResultSet resultSet = preStat.executeQuery();775 try {776 while (resultSet.next()) {777 TestCaseExecutionQueue tmp = new TestCaseExecutionQueue();778 tmp.setTest(resultSet.getString("tec.test"));779 tmp.setTestCase(resultSet.getString("tec.testcase"));780 tmp.setTag(resultSet.getString("exq.tag"));781 if (env) {782 tmp.setEnvironment(resultSet.getString("Environment"));783 } else {784 tmp.setEnvironment("");785 }786 if (country) {787 tmp.setCountry(resultSet.getString("Country"));788 } else {789 tmp.setCountry("");790 }791 if (browser) {792 tmp.setBrowser(resultSet.getString("Browser"));793 } else {794 tmp.setBrowser("");795 }796 if (app) {797 Application application = factoryApplication.create(resultSet.getString("Application"));798 tmp.setApplicationObj(application);799 }800 column.add(tmp);801 }802 msg.setDescription(msg.getDescription().replace("%ITEM%", "TestCaseExecution").replace("%OPERATION%", "SELECT"));803 answer = new AnswerList(column, column.size());804 } catch (SQLException exception) {805 LOG.warn("Unable to execute query : " + exception.toString());806 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);807 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));808 column = null;809 } finally {810 if (resultSet != null) {811 resultSet.close();812 }813 }814 } catch (SQLException ex) {815 LOG.warn("Unable to execute query : " + ex.toString());816 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);817 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));818 column = null;819 } finally {820 if (preStat != null) {821 preStat.close();822 }823 }824 } catch (SQLException ex) {825 LOG.warn(ex.toString());826 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);827 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));828 } finally {829 try {830 if (connection != null) {831 connection.close();832 }833 } catch (SQLException ex) {834 LOG.warn("Unable to execute query : " + ex.toString());835 }836 }837 answer.setResultMessage(msg);838 return answer;839 }840 @Override841 public AnswerList readDistinctValuesByCriteria(String columnName, String sort, String searchTerm, Map<String, List<String>> individualSearch, String column) {842 AnswerList answer = new AnswerList();843 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);844 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));845 List<String> distinctValues = new ArrayList<>();846 StringBuilder searchSQL = new StringBuilder();847 List<String> individalColumnSearchValues = new ArrayList<String>();848 StringBuilder query = new StringBuilder();849 query.append("SELECT distinct exq.");850 query.append(columnName);851 query.append(" as distinctValues FROM testcaseexecutionqueue exq");852 query.append(" where 1=1");853 if (!StringUtil.isNullOrEmpty(searchTerm)) {854 searchSQL.append(" and (exq.ID like ?");855 searchSQL.append(" or exq.Test like ?");856 searchSQL.append(" or exq.TestCase like ?");857 searchSQL.append(" or exq.Country like ?");858 searchSQL.append(" or exq.Environment like ?");859 searchSQL.append(" or exq.Browser like ?");860 searchSQL.append(" or exq.Tag like ?");861 searchSQL.append(" or exq.State like ?)");862 }863 if (individualSearch != null && !individualSearch.isEmpty()) {864 searchSQL.append(" and ( 1=1 ");865 for (Map.Entry<String, List<String>> entry : individualSearch.entrySet()) {866 searchSQL.append(" and exq.");867 searchSQL.append(SqlUtil.getInSQLClauseForPreparedStatement(entry.getKey(), entry.getValue()));868 individalColumnSearchValues.addAll(entry.getValue());869 }870 searchSQL.append(" )");871 }872 query.append(searchSQL);873 query.append(" group by ifnull(exq.").append(columnName).append(",'')");874 query.append(" order by exq.").append(columnName).append(" asc");875 // Debug message on SQL.876 if (LOG.isDebugEnabled()) {877 LOG.debug("SQL : " + query.toString());878 }879 try (Connection connection = databaseSpring.connect();880 PreparedStatement preStat = connection.prepareStatement(query.toString());881 Statement stm = connection.createStatement();) {882 int i = 1;883 if (!StringUtil.isNullOrEmpty(searchTerm)) {884 preStat.setString(i++, "%" + searchTerm + "%");885 preStat.setString(i++, "%" + searchTerm + "%");886 preStat.setString(i++, "%" + searchTerm + "%");887 preStat.setString(i++, "%" + searchTerm + "%");888 preStat.setString(i++, "%" + searchTerm + "%");889 preStat.setString(i++, "%" + searchTerm + "%");890 preStat.setString(i++, "%" + searchTerm + "%");891 preStat.setString(i++, "%" + searchTerm + "%");892 }893 for (String individualColumnSearchValue : individalColumnSearchValues) {894 preStat.setString(i++, individualColumnSearchValue);895 }896 try(ResultSet resultSet = preStat.executeQuery();897 ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()");){898 //gets the data899 while (resultSet.next()) {900 distinctValues.add(resultSet.getString("distinctValues") == null ? "" : resultSet.getString("distinctValues"));901 }902 //get the total number of rows903 904 int nrTotalRows = 0;905 if (rowSet != null && rowSet.next()) {906 nrTotalRows = rowSet.getInt(1);907 }908 if (distinctValues.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.909 LOG.error("Partial Result in the query.");910 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT);911 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Maximum row reached : " + MAX_ROW_SELECTED));912 answer = new AnswerList(distinctValues, nrTotalRows);913 } else if (distinctValues.size() <= 0) {914 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);915 answer = new AnswerList(distinctValues, nrTotalRows);916 } else {917 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);918 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));919 answer = new AnswerList(distinctValues, nrTotalRows);920 }921 }catch (SQLException e) {922 LOG.warn("Unable to execute query : " + e.toString());923 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION",924 e.toString());925 }926 } catch (Exception e) {927 LOG.warn("Unable to execute query : " + e.toString());928 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION",929 e.toString());930 } finally {931 // We always set the result message932 answer.setResultMessage(msg);933 }934 answer.setResultMessage(msg);935 answer.setDataList(distinctValues);936 return answer;937 }938 @Override939 public AnswerList findTagList(int tagnumber) {940 AnswerList response = new AnswerList();941 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);942 List<String> list = null;943 StringBuilder query = new StringBuilder();944 query.append("SELECT DISTINCT tag FROM testcaseexecutionqueue WHERE tag != ''");945 if (tagnumber != 0) {946 query.append("ORDER BY id desc LIMIT ");947 query.append(tagnumber);948 }949 query.append(";");950 Connection connection = this.databaseSpring.connect();951 try {952 PreparedStatement preStat = connection.prepareStatement(query.toString());953 try {954 ResultSet resultSet = preStat.executeQuery();955 try {956 list = new ArrayList<String>();957 while (resultSet.next()) {958 list.add(resultSet.getString("tag"));959 }960 msg.setDescription(msg.getDescription().replace("%ITEM%", "TagList").replace("%OPERATION%", "SELECT"));961 } catch (SQLException exception) {962 LOG.error("Unable to execute query : " + exception.toString());963 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);964 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));965 } finally {966 resultSet.close();967 }968 } catch (SQLException exception) {969 LOG.error("Unable to execute query : " + exception.toString());970 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);971 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));972 } finally {973 preStat.close();974 }975 } catch (SQLException exception) {976 LOG.error("Unable to execute query : " + exception.toString());977 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);978 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));979 } finally {980 try {981 if (connection != null) {982 connection.close();983 }984 } catch (SQLException e) {985 LOG.warn(e.toString());986 }987 }988 response.setResultMessage(msg);989 response.setDataList(list);990 return response;991 }992 @Override993 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) {994 AnswerList answer = new AnswerList();995 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);996 List<TestCaseExecutionQueue> tceList = new ArrayList<TestCaseExecutionQueue>();997 List<String> whereClauses = new LinkedList<String>();998 StringBuilder query = new StringBuilder();999 int paramNumber = 0;1000 query.append(" select t.ID as statusExecutionID, t.* from ( ");1001 query.append(" select exq.*, tec.*, app.* ");1002 query.append(" from testcaseexecutionqueue exq ");1003 query.append(" inner join testcase tec on exq.test = tec.test and exq.testcase = tec.testcase ");1004 query.append(" inner join application app on tec.application = app.application ");1005 String testClause = SqlUtil.generateInClause("exq.test", testList);1006 if (!StringUtil.isNullOrEmpty(testClause)) {1007 whereClauses.add(testClause);1008 }1009 String applicationClause = SqlUtil.generateInClause("tec.application", applicationList);1010 if (!StringUtil.isNullOrEmpty(applicationClause)) {1011 whereClauses.add(applicationClause);1012 }1013 String projectClause = SqlUtil.generateInClause("tec.project", projectList);1014 if (!StringUtil.isNullOrEmpty(projectClause)) {1015 whereClauses.add(projectClause);1016 }1017 //test case status: working, fully_implemented, ...1018 String tcsClause = SqlUtil.generateInClause("exq.status", tcstatusList);1019 if (!StringUtil.isNullOrEmpty(tcsClause)) {1020 whereClauses.add(tcsClause);1021 }1022 //group 1023 String groupClause = SqlUtil.generateInClause("tec.group", groupList);1024 if (!StringUtil.isNullOrEmpty(groupClause)) {1025 whereClauses.add(groupClause);1026 }1027 //test case active1028 String tcactiveClause = SqlUtil.generateInClause("tec.tcactive", tcactiveList);1029 if (!StringUtil.isNullOrEmpty(tcactiveClause)) {1030 whereClauses.add(tcactiveClause);1031 }1032 //test case active1033 String priorityClause = SqlUtil.generateInClause("tec.Priority", priorityList);1034 if (!StringUtil.isNullOrEmpty(priorityClause)) {1035 whereClauses.add(priorityClause);1036 }1037 //target sprint1038 String targetsprintClause = SqlUtil.generateInClause("tec.TargetBuild", targetsprintList);1039 if (!StringUtil.isNullOrEmpty(targetsprintClause)) {1040 whereClauses.add(targetsprintClause);1041 }1042 //target revision1043 String targetrevisionClause = SqlUtil.generateInClause("tec.TargetRev", targetrevisionList);1044 if (!StringUtil.isNullOrEmpty(targetrevisionClause)) {1045 whereClauses.add(targetrevisionClause);1046 }1047 //creator1048 String creatorClause = SqlUtil.generateInClause("tec.UsrCreated", creatorList);1049 if (!StringUtil.isNullOrEmpty(creatorClause)) {1050 whereClauses.add(creatorClause);1051 }1052 //implementer1053 String implementerClause = SqlUtil.generateInClause("tec.Implementer", implementerList);1054 if (!StringUtil.isNullOrEmpty(implementerClause)) {1055 whereClauses.add(implementerClause);1056 }1057 //build1058 String buildClause = SqlUtil.generateInClause("exq.Build", buildList);1059 if (!StringUtil.isNullOrEmpty(buildClause)) {1060 whereClauses.add(buildClause);1061 }1062 //revision1063 String revisionClause = SqlUtil.generateInClause("exq.Revision", revisionList);1064 if (!StringUtil.isNullOrEmpty(revisionClause)) {1065 whereClauses.add(revisionClause);1066 }1067 //environment1068 String environmentClause = SqlUtil.generateInClause("exq.Environment", environmentList);1069 if (!StringUtil.isNullOrEmpty(environmentClause)) {1070 whereClauses.add(environmentClause);1071 }1072 //country1073 String countryClause = SqlUtil.generateInClause("exq.Country", countryList);1074 if (!StringUtil.isNullOrEmpty(countryClause)) {1075 whereClauses.add(countryClause);1076 }1077 //browser1078 String browserClause = SqlUtil.generateInClause("exq.Browser", browserList);1079 if (!StringUtil.isNullOrEmpty(browserClause)) {1080 whereClauses.add(browserClause);1081 }1082 //test case execution1083 String tcestatusClause = SqlUtil.generateInClause("exq.ControlStatus", tcestatusList);1084 if (!StringUtil.isNullOrEmpty(tcestatusClause)) {1085 whereClauses.add(tcestatusClause);1086 }1087 if (!StringUtil.isNullOrEmpty(system)) {1088 whereClauses.add(" app.system like ? ");1089 }1090 if (!StringUtil.isNullOrEmpty(ip)) {1091 whereClauses.add(" exq.IP like ? ");1092 }1093 if (!StringUtil.isNullOrEmpty(port)) {1094 whereClauses.add(" exq.port like ? ");1095 }1096 if (!StringUtil.isNullOrEmpty(tag)) {1097 whereClauses.add(" exq.tag like ? ");1098 }1099 if (!StringUtil.isNullOrEmpty(browserversion)) {1100 whereClauses.add(" exq.browserfullversion like ? ");1101 }1102 if (!StringUtil.isNullOrEmpty(comment)) {1103 whereClauses.add(" exq.comment like ? ");1104 }1105 if (!StringUtil.isNullOrEmpty(bugid)) {1106 whereClauses.add(" tec.BugID like ? ");1107 }1108 if (!StringUtil.isNullOrEmpty(ticket)) {1109 whereClauses.add(" tec.Ticket like ? ");1110 }1111 if (whereClauses.size() > 0) {1112 query.append("where ");1113 String joined = StringUtils.join(whereClauses, " and ");1114 query.append(joined);1115 }1116 query.append(" order by exq.ID desc ");1117 query.append(" ) as t group by t.test, t.testcase, t.environment, t.browser, t.country");1118 Connection connection = this.databaseSpring.connect();1119 try {1120 PreparedStatement preStat = connection.prepareStatement(query.toString());1121 if (testList != null) {1122 for (String param : testList) {1123 preStat.setString(++paramNumber, param);1124 }1125 }1126 if (applicationList != null) {1127 for (String param : applicationList) {1128 preStat.setString(++paramNumber, param);1129 }1130 }1131 if (projectList != null) {1132 for (String param : projectList) {1133 preStat.setString(++paramNumber, param);1134 }1135 }1136 if (tcstatusList != null) {1137 for (String param : tcstatusList) {1138 preStat.setString(++paramNumber, param);1139 }1140 }1141 if (groupList != null) {1142 for (String param : groupList) {1143 preStat.setString(++paramNumber, param);1144 }1145 }1146 if (tcactiveList != null) {1147 for (String param : tcactiveList) {1148 preStat.setString(++paramNumber, param);1149 }1150 }1151 if (priorityList != null) {1152 for (String param : priorityList) {1153 preStat.setString(++paramNumber, param);1154 }1155 }1156 if (targetsprintList != null) {1157 for (String param : targetsprintList) {1158 preStat.setString(++paramNumber, param);1159 }1160 }1161 if (targetrevisionList != null) {1162 for (String param : targetrevisionList) {1163 preStat.setString(++paramNumber, param);1164 }1165 }1166 if (creatorList != null) {1167 for (String param : creatorList) {1168 preStat.setString(++paramNumber, param);1169 }1170 }1171 if (implementerList != null) {1172 for (String param : implementerList) {1173 preStat.setString(++paramNumber, param);1174 }1175 }1176 if (buildList != null) {1177 for (String param : buildList) {1178 preStat.setString(++paramNumber, param);1179 }1180 }1181 if (revisionList != null) {1182 for (String param : revisionList) {1183 preStat.setString(++paramNumber, param);1184 }1185 }1186 //environment1187 if (environmentList != null) {1188 for (String param : environmentList) {1189 preStat.setString(++paramNumber, param);1190 }1191 }1192 //country1193 if (countryList != null) {1194 for (String param : countryList) {1195 preStat.setString(++paramNumber, param);1196 }1197 }1198 //browser 1199 if (browserList != null) {1200 for (String param : browserList) {1201 preStat.setString(++paramNumber, param);1202 }1203 }1204 //controlstatus1205 if (tcestatusList != null) {1206 for (String param : tcestatusList) {1207 preStat.setString(++paramNumber, param);1208 }1209 }1210 if (!StringUtil.isNullOrEmpty(system)) {1211 preStat.setString(++paramNumber, system);1212 }1213 if (!StringUtil.isNullOrEmpty(ip)) {1214 preStat.setString(++paramNumber, "%" + ip + "%");1215 }1216 if (!StringUtil.isNullOrEmpty(port)) {1217 preStat.setString(++paramNumber, "%" + port + "%");1218 }1219 if (!StringUtil.isNullOrEmpty(tag)) {1220 preStat.setString(++paramNumber, "%" + tag + "%");1221 }1222 if (!StringUtil.isNullOrEmpty(browserversion)) {1223 preStat.setString(++paramNumber, "%" + browserversion + "%");1224 }1225 if (!StringUtil.isNullOrEmpty(comment)) {1226 preStat.setString(++paramNumber, "%" + comment + "%");1227 }1228 if (!StringUtil.isNullOrEmpty(bugid)) {1229 preStat.setString(++paramNumber, "%" + bugid + "%");1230 }1231 if (!StringUtil.isNullOrEmpty(ticket)) {1232 preStat.setString(++paramNumber, "%" + ticket + "%");1233 }1234 try {1235 ResultSet resultSet = preStat.executeQuery();1236 try {1237 while (resultSet.next()) {1238 tceList.add(this.loadWithDependenciesFromResultSet(resultSet));1239 }1240 if (tceList.isEmpty()) {1241 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);1242 } else {1243 msg.setDescription(msg.getDescription().replace("%ITEM%", "TestCaseExecutionInQueue").replace("%OPERATION%", "SELECT"));1244 }1245 } catch (SQLException exception) {1246 LOG.warn("Unable to execute query : " + exception.toString());1247 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1248 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));1249 tceList.clear();1250 } catch (FactoryCreationException ex) {1251 LOG.warn("Unable to execute query : " + ex.toString());1252 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1253 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));1254 tceList.clear();1255 } finally {1256 if (resultSet != null) {1257 resultSet.close();1258 }1259 }1260 } catch (SQLException ex) {1261 LOG.warn("Unable to execute query : " + ex.toString());1262 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1263 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));1264 } finally {1265 if (preStat != null) {1266 preStat.close();1267 }1268 }1269 } catch (SQLException ex) {1270 LOG.warn(ex.toString());1271 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1272 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Unable to retrieve the list of entries!"));1273 } finally {1274 try {1275 if (connection != null) {1276 connection.close();1277 }1278 } catch (SQLException ex) {1279 LOG.warn("Unable to execute query : " + ex.toString());1280 }1281 }1282 answer.setTotalRows(tceList.size());1283 answer.setDataList(tceList);1284 answer.setResultMessage(msg);1285 return answer;1286 }1287 @Override1288 public TestCaseExecutionQueue findByKeyWithDependencies(long id) throws CerberusException {1289 String query = "SELECT * FROM `" + TABLE + "` exq "1290 + "INNER JOIN `" + TABLE_TEST_CASE + "` tec ON (exq.`" + COLUMN_TEST + "` = tec.`Test` AND exq.`" + COLUMN_TEST_CASE + "` = tec.`TestCase`) "1291 + "INNER JOIN `" + TABLE_APPLICATION + "` app ON (tec.`Application` = app.`Application`) "1292 + "WHERE `" + COLUMN_ID + "` = ?";1293 try (Connection connection = this.databaseSpring.connect();1294 PreparedStatement selectStatement = connection.prepareStatement(query);) {1295 selectStatement.setLong(1, id);1296 try(ResultSet result = selectStatement.executeQuery();){1297 if (!result.next()) {1298 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));1299 }1300 return loadWithDependenciesFromResultSet(result);1301 }catch (SQLException exception) {1302 LOG.error("Unable to execute query : " + exception.toString());1303 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1304 } 1305 } catch (SQLException | FactoryCreationException e) {1306 LOG.warn("Unable to find test case execution in queue " + id, e);1307 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1308 }1309 }1310 @Override1311 public AnswerItem<TestCaseExecutionQueue> create(TestCaseExecutionQueue object) {1312 TestCaseExecutionQueue newObject = object;1313 MessageEvent msg = null;1314 StringBuilder query = new StringBuilder();1315 query.append("INSERT INTO `" + TABLE + "` (`" + COLUMN_TEST + "`, `" + COLUMN_TEST_CASE + "`, `" + COLUMN_COUNTRY + "`, `" + COLUMN_ENVIRONMENT + "`, `" + COLUMN_ROBOT1316 + "`, `" + COLUMN_ROBOT_IP + "`, `" + COLUMN_ROBOT_PORT + "`, `" + COLUMN_BROWSER + "`, `" + COLUMN_BROWSER_VERSION + "`, `" + COLUMN_PLATFORM1317 + "`, `" + COLUMN_SCREENSIZE + "`, `" + COLUMN_MANUAL_URL + "`, `" + COLUMN_MANUAL_HOST + "`, `" + COLUMN_MANUAL_CONTEXT_ROOT + "`, `"1318 + COLUMN_MANUAL_LOGIN_RELATIVE_URL + "`, `" + COLUMN_MANUAL_ENV_DATA + "`, `" + COLUMN_TAG + "`, `" + COLUMN_SCREENSHOT + "`, `" + COLUMN_VERBOSE + "`, `"1319 + COLUMN_TIMEOUT + "`, `" + COLUMN_PAGE_SOURCE + "`, `" + COLUMN_SELENIUM_LOG + "`, `" + COLUMN_RETRIES + "`, `"1320 + COLUMN_MANUAL_EXECUTION + "`, `" + COLUMN_USRCREATED + "`, `" + COLUMN_STATE + "`, `" + COLUMN_COMMENT + "`, `" + COLUMN_DEBUGFLAG + "`, `" + COLUMN_PRIORITY + "`) "1321 + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");1322 // Debug message on SQL.1323 if (LOG.isDebugEnabled()) {1324 LOG.debug("SQL : " + query.toString());1325 LOG.debug("SQL.param.prio : " + object.getPriority());1326 LOG.debug("SQL.param.debug : " + object.getDebugFlag());1327 LOG.debug("SQL.param.exeid : " + object.getExeId());1328 LOG.debug("SQL.param.comment : " + object.getComment());1329 LOG.debug("SQL.param.state : " + object.getState());1330 }1331 1332 try(Connection connection = this.databaseSpring.connect();1333 PreparedStatement preStat = connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);) {1334 1335 int i = 1;1336 preStat.setString(i++, object.getTest());1337 preStat.setString(i++, object.getTestCase());1338 preStat.setString(i++, object.getCountry());1339 preStat.setString(i++, object.getEnvironment());1340 preStat.setString(i++, object.getRobot());1341 preStat.setString(i++, object.getRobotIP());1342 preStat.setString(i++, object.getRobotPort());1343 preStat.setString(i++, object.getBrowser());1344 preStat.setString(i++, object.getBrowserVersion());1345 preStat.setString(i++, object.getPlatform());1346 preStat.setString(i++, object.getScreenSize());1347 preStat.setInt(i++, object.getManualURL());1348 preStat.setString(i++, object.getManualHost());1349 preStat.setString(i++, object.getManualContextRoot());1350 preStat.setString(i++, object.getManualLoginRelativeURL());1351 preStat.setString(i++, object.getManualEnvData());1352 preStat.setString(i++, object.getTag());1353 preStat.setInt(i++, object.getScreenshot());1354 preStat.setInt(i++, object.getVerbose());1355 preStat.setString(i++, object.getTimeout());1356 preStat.setInt(i++, object.getPageSource());1357 preStat.setInt(i++, object.getSeleniumLog());1358 preStat.setInt(i++, object.getRetries());1359 preStat.setString(i++, object.getManualExecution());1360 String user = object.getUsrCreated() == null ? "" : object.getUsrCreated();1361 preStat.setString(i++, user);1362 if (object.getState() == null) {1363 preStat.setString(i++, object.getState().WAITING.name());1364 } else {1365 preStat.setString(i++, object.getState().name());1366 }1367 preStat.setString(i++, object.getComment());1368 preStat.setString(i++, object.getDebugFlag());1369 preStat.setInt(i++, object.getPriority());1370 preStat.executeUpdate();1371 try (ResultSet resultSet = preStat.getGeneratedKeys()) {1372 if (resultSet.first()) {1373 newObject.setId(resultSet.getInt(1));1374 }1375 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1376 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "INSERT"));1377 } catch (SQLException exception) {1378 LOG.error("Unable to execute query : " + exception.toString());1379 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1380 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1381 }1382 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1383 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "INSERT"));1384 } catch (SQLException exception) {1385 LOG.error("Unable to execute query : " + exception.toString());1386 if (exception.getSQLState().equals(SQL_DUPLICATED_CODE)) { //23000 is the sql state for duplicate entries1387 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_DUPLICATE);1388 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "INSERT").replace("%REASON%", exception.toString()));1389 } else {1390 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1391 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1392 }1393 } 1394 return new AnswerItem(newObject, msg);1395 }1396 @Override1397 public Answer update(TestCaseExecutionQueue object) {1398 MessageEvent msg = null;1399 String query = "UPDATE testcaseexecutionqueue exq SET `Test` = ?, `TestCase` = ?, `Country` = ?, Environment = ?, Robot = ?, "1400 + "RobotIP = ?, `RobotPort` = ?, Browser = ?, BrowserVersion = ?, `Platform`= ?, `ScreenSize` = ?, "1401 + "ManualURL = ?, `ManualHost` = ?, ManualContextRoot = ?, `ManualLoginRelativeUrl`= ?, `ManualEnvData` = ?, "1402 + "Tag = ?, `Screenshot` = ?, Verbose = ?, `Timeout`= ?, `PageSource` = ?, `debugFlag` = ?, `priority` = ?, "1403 + "SeleniumLog = ?, `Retries`= ?, `ManualExecution` = ?, "1404 + "`UsrModif`= ?, `DateModif` = now() ";1405 query += " WHERE `ID` = ?";1406 // Debug message on SQL.1407 if (LOG.isDebugEnabled()) {1408 LOG.debug("SQL : " + query);1409 LOG.debug("SQL.param.id : " + object.getId());1410 }1411 Connection connection = this.databaseSpring.connect();1412 try {1413 PreparedStatement preStat = connection.prepareStatement(query);1414 try {1415 int i = 1;1416 preStat.setString(i++, object.getTest());1417 preStat.setString(i++, object.getTestCase());1418 preStat.setString(i++, object.getCountry());1419 preStat.setString(i++, object.getEnvironment());1420 preStat.setString(i++, object.getRobot());1421 preStat.setString(i++, object.getRobotIP());1422 preStat.setString(i++, object.getRobotPort());1423 preStat.setString(i++, object.getBrowser());1424 preStat.setString(i++, object.getBrowserVersion());1425 preStat.setString(i++, object.getPlatform());1426 preStat.setString(i++, object.getScreenSize());1427 preStat.setInt(i++, object.getManualURL());1428 preStat.setString(i++, object.getManualHost());1429 preStat.setString(i++, object.getManualContextRoot());1430 preStat.setString(i++, object.getManualLoginRelativeURL());1431 preStat.setString(i++, object.getManualEnvData());1432 preStat.setString(i++, object.getTag());1433 preStat.setInt(i++, object.getScreenshot());1434 preStat.setInt(i++, object.getVerbose());1435 preStat.setString(i++, object.getTimeout());1436 preStat.setInt(i++, object.getPageSource());1437 preStat.setString(i++, object.getDebugFlag());1438 preStat.setInt(i++, object.getPriority());1439 preStat.setInt(i++, object.getSeleniumLog());1440 preStat.setInt(i++, object.getRetries());1441 preStat.setString(i++, object.getManualExecution());1442 preStat.setString(i++, object.getUsrModif());1443 preStat.setLong(i++, object.getId());1444 preStat.executeUpdate();1445 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1446 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));1447 } catch (SQLException exception) {1448 LOG.error("Unable to execute query : " + exception.toString());1449 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1450 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1451 } finally {1452 preStat.close();1453 }1454 } catch (SQLException exception) {1455 LOG.error("Unable to execute query : " + exception.toString());1456 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1457 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1458 } finally {1459 try {1460 if (connection != null) {1461 connection.close();1462 }1463 } catch (SQLException exception) {1464 LOG.warn("Unable to close connection : " + exception.toString());1465 }1466 }1467 return new Answer(msg);1468 }1469 @Override1470 public Answer updateComment(long id, String comment) {1471 MessageEvent msg = null;1472 String query1473 = "UPDATE `" + TABLE + "` "1474 + "SET `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now(), `" + COLUMN_COMMENT + "` = ? "1475 + "WHERE `" + COLUMN_ID + "` = ? ;";1476 // Debug message on SQL.1477 if (LOG.isDebugEnabled()) {1478 LOG.debug("SQL : " + query);1479 LOG.debug("SQL.param.id : " + id);1480 }1481 Connection connection = this.databaseSpring.connect();1482 try {1483 PreparedStatement preStat = connection.prepareStatement(query);1484 try {1485 int i = 1;1486 preStat.setString(i++, comment);1487 preStat.setLong(i++, id);1488 int updateResult = preStat.executeUpdate();1489 if (updateResult <= 0) {1490 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_NOUPDATE);1491 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%DESCRIPTION%", "Unable to update comment for execution in queue " + id + " (update result: " + updateResult + ")."));1492 LOG.warn("Unable to update comment for execution in queue " + id + " (update result: " + updateResult + ").");1493 } else {1494 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1495 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));1496 }1497 } catch (SQLException exception) {1498 LOG.error("Unable to execute query : " + exception.toString());1499 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1500 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1501 } finally {1502 preStat.close();1503 }1504 } catch (SQLException exception) {1505 LOG.error("Unable to execute query : " + exception.toString());1506 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1507 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1508 } finally {1509 try {1510 if (connection != null) {1511 connection.close();1512 }1513 } catch (SQLException exception) {1514 LOG.warn("Unable to close connection : " + exception.toString());1515 }1516 }1517 return new Answer(msg);1518 }1519 @Override1520 public Answer updateToQueued(long id, String comment) {1521 MessageEvent msg = null;1522 String query1523 = "UPDATE `" + TABLE + "` "1524 + "SET `" + COLUMN_STATE + "` = 'QUEUED', `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now(), `" + COLUMN_COMMENT + "` = ? "1525 + "WHERE `" + COLUMN_ID + "` = ? "1526 + "AND `" + COLUMN_STATE + "` IN ('CANCELLED', 'ERROR')";1527 // Debug message on SQL.1528 if (LOG.isDebugEnabled()) {1529 LOG.debug("SQL : " + query);1530 LOG.debug("SQL.param.id : " + id);1531 }1532 Connection connection = this.databaseSpring.connect();1533 try {1534 PreparedStatement preStat = connection.prepareStatement(query);1535 try {1536 int i = 1;1537 preStat.setString(i++, comment);1538 preStat.setLong(i++, id);1539 int updateResult = preStat.executeUpdate();1540 if (updateResult <= 0) {1541 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_NOUPDATE);1542 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%DESCRIPTION%", "Unable to move state to QUEUD for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is no longuer in CANCELLED or ERROR ?"));1543 LOG.warn("Unable to move state to QUEUED for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is no longuer in CANCELLED or ERROR ?");1544 } else {1545 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1546 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));1547 }1548 } catch (SQLException exception) {1549 LOG.error("Unable to execute query : " + exception.toString());1550 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1551 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1552 } finally {1553 preStat.close();1554 }1555 } catch (SQLException exception) {1556 LOG.error("Unable to execute query : " + exception.toString());1557 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1558 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1559 } finally {1560 try {1561 if (connection != null) {1562 connection.close();1563 }1564 } catch (SQLException exception) {1565 LOG.warn("Unable to close connection : " + exception.toString());1566 }1567 }1568 return new Answer(msg);1569 }1570 @Override1571 public boolean updateToWaiting(final Long id) throws CerberusException {1572 String queryUpdate = "UPDATE `" + TABLE + "` "1573 + "SET `" + COLUMN_STATE + "` = 'WAITING', `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now() "1574 + "WHERE `" + COLUMN_ID + "` = ? "1575 + "AND `" + COLUMN_STATE + "` = 'QUEUED'";1576 try (1577 Connection connection = this.databaseSpring.connect();1578 PreparedStatement updateStateStatement = connection.prepareStatement(queryUpdate)) {1579 try {1580 // Debug message on SQL.1581 if (LOG.isDebugEnabled()) {1582 LOG.debug("SQL : " + queryUpdate);1583 LOG.debug("SQL.param.id : " + id);1584 }1585 updateStateStatement.setLong(1, id);1586 int updateResult = updateStateStatement.executeUpdate();1587 if (updateResult <= 0) {1588 LOG.warn("Unable to move state to WAITING for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is not in QUEUED ?");1589 return false;1590 }1591 return true;1592 } catch (SQLException e) {1593 LOG.warn("Unable to move state to WAITING for execution in queue " + id + ". Maybe execution is not in QUEUED ?", e);1594 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1595 }1596 } catch (SQLException e) {1597 LOG.warn("Unable to state from QUEUED to WAITING state for executions in queue", e);1598 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1599 }1600 }1601 @Override1602 public void updateToExecuting(long id, String comment, long exeId) throws CerberusException {1603 String queryUpdate = "UPDATE `" + TABLE + "` "1604 + "SET `" + COLUMN_STATE + "` = 'EXECUTING', `" + COLUMN_EXEID + "` = ?, `" + COLUMN_COMMENT + "` = ?, `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now() "1605 + "WHERE `" + COLUMN_ID + "` = ? "1606 + "AND `" + COLUMN_STATE + "` in ('STARTING')";1607 // Debug message on SQL.1608 if (LOG.isDebugEnabled()) {1609 LOG.debug("SQL : " + queryUpdate);1610 LOG.debug("SQL.param.id : " + id);1611 }1612 try (1613 Connection connection = databaseSpring.connect();1614 PreparedStatement updateStateStatement = connection.prepareStatement(queryUpdate)) {1615 updateStateStatement.setLong(1, exeId);1616 updateStateStatement.setString(2, comment);1617 updateStateStatement.setLong(3, id);1618 int updateResult = updateStateStatement.executeUpdate();1619 if (updateResult <= 0) {1620 LOG.warn("Unable to move state to EXECUTING for execution in queue " + id + " (update result: " + updateResult + "). Is the execution currently STARTING ?");1621 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1622 }1623 } catch (SQLException e) {1624 LOG.warn("Unable to move state from STARTING to EXECUTING for execution in queue " + id, e);1625 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1626 }1627 }1628 @Override1629 public void updateToStarting(long id) throws CerberusException {1630 String queryUpdate = "UPDATE `" + TABLE + "` "1631 + "SET `" + COLUMN_STATE + "` = 'STARTING', `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now() "1632 + "WHERE `" + COLUMN_ID + "` = ? "1633 + "AND `" + COLUMN_STATE + "` = 'WAITING'";1634 // Debug message on SQL.1635 if (LOG.isDebugEnabled()) {1636 LOG.debug("SQL : " + queryUpdate);1637 LOG.debug("SQL.param.id : " + id);1638 }1639 try (1640 Connection connection = databaseSpring.connect();1641 PreparedStatement updateStateStatement = connection.prepareStatement(queryUpdate)) {1642 updateStateStatement.setLong(1, id);1643 int updateResult = updateStateStatement.executeUpdate();1644 if (updateResult <= 0) {1645 LOG.warn("Unable to move state to STARTING for execution in queue " + id + " (update result: " + updateResult + "). Is the execution currently WAITING ?");1646 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1647 }1648 } catch (SQLException e) {1649 LOG.warn("Unable to move state from WAITING to STARTING for execution in queue " + id, e);1650 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1651 }1652 }1653 @Override1654 public void updateToError(long id, String comment) throws CerberusException {1655 String query1656 = "UPDATE `" + TABLE + "` "1657 + "SET `" + COLUMN_STATE + "` = 'ERROR', `" + COLUMN_COMMENT + "` = ?, `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now() "1658 + "WHERE `" + COLUMN_ID + "` = ? "1659 + "AND `" + COLUMN_STATE + "` = 'STARTING'";1660 // Debug message on SQL.1661 if (LOG.isDebugEnabled()) {1662 LOG.debug("SQL : " + query);1663 LOG.debug("SQL.param.id : " + id);1664 }1665 try (Connection connection = databaseSpring.connect();1666 PreparedStatement updateStateAndCommentStatement = connection.prepareStatement(query)) {1667 updateStateAndCommentStatement.setString(1, comment);1668 updateStateAndCommentStatement.setLong(2, id);1669 int updateResult = updateStateAndCommentStatement.executeUpdate();1670 if (updateResult <= 0) {1671 LOG.warn("Unable to move state to ERROR for execution in queue " + id + " (update result: " + updateResult + ")");1672 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1673 }1674 } catch (SQLException e) {1675 LOG.warn("Unable to set move to ERROR for execution in queue id " + id, e);1676 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1677 }1678 }1679 @Override1680 public void updateToDone(long id, String comment, long exeId) throws CerberusException {1681 String query1682 = "UPDATE `" + TABLE + "` "1683 + "SET `" + COLUMN_STATE + "` = 'DONE', `" + COLUMN_EXEID + "` = ?, `" + COLUMN_COMMENT + "` = ?, `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now() "1684 + "WHERE `" + COLUMN_ID + "` = ? ";1685 // Debug message on SQL.1686 if (LOG.isDebugEnabled()) {1687 LOG.debug("SQL : " + query);1688 LOG.debug("SQL.param.id : " + id);1689 }1690 try (1691 Connection connection = databaseSpring.connect();1692 PreparedStatement updateStateAndCommentStatement = connection.prepareStatement(query)) {1693// fillUpdateStateAndCommentAndIdStatement(id, TestCaseExecutionQueue.State.DONE, comment, exeId, updateStateAndCommentStatement);1694 updateStateAndCommentStatement.setLong(1, exeId);1695 updateStateAndCommentStatement.setString(2, comment);1696 updateStateAndCommentStatement.setLong(3, id);1697 int updateResult = updateStateAndCommentStatement.executeUpdate();1698 if (updateResult <= 0) {1699 LOG.warn("Unable to move state to DONE for execution in queue " + id + " (update result: " + updateResult + ")");1700 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1701 }1702 } catch (SQLException e) {1703 LOG.warn("Unable to set move to DONE for execution in queue id " + id, e);1704 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1705 }1706 }1707 @Override1708 public Answer updateToCancelled(long id, String comment) {1709 MessageEvent msg = null;1710 String query1711 = "UPDATE `" + TABLE + "` "1712 + "SET `" + COLUMN_STATE + "` = 'CANCELLED', `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now(), `" + COLUMN_COMMENT + "` = ? "1713 + "WHERE `" + COLUMN_ID + "` = ? "1714 + "AND `" + COLUMN_STATE + "` IN ('ERROR','QUEUED')";1715 // Debug message on SQL.1716 if (LOG.isDebugEnabled()) {1717 LOG.debug("SQL : " + query);1718 LOG.debug("SQL.param.id : " + id);1719 }1720 Connection connection = this.databaseSpring.connect();1721 try {1722 PreparedStatement preStat = connection.prepareStatement(query);1723 try {1724 int i = 1;1725 preStat.setString(i++, comment);1726 preStat.setLong(i++, id);1727 int updateResult = preStat.executeUpdate();1728 if (updateResult <= 0) {1729 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_NOUPDATE);1730 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%DESCRIPTION%", "Unable to move state to CANCELLED for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is no longuer in ERROR or QUEUED ?"));1731 LOG.warn("Unable to move state to CANCELLED for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is no longuer in ERROR or QUEUED ?");1732// throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1733 } else {1734 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1735 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));1736 }1737 } catch (SQLException exception) {1738 LOG.error("Unable to execute query : " + exception.toString());1739 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1740 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1741 } finally {1742 preStat.close();1743 }1744 } catch (SQLException exception) {1745 LOG.error("Unable to execute query : " + exception.toString());1746 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1747 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1748 } finally {1749 try {1750 if (connection != null) {1751 connection.close();1752 }1753 } catch (SQLException exception) {1754 LOG.warn("Unable to close connection : " + exception.toString());1755 }1756 }1757 return new Answer(msg);1758 }1759 @Override1760 public Answer updateToCancelledForce(long id, String comment) {1761 MessageEvent msg = null;1762 String query1763 = "UPDATE `" + TABLE + "` "1764 + "SET `" + COLUMN_STATE + "` = 'CANCELLED', `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now(), `" + COLUMN_COMMENT + "` = ? "1765 + "WHERE `" + COLUMN_ID + "` = ? "1766 + "AND `" + COLUMN_STATE + "` IN ('WAITING','STARTING','EXECUTING')";1767 // Debug message on SQL.1768 if (LOG.isDebugEnabled()) {1769 LOG.debug("SQL : " + query);1770 }1771 Connection connection = this.databaseSpring.connect();1772 try {1773 PreparedStatement preStat = connection.prepareStatement(query);1774 try {1775 int i = 1;1776 preStat.setString(i++, comment);1777 preStat.setLong(i++, id);1778 int updateResult = preStat.executeUpdate();1779 if (updateResult <= 0) {1780 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_NOUPDATE);1781 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%DESCRIPTION%", "Unable to move state to CANCELLED (forced) for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is no longuer in WAITING or STARTING or EXECUTING ?"));1782 LOG.warn("Unable to move state to CANCELLED (forced) for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is no longuer in WAITING or STARTING or EXECUTING ?");1783// throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1784 } else {1785 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1786 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));1787 }1788 } catch (SQLException exception) {1789 LOG.error("Unable to execute query : " + exception.toString());1790 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1791 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1792 } finally {1793 preStat.close();1794 }1795 } catch (SQLException exception) {1796 LOG.error("Unable to execute query : " + exception.toString());1797 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1798 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1799 } finally {1800 try {1801 if (connection != null) {1802 connection.close();1803 }1804 } catch (SQLException exception) {1805 LOG.warn("Unable to close connection : " + exception.toString());1806 }1807 }1808 return new Answer(msg);1809 }1810 @Override1811 public Answer updateToErrorForce(long id, String comment) {1812 MessageEvent msg = null;1813 String query1814 = "UPDATE `" + TABLE + "` "1815 + "SET `" + COLUMN_STATE + "` = 'ERROR', `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now(), `" + COLUMN_COMMENT + "` = ? "1816 + "WHERE `" + COLUMN_ID + "` = ? "1817 + "AND `" + COLUMN_STATE + "` IN ('QUEUED')";1818 // Debug message on SQL.1819 if (LOG.isDebugEnabled()) {1820 LOG.debug("SQL : " + query);1821 }1822 Connection connection = this.databaseSpring.connect();1823 try {1824 PreparedStatement preStat = connection.prepareStatement(query);1825 try {1826 int i = 1;1827 preStat.setString(i++, comment);1828 preStat.setLong(i++, id);1829 int updateResult = preStat.executeUpdate();1830 if (updateResult <= 0) {1831 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_NOUPDATE);1832 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%DESCRIPTION%", "Unable to move state to ERROR (forced) for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is no longuer in QUEUED state ?"));1833 LOG.warn("Unable to move state to ERROR (forced) for execution in queue " + id + " (update result: " + updateResult + "). Maybe execution is no longuer in QUEUED state ?");1834// throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));1835 } else {1836 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1837 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));1838 }1839 } catch (SQLException exception) {1840 LOG.error("Unable to execute query : " + exception.toString());1841 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1842 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1843 } finally {1844 preStat.close();1845 }1846 } catch (SQLException exception) {1847 LOG.error("Unable to execute query : " + exception.toString());1848 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1849 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1850 } finally {1851 try {1852 if (connection != null) {1853 connection.close();1854 }1855 } catch (SQLException exception) {1856 LOG.warn("Unable to close connection : " + exception.toString());1857 }1858 }1859 return new Answer(msg);1860 }1861 @Override1862 public Answer delete(TestCaseExecutionQueue object) {1863 MessageEvent msg = null;1864 final String query = "DELETE FROM testcaseexecutionqueue WHERE `ID` = ? ";1865 // Debug message on SQL.1866 if (LOG.isDebugEnabled()) {1867 LOG.debug("SQL : " + query);1868 }1869 Connection connection = this.databaseSpring.connect();1870 try {1871 PreparedStatement preStat = connection.prepareStatement(query);1872 try {1873 preStat.setLong(1, object.getId());1874 preStat.executeUpdate();1875 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1876 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));1877 } catch (SQLException exception) {1878 LOG.error("Unable to execute query : " + exception.toString());1879 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1880 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1881 } finally {1882 preStat.close();1883 }1884 } catch (SQLException exception) {1885 LOG.error("Unable to execute query : " + exception.toString());1886 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1887 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1888 } finally {1889 try {1890 if (connection != null) {1891 connection.close();1892 }1893 } catch (SQLException exception) {1894 LOG.warn("Unable to close connection : " + exception.toString());1895 }1896 }1897 return new Answer(msg);1898 }1899 @Override1900 public Answer delete(Long id) {1901 MessageEvent msg = null;1902 final String query = "DELETE FROM testcaseexecutionqueue WHERE `ID` = ? ";1903 // Debug message on SQL.1904 if (LOG.isDebugEnabled()) {1905 LOG.debug("SQL : " + query);1906 }1907 Connection connection = this.databaseSpring.connect();1908 try {1909 PreparedStatement preStat = connection.prepareStatement(query);1910 try {1911 preStat.setLong(1, id);1912 preStat.executeUpdate();1913 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);1914 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));1915 } catch (SQLException exception) {1916 LOG.error("Unable to execute query : " + exception.toString());1917 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1918 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1919 } finally {1920 preStat.close();1921 }1922 } catch (SQLException exception) {1923 LOG.error("Unable to execute query : " + exception.toString());1924 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);1925 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));1926 } finally {1927 try {1928 if (connection != null) {1929 connection.close();1930 }1931 } catch (SQLException exception) {1932 LOG.warn("Unable to close connection : " + exception.toString());1933 }1934 }1935 return new Answer(msg);1936 }1937 @Override1938 public TestCaseExecutionQueue loadFromResultSet(ResultSet resultSet) throws FactoryCreationException, SQLException {1939 return factoryTestCaseExecutionInQueue.create(1940 resultSet.getLong(COLUMN_ID),1941 resultSet.getString(COLUMN_TEST),1942 resultSet.getString(COLUMN_TEST_CASE),1943 resultSet.getString(COLUMN_COUNTRY),1944 resultSet.getString(COLUMN_ENVIRONMENT),1945 resultSet.getString(COLUMN_ROBOT),1946 resultSet.getString(COLUMN_ROBOT_IP),1947 resultSet.getString(COLUMN_ROBOT_PORT),1948 resultSet.getString(COLUMN_BROWSER),1949 resultSet.getString(COLUMN_BROWSER_VERSION),1950 resultSet.getString(COLUMN_PLATFORM),1951 resultSet.getString(COLUMN_SCREENSIZE),1952 resultSet.getInt(COLUMN_MANUAL_URL),1953 resultSet.getString(COLUMN_MANUAL_HOST),1954 resultSet.getString(COLUMN_MANUAL_CONTEXT_ROOT),1955 resultSet.getString(COLUMN_MANUAL_LOGIN_RELATIVE_URL),1956 resultSet.getString(COLUMN_MANUAL_ENV_DATA),1957 resultSet.getString(COLUMN_TAG),1958 resultSet.getInt(COLUMN_SCREENSHOT),1959 resultSet.getInt(COLUMN_VERBOSE),1960 resultSet.getString(COLUMN_TIMEOUT),1961 resultSet.getInt(COLUMN_PAGE_SOURCE),1962 resultSet.getInt(COLUMN_SELENIUM_LOG),1963 new Date(resultSet.getTimestamp(COLUMN_REQUEST_DATE).getTime()),1964 TestCaseExecutionQueue.State.valueOf(resultSet.getString(COLUMN_STATE)),1965 resultSet.getInt(COLUMN_PRIORITY),1966 resultSet.getString(COLUMN_COMMENT),1967 resultSet.getString(COLUMN_DEBUGFLAG),1968 resultSet.getInt(COLUMN_RETRIES),1969 resultSet.getString(COLUMN_MANUAL_EXECUTION),1970 resultSet.getLong(COLUMN_EXEID),1971 resultSet.getString(COLUMN_USRCREATED),1972 resultSet.getTimestamp(COLUMN_DATECREATED),1973 resultSet.getString(COLUMN_USRMODIF),1974 resultSet.getTimestamp(COLUMN_DATEMODIF)1975 );1976 }1977 private TestCaseExecutionQueueToTreat loadQueueToTreatFromResultSet(ResultSet resultSet) throws SQLException {1978 TestCaseExecutionQueueToTreat inQueue = new TestCaseExecutionQueueToTreat();1979 try {1980 inQueue.setId(resultSet.getInt("exq.id"));1981 inQueue.setManualExecution(resultSet.getString("exq.manualexecution"));1982 inQueue.setSystem(resultSet.getString("app.system"));1983 inQueue.setEnvironment(resultSet.getString("cea.environment"));1984 inQueue.setCountry(resultSet.getString("cea.country"));1985 inQueue.setApplication(resultSet.getString("cea.application"));1986 inQueue.setPoolSizeApplication(resultSet.getInt("cea.poolsize"));1987 inQueue.setDebugFlag(resultSet.getString("exq.DebugFlag"));1988 /**1989 * Robot host is feed only if application type really required a1990 * robot. data comes from robot by priority or exe when exist.1991 */1992 String robotHost = "";1993 String appType = resultSet.getString("app.type");1994 if (appType == null) {1995 appType = "";1996 }1997 // If application type require a selenium/appium/sikuli server, we get the robot host from robot and not execution queue.1998 if ((appType.equals(Application.TYPE_APK)) || (appType.equals(Application.TYPE_GUI)) || (appType.equals(Application.TYPE_FAT)) || (appType.equals(Application.TYPE_IPA))) {1999 robotHost = resultSet.getString("rbt.host");2000 if (StringUtil.isNullOrEmpty(robotHost)) {2001 robotHost = resultSet.getString("exq.robotIP");2002 }2003 }2004 inQueue.setRobotHost(robotHost);2005 } catch (Exception e) {2006 LOG.debug("Exception in load queue from resultset : " + e.toString());2007 }2008 return inQueue;2009 }2010 /**2011 * Uses data of ResultSet to create object {@link TestCaseExecutionQueue}2012 *2013 * @param resultSet ResultSet relative to select from table2014 * TestCaseExecutionInQueue2015 * @return object {@link TestCaseExecutionQueue} with objects2016 * {@link ResultSet} and {@link Application}2017 * @throws SQLException when trying to get value from2018 * {@link java.sql.ResultSet#getString(String)}2019 * @see TestCaseExecutionQueue2020 */2021 private TestCaseExecutionQueue loadWithDependenciesFromResultSet(ResultSet resultSet) throws SQLException, FactoryCreationException {2022 TestCaseExecutionQueue testCaseExecutionInQueue = this.loadFromResultSet(resultSet);2023 testCaseExecutionInQueue.setTestCaseObj(testCaseDAO.loadFromResultSet(resultSet));2024 testCaseExecutionInQueue.setApplicationObj(applicationDAO.loadFromResultSet(resultSet));2025 return testCaseExecutionInQueue;2026 }2027}...

Full Screen

Full Screen

loadFromResultSet

Using AI Code Generation

copy

Full Screen

1 InputStream is = url.openStream();2 BufferedReader br = new BufferedReader(new InputStreamReader(is));3 String line = null;4 while ((line = br.readLine()) != null) {5 System.out.println(line);6 }7 String in = br.readLine();8 System.out.println(in);9 br.close();10public String getOutput() throws IOException {11 String output = null;12 Process p = Runtime.getRuntime().exec("cmd /c dir");13 BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));14 BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));

Full Screen

Full Screen

loadFromResultSet

Using AI Code Generation

copy

Full Screen

1public List<TestCaseExecutionQueue> loadFromResultSet(ResultSet rs) throws SQLException {2 List<TestCaseExecutionQueue> list = new ArrayList<>();3 boolean hasResultSet = rs.first();4 while (hasResultSet) {5 TestCaseExecutionQueue testCaseExecutionQueue = new TestCaseExecutionQueue();6 testCaseExecutionQueue.setId(rs.getLong("id"));7 testCaseExecutionQueue.setTest(rs.getString("test"));8 testCaseExecutionQueue.setTestCase(rs.getString("testCase"));9 testCaseExecutionQueue.setCountry(rs.getString("country"));10 testCaseExecutionQueue.setEnvironment(rs.getString("environment"));11 testCaseExecutionQueue.setBrowser(rs.getString("browser"));12 testCaseExecutionQueue.setBrowserVersion(rs.getString("browserVersion"));13 testCaseExecutionQueue.setPlatform(rs.getString("platform"));14 testCaseExecutionQueue.setVersion(rs.getString("version"));15 testCaseExecutionQueue.setRevision(rs.getString("revision"));16 testCaseExecutionQueue.setRobot(rs.getString("robot"));17 testCaseExecutionQueue.setRobotDecli(rs.getString("robotDecli"));18 testCaseExecutionQueue.setRobotHost(rs.getString("robotHost"));19 testCaseExecutionQueue.setRobotPort(rs.getString("robotPort"));20 testCaseExecutionQueue.setRobotPlatform(rs.getString("robotPlatform"));21 testCaseExecutionQueue.setRobotBrowser(rs.getString("robotBrowser"));22 testCaseExecutionQueue.setManualURL(rs.getString("manualURL"));23 testCaseExecutionQueue.setManualHost(rs.getString("manualHost"));24 testCaseExecutionQueue.setManualContextRoot(rs.getString("manualContextRoot"));25 testCaseExecutionQueue.setManualLoginRelativeURL(rs.getString("manualLoginRelativeURL"));26 testCaseExecutionQueue.setManualEnvData(rs.getString("manualEnvData"));27 testCaseExecutionQueue.setManualExecution(rs.getString("manualExecution"));28 testCaseExecutionQueue.setPriority(rs.getInt("priority"));29 testCaseExecutionQueue.setUsrCreated(rs.getString("usrCreated"));30 testCaseExecutionQueue.setUsrModif(rs.getString("usrModif"));31 testCaseExecutionQueue.setDateCreated(rs.getTimestamp("dateCreated"));32 testCaseExecutionQueue.setDateModif(rs.getTimestamp("dateModif"));33 list.add(testCaseExecutionQueue);34 hasResultSet = rs.next();35 }36 return list;37}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful