How to use updateTestCase method of org.cerberus.crud.dao.impl.TestCaseDAO class

Best Cerberus-source code snippet using org.cerberus.crud.dao.impl.TestCaseDAO.updateTestCase

Source:TestCaseDAO.java Github

copy

Full Screen

...515 ansList.setDataList(listOfTests);516 return ansList;517 }518 @Override519 public boolean updateTestCaseInformation(TestCase testCase) {520 boolean res = false;521 final String sql = "UPDATE testcase tc SET tc.Application = ?, tc.BehaviorOrValueExpected = ?, tc.activeQA = ?, tc.activeUAT = ?, tc.activePROD = ?, "522 + "tc.Priority = ?, tc.Status = ?, tc.TcActive = ?, tc.Description = ?, tc.Group = ?, tc.HowTo = ?, tc.Comment = ?, tc.FromBuild = ?, "523 + "tc.FromRev = ?, tc.ToBuild = ?, tc.ToRev = ?, tc.BugID = ?, tc.TargetBuild = ?, tc.Implementer = ?, tc.Executor = ?, tc.LastModifier = ?, tc.TargetRev = ?, tc.`function` = ?, "524 + "tc.conditionOper = ?, tc.conditionVal1 = ?, tc.conditionVal2 = ? , tc.conditionVal3 = ? "525 + "WHERE tc.Test = ? AND tc.Testcase = ?";526 // Debug message on SQL.527 if (LOG.isDebugEnabled()) {528 LOG.debug("SQL : " + sql);529 }530 Connection connection = this.databaseSpring.connect();531 try {532 PreparedStatement preStat = connection.prepareStatement(sql);533 try {534 int i = 1;535 preStat.setString(i++, testCase.getApplication());536 preStat.setString(i++, testCase.getBehaviorOrValueExpected());537 preStat.setString(i++, testCase.getActiveQA());538 preStat.setString(i++, testCase.getActiveUAT());539 preStat.setString(i++, testCase.getActivePROD());540 preStat.setString(i++, Integer.toString(testCase.getPriority()));541 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getStatus(), ""));542 preStat.setString(i++, testCase.getTcActive());543 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getDescription(), ""));544 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getGroup(), ""));545 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getHowTo(), ""));546 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getComment(), ""));547 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getFromBuild(), ""));548 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getFromRev(), ""));549 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getToBuild(), ""));550 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getToRev(), ""));551 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getBugID().toString(), ""));552 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getTargetBuild(), ""));553 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getImplementer(), ""));554 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getExecutor(), ""));555 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getUsrModif(), ""));556 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getTargetRev(), ""));557 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getFunction(), ""));558 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getConditionOper(), ""));559 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getConditionVal1(), ""));560 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getConditionVal2(), ""));561 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getConditionVal3(), ""));562 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getTest(), ""));563 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getTestCase(), ""));564 res = preStat.executeUpdate() > 0;565 } catch (SQLException exception) {566 LOG.error("Unable to execute query : " + exception.toString());567 } finally {568 preStat.close();569 }570 } catch (SQLException exception) {571 LOG.error("Unable to execute query : " + exception.toString());572 } finally {573 try {574 if (connection != null) {575 connection.close();576 }577 } catch (SQLException e) {578 LOG.warn(e.toString());579 }580 }581 return res;582 }583 @Override584 public boolean updateTestCaseInformationCountries(TestCase tc) {585 boolean res = false;586 final String sql_count = "SELECT Country FROM testcasecountry WHERE Test = ? AND TestCase = ?";587 ArrayList<String> countriesDB = new ArrayList<String>();588 List<String> countryList = new ArrayList<String>();589 for (TestCaseCountry tcCountry : tc.getTestCaseCountry()) {590 countryList.add(tcCountry.getCountry());591 }592 // Debug message on SQL.593 if (LOG.isDebugEnabled()) {594 LOG.debug("SQL : " + sql_count);595 }596 Connection connection = this.databaseSpring.connect();597 try {598 PreparedStatement preStat = connection.prepareStatement(sql_count);599 try {600 preStat.setString(1, tc.getTest());601 preStat.setString(2, tc.getTestCase());602 ResultSet rsCount = preStat.executeQuery();603 try {604 while (rsCount.next()) {605 countriesDB.add(rsCount.getString("Country"));606 if (!countryList.contains(rsCount.getString("Country"))) {607 final String sql_delete = "DELETE FROM testcasecountry WHERE Test = ? AND TestCase = ? AND Country = ?";608 PreparedStatement preStat2 = connection.prepareStatement(sql_delete);609 try {610 preStat2.setString(1, tc.getTest());611 preStat2.setString(2, tc.getTestCase());612 preStat2.setString(3, rsCount.getString("Country"));613 preStat2.executeUpdate();614 } catch (SQLException exception) {615 LOG.error("Unable to execute query : " + exception.toString());616 } finally {617 preStat2.close();618 }619 }620 }621 } catch (SQLException exception) {622 LOG.error("Unable to execute query : " + exception.toString());623 } finally {624 rsCount.close();625 }626 } catch (SQLException exception) {627 LOG.error("Unable to execute query : " + exception.toString());628 } finally {629 preStat.close();630 }631 res = true;632 for (int i = 0; i < countryList.size() && res; i++) {633 if (!countriesDB.contains(countryList.get(i))) {634 final String sql_insert = "INSERT INTO testcasecountry (test, testcase, country) VALUES (?, ?, ?)";635 PreparedStatement preStat2 = connection.prepareStatement(sql_insert);636 try {637 preStat2.setString(1, tc.getTest());638 preStat2.setString(2, tc.getTestCase());639 preStat2.setString(3, countryList.get(i));640 res = preStat2.executeUpdate() > 0;641 } catch (SQLException exception) {642 LOG.error("Unable to execute query : " + exception.toString());643 } finally {644 preStat2.close();645 }646 }647 }648 } catch (SQLException exception) {649 LOG.error("Unable to execute query : " + exception.toString());650 } finally {651 try {652 if (connection != null) {653 connection.close();654 }655 } catch (SQLException e) {656 LOG.warn(e.toString());657 }658 }659 return res;660 }661 @Override662 public boolean createTestCase(TestCase testCase) {663 boolean res = false;664 final StringBuffer sql = new StringBuffer("INSERT INTO `testcase` ")665 .append(" ( `Test`, `TestCase`, `Application`, ")666 .append("`Description`, `BehaviorOrValueExpected`, ")667 .append("`Priority`, `Status`, `TcActive`, ")668 .append("`Group`, `Origine`, `RefOrigine`, `HowTo`, `Comment`, ")669 .append("`FromBuild`, `FromRev`, `ToBuild`, `ToRev`, ")670 .append("`BugID`, `TargetBuild`, `TargetRev`, `UsrCreated`, ")671 .append("`Implementer`, `Executor`, `UsrModif`, `function`, `activeQA`, `activeUAT`, `activePROD`, `useragent`, `screensize`, ")672 .append("`conditionOper`, `conditionVal1`, `conditionVal2`, `conditionVal3`) ")673 .append("VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ")674 .append("?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ); ");675 // Debug message on SQL.676 if (LOG.isDebugEnabled()) {677 LOG.debug("SQL : " + sql);678 }679 Connection connection = this.databaseSpring.connect();680 try {681 PreparedStatement preStat = connection.prepareStatement(sql.toString());682 try {683 int i = 1;684 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getTest(), ""));685 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getTestCase(), ""));686 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getApplication(), ""));687 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getDescription(), ""));688 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getBehaviorOrValueExpected(), ""));689 preStat.setString(i++, Integer.toString(testCase.getPriority()));690 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getStatus(), ""));691 preStat.setString(i++, testCase.getTcActive() != null && !testCase.getTcActive().equals("Y") ? "N" : "Y");692 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getGroup(), ""));693 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getOrigine(), ""));694 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getRefOrigine(), ""));695 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getHowTo(), ""));696 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getComment(), ""));697 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getFromBuild(), ""));698 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getFromRev(), ""));699 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getToBuild(), ""));700 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getToRev(), ""));701 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getBugID().toString(), ""));702 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getTargetBuild(), ""));703 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getTargetRev(), ""));704 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getUsrCreated(), ""));705 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getImplementer(), ""));706 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getExecutor(), ""));707 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getUsrModif(), ""));708 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getFunction(), ""));709 preStat.setString(i++, testCase.getActiveQA() != null && !testCase.getActiveQA().equals("Y") ? "N" : "Y");710 preStat.setString(i++, testCase.getActiveUAT() != null && !testCase.getActiveUAT().equals("Y") ? "N" : "Y");711 preStat.setString(i++, testCase.getActivePROD() != null && !testCase.getActivePROD().equals("N") ? "Y" : "N");712 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getUserAgent(), ""));713 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getScreenSize(), ""));714 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getConditionOper(), ""));715 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getConditionVal1(), ""));716 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getConditionVal2(), ""));717 preStat.setString(i++, ParameterParserUtil.parseStringParam(testCase.getConditionVal3(), ""));718 res = preStat.executeUpdate() > 0;719 } catch (SQLException exception) {720 LOG.error("Unable to execute query : " + exception.toString());721 } finally {722 preStat.close();723 }724 } catch (SQLException exception) {725 LOG.error("Unable to execute query : " + exception.toString());726 } finally {727 try {728 if (connection != null) {729 connection.close();730 }731 } catch (SQLException e) {732 LOG.warn(e.toString());733 }734 }735 return res;736 //throw new UnsupportedOperationException("Not supported yet.");737 }738 @Override739 public List<TestCase> findTestCaseByApplication(final String application) {740 List<TestCase> testCases = null;741 try (final Connection connection = databaseSpring.connect();742 final PreparedStatement statement = connection.prepareStatement(Query.FIND_BY_APPLICATION)) {743 statement.setString(1, application);744 testCases = new ArrayList<>();745 try (ResultSet resultSet = statement.executeQuery();) {746 while (resultSet.next()) {747 testCases.add(loadFromResultSet(resultSet));748 }749 }750 } catch (SQLException e) {751 LOG.warn("Unable to get test cases for application " + application, e);752 }753 return testCases;754 }755 @Override756 public List<TestCase> findTestCaseByCriteria(String test, String application, String country, String active) {757 List<TestCase> list = null;758 final String query = "SELECT tec.* FROM testcase tec "759 + "JOIN testcasecountry tcc "760 + "LEFT OUTER JOIN application app on app.application = tec.application "761 + "WHERE tec.test=tcc.test AND tec.testcase=tcc.testcase "762 + "AND tec.test = ? AND tec.application = ? AND tcc.country = ? AND tec.tcactive = ? ";763 // Debug message on SQL.764 if (LOG.isDebugEnabled()) {765 LOG.debug("SQL : " + query);766 }767 Connection connection = this.databaseSpring.connect();768 try {769 PreparedStatement preStat = connection.prepareStatement(query);770 try {771 preStat.setString(1, test);772 preStat.setString(2, application);773 preStat.setString(3, country);774 preStat.setString(4, active);775 ResultSet resultSet = preStat.executeQuery();776 list = new ArrayList<>();777 try {778 while (resultSet.next()) {779 list.add(this.loadFromResultSet(resultSet));780 }781 } catch (SQLException exception) {782 LOG.error("Unable to execute query : " + exception.toString());783 } finally {784 resultSet.close();785 }786 } catch (SQLException exception) {787 LOG.error("Unable to execute query : " + exception.toString());788 } finally {789 preStat.close();790 }791 } catch (SQLException exception) {792 LOG.error("Unable to execute query : " + exception.toString());793 } finally {794 try {795 if (connection != null) {796 connection.close();797 }798 } catch (SQLException e) {799 LOG.warn(e.toString());800 }801 }802 return list;803 }804 @Override805 public List<TestCase> findTestCaseByCriteria(TestCase testCase, String text, String system) {806 List<TestCase> list = null;807 String query = new StringBuilder()808 .append("SELECT tec.* FROM testcase tec ")809 .append("LEFT OUTER JOIN application app ON app.application=tec.application ")810 .append(" WHERE (tec.test LIKE ")811 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.test", testCase.getTest()))812 .append(") AND (tec.bugid LIKE ")813 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.bugid", testCase.getBugID().toString()))814 .append(") AND (tec.origine LIKE ")815 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.origine", testCase.getOrigine()))816 .append(") AND (app.system LIKE ")817 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("app.system", system))818 .append(") AND (tec.application LIKE ")819 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.application", testCase.getApplication()))820 .append(") AND (tec.priority LIKE ")821 .append(ParameterParserUtil.wildcardOrIsNullIfMinusOne("tec.priority", testCase.getPriority()))822 .append(") AND (tec.status LIKE ")823 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.status", testCase.getStatus()))824 .append(") AND (tec.group LIKE ")825 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.group", testCase.getGroup()))826 .append(") AND (tec.activePROD LIKE ")827 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.activePROD", testCase.getActivePROD()))828 .append(") AND (tec.activeUAT LIKE ")829 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.activeUAT", testCase.getActiveUAT()))830 .append(") AND (tec.activeQA LIKE ")831 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.activeQA", testCase.getActiveQA()))832 .append(") AND (tec.description LIKE ")833 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.description", text))834 .append(" OR tec.howto LIKE ")835 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.howto", text))836 .append(" OR tec.behaviororvalueexpected LIKE ")837 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.behaviororvalueexpected", text))838 .append(" OR tec.comment LIKE ")839 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.comment", text))840 .append(") AND (tec.TcActive LIKE ")841 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.TcActive", testCase.getTcActive()))842 .append(") AND (tec.frombuild LIKE ")843 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.frombuild", testCase.getFromBuild()))844 .append(") AND (tec.fromrev LIKE ")845 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.fromrev", testCase.getFromRev()))846 .append(") AND (tec.tobuild LIKE ")847 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.tobuild", testCase.getToBuild()))848 .append(") AND (tec.torev LIKE ")849 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.torev", testCase.getToRev()))850 .append(") AND (tec.targetbuild LIKE ")851 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.targetbuild", testCase.getTargetBuild()))852 .append(") AND (tec.targetrev LIKE ")853 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.targetrev", testCase.getTargetRev()))854 .append(") AND (tec.testcase LIKE ")855 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.testcase", testCase.getTestCase()))856 .append(") AND (tec.function LIKE ")857 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.function", testCase.getFunction()))858 .append(") AND (tec.Executor LIKE ")859 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.Executor", testCase.getExecutor()))860 .append(") AND (tec.Implementer LIKE ")861 .append(ParameterParserUtil.wildcardOrIsNullIfEmpty("tec.Implementer", testCase.getImplementer()))862 .append(")").toString();863 // Debug message on SQL.864 if (LOG.isDebugEnabled()) {865 LOG.debug("SQL : " + query.toString());866 }867 Connection connection = this.databaseSpring.connect();868 try {869 PreparedStatement preStat = connection.prepareStatement(query);870 try {871 ResultSet resultSet = preStat.executeQuery();872 list = new ArrayList<TestCase>();873 try {874 while (resultSet.next()) {875 list.add(this.loadFromResultSet(resultSet));876 }877 } catch (SQLException exception) {878 LOG.error("Unable to execute query : " + exception.toString());879 } finally {880 resultSet.close();881 }882 } catch (SQLException exception) {883 LOG.error("Unable to execute query : " + exception.toString());884 } finally {885 preStat.close();886 }887 } catch (SQLException exception) {888 LOG.error("Unable to execute query : " + exception.toString());889 } finally {890 try {891 if (connection != null) {892 connection.close();893 }894 } catch (SQLException e) {895 LOG.warn(e.toString());896 }897 }898 return list;899 }900 @Override901 public AnswerList<TestCase> readByVarious(String[] test, String[] app, String[] creator, String[] implementer, String[] system,902 String[] campaign, List<Integer> labelid, String[] priority, String[] group, String[] status, int length) {903 AnswerList<TestCase> answer = new AnswerList<>();904 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);905 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));906 List<TestCase> testCaseList = new ArrayList<>();907 StringBuilder query = new StringBuilder();908 query.append("SELECT * FROM testcase tec ");909 query.append("LEFT JOIN application app ON tec.application = app.application ");910 if ((labelid != null) || (campaign != null)) {911 query.append("LEFT JOIN testcaselabel tel ON tec.test = tel.test AND tec.testcase = tel.testcase ");912 query.append("LEFT JOIN campaignlabel cpl ON cpl.labelId = tel.labelId ");913 }914 query.append("WHERE 1=1 AND tec.tcactive = 'Y' ");915 query.append(createInClauseFromList(test, "tec.test", "AND ", " "));916 query.append(createInClauseFromList(app, "tec.application", "AND ", " "));917 query.append(createInClauseFromList(creator, "tec.usrCreated", "AND ", " "));918 query.append(createInClauseFromList(implementer, "tec.implementer", "AND ", " "));919 query.append(createInClauseFromList(priority, "tec.priority", "AND ", " "));920 query.append(createInClauseFromList(group, "tec.group", "AND ", " "));921 query.append(createInClauseFromList(status, "tec.status", "AND ", " "));922 query.append(createInClauseFromList(system, "app.system", "AND ", " "));923 query.append(SqlUtil.createWhereInClauseInteger("tel.labelid", labelid, "AND ", " "));924 if (campaign != null) {925 query.append(createInClauseFromList(campaign, "cpl.campaign", " AND (", ") "));926 }927 query.append("GROUP BY tec.test, tec.testcase ");928 if (length != -1) {929 query.append("LIMIT ?");930 }931 // Debug message on SQL.932 if (LOG.isDebugEnabled()) {933 LOG.debug("SQL : " + query.toString());934 }935 Connection connection = this.databaseSpring.connect();936 try {937 PreparedStatement preStat = connection.prepareStatement(query.toString());938 if (length != -1) {939 preStat.setInt(1, length);940 }941 try {942 ResultSet resultSet = preStat.executeQuery();943 try {944 //gets the data945 while (resultSet.next()) {946 testCaseList.add(this.loadFromResultSet(resultSet));947 }948 if (testCaseList.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.949 LOG.error("Partial Result in the query.");950 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT);951 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Maximum row reached : " + MAX_ROW_SELECTED));952 answer = new AnswerList<>(testCaseList, testCaseList.size());953 } else if (testCaseList.size() <= 0) {954 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);955 answer = new AnswerList<>(testCaseList, testCaseList.size());956 } else {957 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);958 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));959 answer = new AnswerList<>(testCaseList, testCaseList.size());960 }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%", exception.toString()));965 } finally {966 if (resultSet != null) {967 resultSet.close();968 }969 }970 } catch (SQLException exception) {971 LOG.error("Unable to execute query : " + exception.toString());972 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);973 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));974 } finally {975 if (preStat != null) {976 preStat.close();977 }978 }979 } catch (SQLException exception) {980 LOG.error("Unable to execute query : " + exception.toString());981 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);982 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));983 } finally {984 try {985 if (!this.databaseSpring.isOnTransaction()) {986 if (connection != null) {987 connection.close();988 }989 }990 } catch (SQLException exception) {991 LOG.warn("Unable to close connection : " + exception.toString());992 }993 }994 answer.setResultMessage(msg);995 answer.setDataList(testCaseList);996 return answer;997 }998 @Override999 public List<String> findUniqueDataOfColumn(String column) {1000 List<String> list = null;1001 final String query = "SELECT DISTINCT tec." + column + " FROM testcase tec LEFT OUTER JOIN application a ON a.application=tec.application ORDER BY tec." + column + " ASC";1002 // Debug message on SQL.1003 if (LOG.isDebugEnabled()) {1004 LOG.debug("SQL : " + query);1005 }1006 try (Connection connection = this.databaseSpring.connect();1007 PreparedStatement preStat = connection.prepareStatement(query);1008 ResultSet resultSet = preStat.executeQuery();) {1009 list = new ArrayList<String>();1010 while (resultSet.next()) {1011 list.add(resultSet.getString(1));1012 }1013 } catch (SQLException exception) {1014 LOG.error("Unable to execute query : " + exception.toString());1015 }1016 return list;1017 }1018 @Override1019 public boolean deleteTestCase(TestCase testCase) {1020 boolean bool = false;1021 final String query = "DELETE FROM testcase WHERE test = ? AND testcase = ?";1022 // Debug message on SQL.1023 if (LOG.isDebugEnabled()) {1024 LOG.debug("SQL : " + query);1025 }1026 Connection connection = this.databaseSpring.connect();1027 try {1028 PreparedStatement preStat = connection.prepareStatement(query);1029 try {1030 preStat.setString(1, testCase.getTest());1031 preStat.setString(2, testCase.getTestCase());1032 bool = preStat.executeUpdate() > 0;1033 } catch (SQLException exception) {1034 LOG.error("Unable to execute query : " + exception.toString());1035 } finally {1036 preStat.close();1037 }1038 } catch (SQLException exception) {1039 LOG.error("Unable to execute query : " + exception.toString());1040 } finally {1041 try {1042 if (connection != null) {1043 connection.close();1044 }1045 } catch (SQLException e) {1046 LOG.warn(e.toString());1047 }1048 }1049 return bool;1050 }1051 @Override1052 public void updateTestCase(TestCase testCase) throws CerberusException {1053 final String sql = "UPDATE testcase tc SET tc.Application = ?, tc.BehaviorOrValueExpected = ?, tc.activeQA = ?, tc.activeUAT = ?, tc.activePROD = ?, "1054 + "tc.Priority = ?, tc.Status = ?, tc.TcActive = ?, tc.Description = ?, tc.Group = ?, tc.HowTo = ?, tc.Comment = ?, tc.FromBuild = ?, "1055 + "tc.FromRev = ?, tc.ToBuild = ?, tc.ToRev = ?, tc.BugID = ?, tc.TargetBuild = ?, tc.Implementer = ?, tc.Executor = ?, tc.UsrModif = ?, tc.TargetRev = ?, tc.`function` = ?,"1056 + " `conditionOper` = ?, `conditionVal1` = ?, `conditionVal2` = ?, `conditionVal3` = ?, `useragent` = ?, `screensize` = ?, `testCaseVersion` = ?, dateModif = CURRENT_TIMESTAMP "1057 + "WHERE tc.Test = ? AND tc.Testcase = ?";1058 // Debug message on SQL.1059 if (LOG.isDebugEnabled()) {1060 LOG.debug("SQL : " + sql);1061 }1062 Connection connection = this.databaseSpring.connect();1063 try {1064 PreparedStatement preStat = connection.prepareStatement(sql);1065 try {1066 int i = 1;...

Full Screen

Full Screen

Source:TestCaseService.java Github

copy

Full Screen

...152 public List<TestCase> findTestCaseByApplication(final String application) {153 return testCaseDao.findTestCaseByApplication(application);154 }155 @Override156 public boolean updateTestCaseInformation(TestCase testCase) {157 return testCaseDao.updateTestCaseInformation(testCase);158 }159 @Override160 public boolean updateTestCaseInformationCountries(TestCase tc) {161 return testCaseDao.updateTestCaseInformationCountries(tc);162 }163 @Override164 public boolean createTestCase(TestCase testCase) throws CerberusException {165 return testCaseDao.createTestCase(testCase);166 }167 @Override168 public List<TestCase> findTestCaseActiveByCriteria(String test, String application, String country) {169 return testCaseDao.findTestCaseByCriteria(test, application, country, "Y");170 }171 @Override172 public List<TestCase> findTestCaseByAllCriteria(TestCase tCase, String text, String system) {173 return this.testCaseDao.findTestCaseByCriteria(tCase, text, system);174 }175 @Override176 public AnswerList<List<TestCase>> readByVarious(String[] test, String[] idProject, String[] app, String[] creator, String[] implementer, String[] system,177 String[] campaign, String[] labelid, String[] priority, String[] group, String[] status, int length) {178 return testCaseDao.readByVarious(test, idProject, app, creator, implementer, system, campaign, labelid, priority, group, status, length);179 }180 /**181 * @param column182 * @return183 * @since 0.9.1184 */185 @Override186 public List<String> findUniqueDataOfColumn(String column) {187 return this.testCaseDao.findUniqueDataOfColumn(column);188 }189 @Override190 public List<String> findTestWithTestCaseActiveAutomatedBySystem(String system) {191 TestCase tCase = factoryTCase.create(null, null, null, null, null, null, null, null, null, null,192 null, null, null, null, -1, null, null, null, null, null, "Y", null, null,193 null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);194 List<String> result = new ArrayList();195 List<TestCase> testCases = findTestCaseByAllCriteria(tCase, null, system);196 for (TestCase testCase : testCases) {197 if (!testCase.getGroup().equals("PRIVATE")) {198 result.add(testCase.getTest());199 }200 }201 Set<String> uniqueResult = new HashSet<String>(result);202 result = new ArrayList();203 result.addAll(uniqueResult);204 Collections.sort(result);205 return result;206 }207 @Override208 public List<TestCase> findTestCaseActiveAutomatedBySystem(String test, String system) {209 TestCase tCase = factoryTCase.create(test, null, null, null, null, null, null, null, null, null,210 null, null, null, null, -1, null, null, null, null, null, "Y", null, null,211 null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);212 List<TestCase> result = new ArrayList();213 List<TestCase> testCases = findTestCaseByAllCriteria(tCase, null, system);214 for (TestCase testCase : testCases) {215 if (!testCase.getGroup().equals("PRIVATE")) {216 result.add(testCase);217 }218 }219 return result;220 }221 @Override222 public boolean deleteTestCase(TestCase testCase) {223 return testCaseDao.deleteTestCase(testCase);224 }225 @Override226 public void updateTestCase(TestCase tc) throws CerberusException {227 testCaseDao.updateTestCase(tc);228 }229 @Override230 public String getMaxNumberTestCase(String test) {231 return this.testCaseDao.getMaxNumberTestCase(test);232 }233 @Override234 public AnswerItem<List<TestCase>> findTestCaseByCampaignNameAndCountries(String campaign, String[] countries) {235 String[] status = null;236 String[] system = null;237 String[] application = null;238 String[] priority = null;239 String[] group = null;240 AnswerItem<Map<String, List<String>>> parameters = campaignParameterService.parseParametersByCampaign(campaign);241 for (Map.Entry<String, List<String>> entry : parameters.getItem().entrySet()) {...

Full Screen

Full Screen

updateTestCase

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.dao.impl;2import org.cerberus.crud.entity.TestCase;3import org.cerberus.crud.factory.IFactoryTestCase;4import org.cerberus.database.DatabaseSpring;5import org.cerberus.crud.entity.TestCaseCountryProperties;6import org.cerberus.crud.entity.TestCaseCountryProperties;7import org.cerberus.crud.entity.TestCaseStep;8import org.cerberus.crud.entity.TestCaseStepAction;9import org.cerberus.crud.factory.IFactoryTestCaseCountryProperties;10import org.cerberus.crud.factory.IFactoryTestCaseStep;11import org.cerberus.crud.factory.IFactoryTestCaseStepAction;12import org.cerberus.crud.factory.IFactoryTestCaseStepActionControl;13import org.cerberus.crud.factory.IFactoryTestCaseStepActionControlExecution;14import org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution;15import org.cerberus.crud.factory.IFactoryTestCaseStepExecution;16import org.cerberus.crud.factory.IFactoryTestCaseStepActionControlExecution;17import org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution;18import org.cerberus.crud.factory.IFactoryTestCaseStepExecution;19import org.cerberus.enums.MessageEventEnum;20import org.cerberus.enums.MessageGeneralEnum;21import org.cerberus.exception.CerberusException;22import org.cerberus.crud.service.ITestCaseCountryPropertiesService;23import org.cerberus.crud.service.ITestCaseStepActionControlExecutionService;24import org.cerberus.crud.service.ITestCaseStepActionExecutionService;25import org.cerberus.crud.service.ITestCaseStepExecutionService;26import org.cerberus.crud.service.ITestCaseService;27import org.cerberus.crud.service.ITestCaseStepActionControlService;28import org.cerberus.crud.service.ITestCaseStepActionService;29import org.cerberus.crud.service.ITestCaseStepService;30import org.cerberus.crud.service.impl.TestCaseCountryPropertiesService;31import org.cerberus.crud.service.impl.TestCaseStepActionControlExecutionService;32import org.cerberus.crud.service.impl.TestCaseStepActionExecutionService;33import org.cerberus.crud.service.impl.TestCaseStepExecutionService;34import org.cerberus.crud.service.impl.TestCaseService;35import org.cerberus

Full Screen

Full Screen

updateTestCase

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.dao.impl.TestCaseDAO;2import org.cerberus.crud.entity.TestCase;3import org.cerberus.crud.factory.IFactoryTestCase;4import org.cerberus.crud.factory.impl.FactoryTestCase;5import org.cerberus.util.ParameterParserUtil;6public class UpdateTestCase {7 public static void main(String[] args) {8 String test = ParameterParserUtil.parseStringParam(args[0], "");9 String testCase = ParameterParserUtil.parseStringParam(args[1], "");10 String application = ParameterParserUtil.parseStringParam(args[2], "");11 String description = ParameterParserUtil.parseStringParam(args[3], "");12 String status = ParameterParserUtil.parseStringParam(args[4], "");13 String project = ParameterParserUtil.parseStringParam(args[5], "");14 String ticket = ParameterParserUtil.parseStringParam(args[6], "");15 String bugId = ParameterParserUtil.parseStringParam(args[7], "");16 String targetBuild = ParameterParserUtil.parseStringParam(args[8], "");17 String targetRev = ParameterParserUtil.parseStringParam(args[9], "");18 String comment = ParameterParserUtil.parseStringParam(args[10], "");19 String fromSprint = ParameterParserUtil.parseStringParam(args[11], "");20 String fromRevision = ParameterParserUtil.parseStringParam(args[12], "");21 String toSprint = ParameterParserUtil.parseStringParam(args[13], "");22 String toRevision = ParameterParserUtil.parseStringParam(args[14], "");23 String active = ParameterParserUtil.parseStringParam(args[15], "");24 String creator = ParameterParserUtil.parseStringParam(args[16], "");25 String implementer = ParameterParserUtil.parseStringParam(args[17], "");26 String function = ParameterParserUtil.parseStringParam(args[18], "");27 String lastModifier = ParameterParserUtil.parseStringParam(args[19], "");28 String group = ParameterParserUtil.parseStringParam(args[20], "");29 String priority = ParameterParserUtil.parseStringParam(args[21], "");30 String howTo = ParameterParserUtil.parseStringParam(args[22], "");31 String conditionOper = ParameterParserUtil.parseStringParam(args[23], "");32 String conditionVal1 = ParameterParserUtil.parseStringParam(args[24], "");33 String conditionVal2 = ParameterParserUtil.parseStringParam(args[25], "");

Full Screen

Full Screen

updateTestCase

Using AI Code Generation

copy

Full Screen

1TestCaseDAO testCaseDAO = new TestCaseDAO();2TestCase testCase = new TestCase();3testCase.setTest("TEST");4testCase.setTestCase("TESTCASE");5testCase.setActive("Y");6testCase.setApplication("APP");7testCase.setProject("PROJECT");8testCase.setTicket("TICKET");9testCase.setGroup("GROUP");10testCase.setPriority(1);11testCase.setOrigin("ORIGIN");12testCase.setRefOrigin("REFORIGIN");13testCase.setRefBrowser("REFBROWSER");14testCase.setRefRobot("REFROBOT");15testCase.setRefTestCase("REFTESTCASE");16testCase.setBugId("BUGID");17testCase.setTargetSprint("TARGETSPRINT");18testCase.setTargetRev("TARGETREV");19testCase.setComment("COMMENT");20testCase.setHowTo("HOWTO");21testCase.setFromSprint("FROMSPRINT");22testCase.setFromRev("FROMREV");23testCase.setFromBuild("FROMBUILD");24testCase.setFromRevision("FROMREVISION");25testCase.setFromMajor("FROMMAJOR");26testCase.setFromMinor("FROMMINOR");27testCase.setFromDateCre("FROMDATECRE");28testCase.setFromIdCreator("FROMIDCREATOR");29testCase.setFromIdLastModifier("FROMIDLASTMODIFIER");30testCase.setFromDateModif("FROMDATEMODIF");31testCase.setFromFunction("FROMFUNCTION");32testCase.setFromStatus("FROMSTATUS");33testCase.setFromPriority("FROMPRIORITY");34testCase.setFromComment("FROMCOMMENT");35testCase.setFromBugID("FROMBUGID");36testCase.setFromTicket("FROMTICKET");37testCase.setFromTargetSprint("FROMTARGETSPRINT");38testCase.setFromTargetRev("FROMTARGETREV");39testCase.setFromTargetBuild("FROMTARGETBUILD");40testCase.setFromTargetRev("FROMTARGETREV");41testCase.setFromTargetMajor("FROMTARGETMAJOR");42testCase.setFromTargetMinor("FROMTARGETMINOR");43testCase.setFromTargetRevision("FROMTARGETREVISION");44testCase.setFromApplication("FROMAPPLICATION");45testCase.setFromProject("FROMPROJECT");46testCase.setFromGroup("FROMGROUP");47testCase.setFromRefOrigin("FROMREFORIGIN");48testCase.setFromRefBrowser("FROMREFBROWSER");49testCase.setFromRefRobot("FROMREFROBOT");50testCase.setFromRefTestCase("FROMREFTESTCASE");51testCase.setFromDescription("FROMDESCRIPTION");52testCase.setFromHowTo("FROMHOWTO");53testCase.setFromBehaviorOrValueExpected("FROMBEHAVIORORVALUEEXPECTED");54testCase.setFromUsrCreated("FROMUSRCREATED");

Full Screen

Full Screen

updateTestCase

Using AI Code Generation

copy

Full Screen

1package com.softech.cerberus;2import org.cerberus.crud.dao.ITestCaseDAO;3import org.cerberus.crud.entity.TestCase;4import org.springframework.context.ApplicationContext;5import org.springframework.context.support.ClassPathXmlApplicationContext;6public class UpdateTestCase {7 public static void main(String[] args) {8 ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");9 ITestCaseDAO testCaseDAO = (ITestCaseDAO) appContext.getBean("TestCaseDAO");10 TestCase testCase = new TestCase();11 testCase.setTest("TEST");12 testCase.setTestCase("TESTCASE");13 testCase.setProject("PROJECT");14 testCase.setApplication("APPLICATION");15 testCase.setActive("Y");16 testCase.setTcstatus("OK");17 testCase.setTcactive("Y");18 testCase.setTcstatus("OK");19 testCase.setPriority(1);20 testCase.setGroup("GROUP");21 testCase.setOrigin("MANUAL");22 testCase.setRefOrigin("REF_ORIGIN");23 testCase.setRefKey("REF_KEY");24 testCase.setTicket("TICKET");25 testCase.setFunction("FUNCTION");26 testCase.setSummary("SUMMARY");27 testCase.setHowTo("HOWTO");28 testCase.setBehaviorOrValueExpected("BEHAVIOR");29 testCase.setComment("COMMENT");30 testCase.setUsrModif("ADMIN");31 testCaseDAO.updateTestCase(testCase);32 }33}

Full Screen

Full Screen

updateTestCase

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.dao.impl;2import org.cerberus.crud.entity.TestCase;3import org.cerberus.crud.factory.IFactoryTestCase;4import org.cerberus.database.DatabaseSpring;5import org.cerberus.util.DateUtil;6import org.cerberus.util.SqlUtil;7import org.springframework.beans.factory.annotation.Autowired;8import org.springframework.stereotype.Repository;9public class TestCaseDAO implements ITestCaseDAO {10 private DatabaseSpring databaseSpring;11 private IFactoryTestCase factoryTestCase;12 private final String OBJECT_NAME = "TestCase";13 private final int MAX_ROW_SELECTED = 100000;14 private final String SQL_DUPLICATED = "SELECT * FROM testcase tc WHERE tc.test = ? AND tc.testcase = ?";15 private final String SQL_FIND_TESTCASE_BY_TEST_TESTCASE = "SELECT * FROM testcase tc WHERE tc.test = ? AND tc.testcase = ?";16 private final String SQL_FIND_TESTCASE_BY_TEST_TESTCASE_SYSTEM = "SELECT * FROM testcase tc WHERE tc.test = ? AND tc.testcase = ? AND tc.system = ?";17 private final String SQL_FIND_TESTCASE_BY_TEST_TESTCASE_SYSTEM_COUNTRY = "SELECT * FROM testcase tc WHERE tc.test = ? AND tc.testcase = ? AND tc.system = ? AND tc.country = ?";18 private final String SQL_FIND_TESTCASE_BY_TEST_TESTCASE_SYSTEM_COUNTRY_BROWSER = "SELECT * FROM testcase tc WHERE tc.test = ? AND tc.testcase = ? AND tc.system = ? AND tc.country = ? AND tc.browser = ?";19 private final String SQL_FIND_TESTCASE_BY_TEST_TESTCASE_SYSTEM_COUNTRY_BROWSER_ENVIRONMENT = "SELECT * FROM testcase tc WHERE tc.test = ? AND tc.testcase = ? AND tc.system = ? AND tc.country = ? AND tc.browser = ? AND tc.environment = ?";20 private final String SQL_FIND_TESTCASE_BY_TEST_TESTCASE_SYSTEM_COUNTRY_BROWSER_ENVIRONMENT_ROBOT = "SELECT * FROM testcase tc WHERE tc.test = ? AND tc.testcase = ? AND tc.system = ? AND tc.country = ? AND tc.browser = ? AND tc.environment = ? AND tc.robot = ?";

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