use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class TestCaseStepActionDAO method update.
@Override
public void update(TestCaseStepAction testCaseStepAction) throws CerberusException {
boolean throwExcep = false;
final String query = new StringBuilder("UPDATE `testcasestepaction` ").append("SET ").append("`Test` = ?, ").append("`TestCase` = ?, ").append("`Step` = ?, ").append("`Sequence` = ?, ").append("`Sort` = ?, ").append("`ConditionOper` = ?, ").append("`ConditionVal1` = ?, ").append("`ConditionVal2` = ?, ").append("`Action` = ?, ").append("`Value1` = ?, ").append("`Value2` = ?, ").append("`ForceExeStatus` = ?, ").append("`Description` = ?, ").append("`ScreenshotFilename` = ? ").append("WHERE `Test` = ? AND `TestCase` = ? AND `Step` = ? AND `Sequence` = ? ").toString();
LOG.debug("SQL " + query);
LOG.debug("SQL.param.conditionOper " + testCaseStepAction.getConditionOper());
LOG.debug("SQL.param.conditionVal1 " + testCaseStepAction.getConditionVal1());
LOG.debug("SQL.param.conditionVal2 " + testCaseStepAction.getConditionVal2());
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
int i = 1;
preStat.setString(i++, testCaseStepAction.getTest());
preStat.setString(i++, testCaseStepAction.getTestCase());
preStat.setInt(i++, testCaseStepAction.getStep());
preStat.setInt(i++, testCaseStepAction.getSequence());
preStat.setInt(i++, testCaseStepAction.getSort());
preStat.setString(i++, testCaseStepAction.getConditionOper());
preStat.setString(i++, testCaseStepAction.getConditionVal1());
preStat.setString(i++, testCaseStepAction.getConditionVal2());
preStat.setString(i++, testCaseStepAction.getAction());
preStat.setString(i++, testCaseStepAction.getValue1());
preStat.setString(i++, testCaseStepAction.getValue2());
preStat.setString(i++, testCaseStepAction.getForceExeStatus());
preStat.setString(i++, testCaseStepAction.getDescription());
preStat.setString(i++, testCaseStepAction.getScreenshotFilename());
preStat.setString(i++, testCaseStepAction.getTest());
preStat.setString(i++, testCaseStepAction.getTestCase());
preStat.setInt(i++, testCaseStepAction.getStep());
preStat.setInt(i++, testCaseStepAction.getSequence());
preStat.executeUpdate();
throwExcep = false;
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
if (preStat != null) {
preStat.close();
}
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class TestCaseStepDAO method updateTestCaseStep.
@Override
public void updateTestCaseStep(TestCaseStep tcs) throws CerberusException {
boolean throwExcep = false;
StringBuilder query = new StringBuilder();
query.append("UPDATE testcasestep SET ");
query.append(" `Description` = ?, `useStep`=? ");
if (!StringUtil.isNullOrEmpty(tcs.getUseStepTest())) {
query.append(",`useStepTest`=? ");
}
if (!StringUtil.isNullOrEmpty(tcs.getUseStepTestCase())) {
query.append(",`useStepTestCase`=? ");
}
if (tcs.getUseStepStep() >= 0) {
query.append(",`useStepStep`=? ");
}
query.append(",`inlibrary` = ?, `Sort` = ?, `loop` = ?, `conditionOper` = ?, `conditionVal1` = ?, `conditionVal2` = ? WHERE Test = ? AND TestCase = ? AND step = ?");
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query.toString());
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
int i = 1;
preStat.setString(i++, tcs.getDescription());
preStat.setString(i++, tcs.getUseStep() == null ? "N" : tcs.getUseStep());
if (!StringUtil.isNullOrEmpty(tcs.getUseStepTest())) {
preStat.setString(i++, tcs.getUseStepTest());
}
if (!StringUtil.isNullOrEmpty(tcs.getUseStepTestCase())) {
preStat.setString(i++, tcs.getUseStepTestCase());
}
if (tcs.getUseStepStep() >= 0) {
preStat.setInt(i++, tcs.getUseStepStep());
}
preStat.setString(i++, tcs.getInLibrary() == null ? "N" : tcs.getInLibrary());
preStat.setInt(i++, tcs.getSort());
preStat.setString(i++, tcs.getLoop() == null ? "" : tcs.getLoop());
preStat.setString(i++, tcs.getConditionOper() == null ? "" : tcs.getConditionOper());
preStat.setString(i++, tcs.getConditionVal1() == null ? "" : tcs.getConditionVal1());
preStat.setString(i++, tcs.getConditionVal2() == null ? "" : tcs.getConditionVal2());
preStat.setString(i++, tcs.getTest());
preStat.setString(i++, tcs.getTestCase());
preStat.setInt(i++, tcs.getStep());
preStat.executeUpdate();
throwExcep = false;
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn("Exception Closing the connection : " + e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class TestDAO method createTest.
@Override
public boolean createTest(Test test) throws CerberusException {
boolean res = false;
final String sql = "INSERT INTO test (Test, Description, Active, Automated, TDateCrea) VALUES (?, ?, ?, ?, ?)";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(sql);
try {
preStat.setString(1, test.getTest());
preStat.setString(2, test.getDescription());
preStat.setString(3, test.getActive());
preStat.setString(4, test.getAutomated());
preStat.setString(5, DateUtil.getMySQLTimestampTodayDeltaMinutes(0));
res = preStat.executeUpdate() > 0;
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.GUI_ERROR_INSERTING_DATA);
mes.setDescription(mes.getDescription().replace("%DETAILS%", exception.toString()));
throw new CerberusException(mes);
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.GUI_ERROR_INSERTING_DATA);
mes.setDescription(mes.getDescription().replace("%DETAILS%", exception.toString()));
throw new CerberusException(mes);
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
return res;
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class CampaignParameterDAO method findAll.
@Override
public List<CampaignParameter> findAll() throws CerberusException {
boolean throwEx = false;
final String query = "SELECT * FROM campaignparameter c";
List<CampaignParameter> campaignParameterList = new ArrayList<CampaignParameter>();
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query)) {
try (ResultSet resultSet = preStat.executeQuery()) {
while (resultSet.next()) {
campaignParameterList.add(this.loadFromResultSet(resultSet));
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
campaignParameterList = null;
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
campaignParameterList = null;
}
if (throwEx) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));
}
return campaignParameterList;
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class CampaignParameterDAO method findCampaignParametersByCampaign.
@Override
public List<CampaignParameter> findCampaignParametersByCampaign(String campaign) throws CerberusException {
boolean throwEx = false;
final String query = "SELECT * FROM campaignparameter c WHERE c.campaign = ?";
List<CampaignParameter> campaignParameterList = new ArrayList<CampaignParameter>();
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query)) {
preStat.setString(1, campaign);
try (ResultSet resultSet = preStat.executeQuery()) {
while (resultSet.next()) {
campaignParameterList.add(this.loadFromResultSet(resultSet));
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
campaignParameterList = null;
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
campaignParameterList = null;
}
if (throwEx) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));
}
return campaignParameterList;
}
Aggregations