Search in sources :

Example 1 with TestCaseExecutionFile

use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.

the class TestCaseExecutionFileDAO method readByKey.

@Override
public AnswerItem<TestCaseExecutionFile> readByKey(long id) {
    AnswerItem ans = new AnswerItem();
    TestCaseExecutionFile result = null;
    final String query = "SELECT * FROM `testcaseexecutionfile` exf WHERE `id` = ?";
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query);
        LOG.debug("SQL.param.id : " + id);
    }
    try (Connection connection = this.databaseSpring.connect();
        PreparedStatement preStat = connection.prepareStatement(query)) {
        preStat.setLong(1, id);
        try (ResultSet resultSet = preStat.executeQuery()) {
            if (resultSet.first()) {
                result = loadFromResultSet(resultSet);
                msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
                ans.setItem(result);
            } else {
                msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
            }
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    }
    // sets the message
    ans.setResultMessage(msg);
    return ans;
}
Also used : SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) FactoryTestCaseExecutionFile(org.cerberus.crud.factory.impl.FactoryTestCaseExecutionFile) IFactoryTestCaseExecutionFile(org.cerberus.crud.factory.IFactoryTestCaseExecutionFile) TestCaseExecutionFile(org.cerberus.crud.entity.TestCaseExecutionFile) PreparedStatement(java.sql.PreparedStatement) AnswerItem(org.cerberus.util.answer.AnswerItem)

Example 2 with TestCaseExecutionFile

use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.

the class TestCaseExecutionFileDAO method readByKey.

@Override
public AnswerItem<TestCaseExecutionFile> readByKey(long exeId, String level, String fileDesc) {
    AnswerItem ans = new AnswerItem();
    TestCaseExecutionFile result = null;
    StringBuilder query = new StringBuilder("SELECT * FROM `testcaseexecutionfile` exf WHERE `exeid` = ? and `level` = ? ");
    if (fileDesc != null) {
        query.append("and `filedesc` = ? ");
    }
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query);
        LOG.debug("SQL.param.id : " + exeId);
        LOG.debug("SQL.param.id : " + level);
        LOG.debug("SQL.param.id : " + fileDesc);
    }
    try (Connection connection = this.databaseSpring.connect();
        PreparedStatement preStat = connection.prepareStatement(query.toString())) {
        preStat.setLong(1, exeId);
        preStat.setString(2, level);
        if (fileDesc != null) {
            preStat.setString(3, fileDesc);
        }
        try (ResultSet resultSet = preStat.executeQuery()) {
            if (resultSet.first()) {
                result = loadFromResultSet(resultSet);
                msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
                ans.setItem(result);
            } else {
                msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
            }
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    }
    // sets the message
    ans.setResultMessage(msg);
    return ans;
}
Also used : SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) FactoryTestCaseExecutionFile(org.cerberus.crud.factory.impl.FactoryTestCaseExecutionFile) IFactoryTestCaseExecutionFile(org.cerberus.crud.factory.IFactoryTestCaseExecutionFile) TestCaseExecutionFile(org.cerberus.crud.entity.TestCaseExecutionFile) PreparedStatement(java.sql.PreparedStatement) AnswerItem(org.cerberus.util.answer.AnswerItem)

Example 3 with TestCaseExecutionFile

use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.

the class FactoryTestCaseExecutionData method create.

@Override
public TestCaseExecutionData create(long id, String property, int index, String description, String value, String type, String value1, String value2, String rC, String rMessage, long start, long end, long startLong, long endLong, MessageEvent message, int retrynb, int retryperiod, String database, String value1Init, String value2Init, String lengthInit, String length, int rowLimit, String nature, String system, String environment, String country, String dataLib, String jsonResult, String fromCache) {
    TestCaseExecutionData testCaseExecutionData = new TestCaseExecutionData();
    testCaseExecutionData.setId(id);
    testCaseExecutionData.setProperty(property);
    testCaseExecutionData.setIndex(index);
    testCaseExecutionData.setType(type);
    testCaseExecutionData.setValue(value);
    testCaseExecutionData.setDatabase(database);
    testCaseExecutionData.setValue1Init(value1Init);
    testCaseExecutionData.setValue2Init(value2Init);
    testCaseExecutionData.setValue1(value1);
    testCaseExecutionData.setValue2(value2);
    testCaseExecutionData.setLength(length);
    testCaseExecutionData.setLengthInit(lengthInit);
    testCaseExecutionData.setRowLimit(rowLimit);
    testCaseExecutionData.setNature(nature);
    testCaseExecutionData.setRetryNb(retrynb);
    testCaseExecutionData.setRetryPeriod(retryperiod);
    testCaseExecutionData.setStart(start);
    testCaseExecutionData.setEnd(end);
    testCaseExecutionData.setStartLong(startLong);
    testCaseExecutionData.setEndLong(endLong);
    testCaseExecutionData.setRC(rC);
    testCaseExecutionData.setrMessage(rMessage);
    testCaseExecutionData.setDescription(description);
    testCaseExecutionData.setPropertyResultMessage(message);
    testCaseExecutionData.setSystem(system);
    testCaseExecutionData.setEnvironment(environment);
    testCaseExecutionData.setCountry(country);
    testCaseExecutionData.setDataLib(dataLib);
    testCaseExecutionData.setJsonResult(jsonResult);
    testCaseExecutionData.setFromCache(fromCache);
    // List objects
    List<TestCaseExecutionFile> objectFileList = new ArrayList<TestCaseExecutionFile>();
    testCaseExecutionData.setFileList(objectFileList);
    return testCaseExecutionData;
}
Also used : TestCaseExecutionData(org.cerberus.crud.entity.TestCaseExecutionData) IFactoryTestCaseExecutionData(org.cerberus.crud.factory.IFactoryTestCaseExecutionData) ArrayList(java.util.ArrayList) TestCaseExecutionFile(org.cerberus.crud.entity.TestCaseExecutionFile)

Example 4 with TestCaseExecutionFile

use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.

the class FactoryTestCaseStepActionControlExecution method create.

@Override
public TestCaseStepActionControlExecution create(long id, String test, String testCase, int step, int index, int sequence, int controlSequence, int sort, String returnCode, String returnMessage, String conditionOper, String conditionVal1Init, String conditionVal2Init, String conditionVal1, String conditionVal2, String control, String value1Init, String value2Init, String value1, String value2, String fatal, long start, long end, long startLong, long endLong, String description, TestCaseStepActionExecution testCaseStepActionExecution, MessageEvent resultMessage) {
    TestCaseStepActionControlExecution testCaseStepActionControlExecution = new TestCaseStepActionControlExecution();
    testCaseStepActionControlExecution.setId(id);
    testCaseStepActionControlExecution.setTest(test);
    testCaseStepActionControlExecution.setTestCase(testCase);
    testCaseStepActionControlExecution.setStep(step);
    testCaseStepActionControlExecution.setIndex(index);
    testCaseStepActionControlExecution.setSequence(sequence);
    testCaseStepActionControlExecution.setControlSequence(controlSequence);
    testCaseStepActionControlExecution.setSort(sort);
    testCaseStepActionControlExecution.setReturnCode(returnCode);
    testCaseStepActionControlExecution.setReturnMessage(returnMessage);
    testCaseStepActionControlExecution.setConditionOper(conditionOper);
    testCaseStepActionControlExecution.setConditionVal1Init(conditionVal1Init);
    testCaseStepActionControlExecution.setConditionVal2Init(conditionVal2Init);
    testCaseStepActionControlExecution.setConditionVal1(conditionVal1);
    testCaseStepActionControlExecution.setConditionVal2(conditionVal2);
    testCaseStepActionControlExecution.setControl(control);
    testCaseStepActionControlExecution.setValue1(value1);
    testCaseStepActionControlExecution.setValue2(value2);
    testCaseStepActionControlExecution.setValue1Init(value1Init);
    testCaseStepActionControlExecution.setValue2Init(value2Init);
    testCaseStepActionControlExecution.setFatal(fatal);
    testCaseStepActionControlExecution.setStart(start);
    testCaseStepActionControlExecution.setEnd(end);
    testCaseStepActionControlExecution.setStartLong(startLong);
    testCaseStepActionControlExecution.setEndLong(endLong);
    testCaseStepActionControlExecution.setTestCaseStepActionExecution(testCaseStepActionExecution);
    testCaseStepActionControlExecution.setControlResultMessage(resultMessage);
    testCaseStepActionControlExecution.setDescription(description);
    // List objects
    List<TestCaseExecutionFile> objectFileList = new ArrayList<TestCaseExecutionFile>();
    testCaseStepActionControlExecution.setFileList(objectFileList);
    return testCaseStepActionControlExecution;
}
Also used : IFactoryTestCaseStepActionControlExecution(org.cerberus.crud.factory.IFactoryTestCaseStepActionControlExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) ArrayList(java.util.ArrayList) TestCaseExecutionFile(org.cerberus.crud.entity.TestCaseExecutionFile)

Example 5 with TestCaseExecutionFile

use of org.cerberus.crud.entity.TestCaseExecutionFile in project cerberus-source by cerberustesting.

the class FactoryTestCaseExecution method create.

@Override
public TestCaseExecution create(long id, String test, String testCase, String description, String build, String revision, String environment, String country, String browser, String version, String platform, String browserFullVersion, long start, long end, String controlStatus, String controlMessage, String application, Application applicationObj, String ip, String url, String port, String tag, int verbose, int screenshot, int pageSource, int seleniumLog, boolean synchroneous, String timeout, String outputFormat, String status, String crbVersion, TestCase tCase, CountryEnvParam countryEnvParam, CountryEnvironmentParameters countryEnvironmentParameters, boolean manualURL, String myHost, String myContextRoot, String myLoginRelativeURL, String myEnvData, String seleniumIP, String seleniumPort, List<TestCaseStepExecution> testCaseStepExecution, MessageGeneral resultMessage, String executor, int numberOfRetries, String screenSize, List<RobotCapability> capabilities, String conditionOper, String conditionVal1Init, String conditionVal2Init, String conditionVal1, String conditionVal2, String manualExecution, String userAgent, int testCaseVersion, String system, String robotDecli) {
    TestCaseExecution newTce = new TestCaseExecution();
    newTce.setApplicationObj(applicationObj);
    newTce.setApplication(application);
    newTce.setBrowser(browser);
    newTce.setVersion(version);
    newTce.setPlatform(platform);
    newTce.setBrowserFullVersion(browserFullVersion);
    newTce.setBuild(build);
    newTce.setControlMessage(controlMessage);
    newTce.setControlStatus(controlStatus);
    newTce.setCountry(country);
    newTce.setCrbVersion(crbVersion);
    newTce.setEnd(end);
    newTce.setEnvironment(environment);
    newTce.setEnvironmentData(myEnvData);
    newTce.setId(id);
    newTce.setIp(ip);
    newTce.setPort(port);
    newTce.setRevision(revision);
    newTce.setStart(start);
    newTce.setStatus(status);
    newTce.setTag(tag);
    newTce.setTest(test);
    newTce.setTestCase(testCase);
    newTce.setUrl(url);
    newTce.setVerbose(verbose);
    newTce.setScreenshot(screenshot);
    newTce.setTestCaseObj(tCase);
    newTce.setCountryEnvParam(countryEnvParam);
    newTce.setCountryEnvironmentParameters(countryEnvironmentParameters);
    newTce.setManualURL(manualURL);
    newTce.setMyHost(myHost);
    newTce.setMyContextRoot(myContextRoot);
    newTce.setMyLoginRelativeURL(myLoginRelativeURL);
    newTce.setSeleniumIP(seleniumIP);
    newTce.setSeleniumPort(seleniumPort);
    if (testCaseStepExecution == null) {
        testCaseStepExecution = new ArrayList<>();
    }
    newTce.setTestCaseStepExecutionList(testCaseStepExecution);
    newTce.setResultMessage(resultMessage);
    newTce.setOutputFormat(outputFormat);
    newTce.setTimeout(timeout);
    newTce.setSynchroneous(synchroneous);
    newTce.setPageSource(pageSource);
    newTce.setSeleniumLog(seleniumLog);
    newTce.setExecutor(executor);
    newTce.setNumberOfRetries(numberOfRetries);
    newTce.setScreenSize(screenSize);
    newTce.setCapabilities(capabilities);
    newTce.setLastWebsocketPush(0);
    newTce.setConditionOper(conditionOper);
    newTce.setConditionVal1(conditionVal1);
    newTce.setConditionVal1Init(conditionVal1Init);
    newTce.setConditionVal2(conditionVal2);
    newTce.setConditionVal2Init(conditionVal2Init);
    newTce.setManualExecution(manualExecution);
    newTce.setUserAgent(userAgent);
    newTce.setDescription(description);
    newTce.setRobotDecli(robotDecli);
    newTce.setSystem(system);
    // List objects
    List<TestCaseExecutionFile> objectFileList = new ArrayList<>();
    newTce.setFileList(objectFileList);
    TreeMap<String, TestCaseExecutionData> hashTemp1 = new TreeMap<>();
    newTce.setTestCaseExecutionDataMap(hashTemp1);
    newTce.setNbExecutions(1);
    newTce.setTestCaseVersion(testCaseVersion);
    return newTce;
}
Also used : TestCaseExecution(org.cerberus.crud.entity.TestCaseExecution) IFactoryTestCaseExecution(org.cerberus.crud.factory.IFactoryTestCaseExecution) TestCaseExecutionData(org.cerberus.crud.entity.TestCaseExecutionData) ArrayList(java.util.ArrayList) TestCaseExecutionFile(org.cerberus.crud.entity.TestCaseExecutionFile) TreeMap(java.util.TreeMap)

Aggregations

TestCaseExecutionFile (org.cerberus.crud.entity.TestCaseExecutionFile)28 IFactoryTestCaseExecutionFile (org.cerberus.crud.factory.IFactoryTestCaseExecutionFile)15 ArrayList (java.util.ArrayList)13 MessageEvent (org.cerberus.engine.entity.MessageEvent)8 AnswerList (org.cerberus.util.answer.AnswerList)7 Recorder (org.cerberus.engine.entity.Recorder)6 CerberusException (org.cerberus.exception.CerberusException)6 IOException (java.io.IOException)5 AnswerItem (org.cerberus.util.answer.AnswerItem)5 File (java.io.File)4 FileNotFoundException (java.io.FileNotFoundException)4 TestCaseExecutionData (org.cerberus.crud.entity.TestCaseExecutionData)4 TestCaseStepActionControlExecution (org.cerberus.crud.entity.TestCaseStepActionControlExecution)4 TestCaseStepActionExecution (org.cerberus.crud.entity.TestCaseStepActionExecution)4 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 TestCaseExecution (org.cerberus.crud.entity.TestCaseExecution)3 FactoryTestCaseExecutionFile (org.cerberus.crud.factory.impl.FactoryTestCaseExecutionFile)3