Search in sources :

Example 26 with TestCaseStepActionExecution

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

the class FactoryTestCaseStepActionExecution method create.

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

Example 27 with TestCaseStepActionExecution

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

the class TestCaseStepActionExecutionDAO method findTestCaseStepActionExecutionByCriteria.

@Override
public List<TestCaseStepActionExecution> findTestCaseStepActionExecutionByCriteria(long id, String test, String testCase, int step, int index) {
    List<TestCaseStepActionExecution> result = null;
    TestCaseStepActionExecution resultData;
    final String query = "SELECT * FROM testcasestepactionexecution exa WHERE exa.id = ? AND exa.test = ? AND exa.testcase = ? AND exa.step = ? AND exa.index = ? ORDER BY exa.sort";
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            preStat.setString(1, String.valueOf(id));
            preStat.setString(2, test);
            preStat.setString(3, testCase);
            preStat.setInt(4, step);
            preStat.setInt(5, index);
            ResultSet resultSet = preStat.executeQuery();
            try {
                result = new ArrayList<TestCaseStepActionExecution>();
                while (resultSet.next()) {
                    result.add(this.loadFromResultset(resultSet));
                }
            } catch (SQLException exception) {
                LOG.warn("Unable to execute query : " + exception.toString());
            } finally {
                resultSet.close();
            }
        } catch (SQLException exception) {
            LOG.warn("Unable to execute query : " + exception.toString());
        } finally {
            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());
        }
    }
    return result;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) IFactoryTestCaseStepActionExecution(org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) PreparedStatement(java.sql.PreparedStatement)

Example 28 with TestCaseStepActionExecution

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

the class ControlServiceTest method testDoControlIntegerMinorWhenFail.

@Test
public void testDoControlIntegerMinorWhenFail() {
    String property = "10";
    String value = "5";
    String msg = "'" + property + "' is not minor than '" + value + "'.";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyNumericMinor");
    tcsace.setValue1(property);
    tcsace.setValue2(value);
    tcsace.setFatal("Y");
    TestCaseStepExecution tcse = new TestCaseStepExecution();
    tcse.settCExecution(tCExecution);
    TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
    tcsae.setTestCaseStepExecution(tcse);
    tcsace.setTestCaseStepActionExecution(tcsae);
    this.controlService.doControl(tcsace);
    Assert.assertEquals("KO", tcsace.getReturnCode());
    Assert.assertEquals("Y", tcsace.getFatal());
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) Test(org.junit.Test)

Example 29 with TestCaseStepActionExecution

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

the class ControlServiceTest method testVerifyElementEqualsWithNotCompatibleApplication.

// @Ignore
// @Test
// public void testDoControlElementInElementWhenValueIsNotChildOfProperty() {
// String property = "id=parent";
// String value = "id=child";
// String msg = "Element '" + value + "' is not child of element '" + property + "'.";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// Identifier identifierValue = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test2");
// 
// when(webdriverService.isElementInElement(session, identifier, identifierValue)).thenReturn(Boolean.FALSE);
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementInElement");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
// Assert.assertEquals("KO", tcsace.getReturnCode());
// Assert.assertEquals("Y", tcsace.getFatal());
// }
// 
// @Ignore
// @Test
// public void testDoControlElementInElementWhenValueIsChildOfProperty() {
// String property = "id=parent";
// String value = "id=child";
// String msg = "Element '" + value + "' in child of element '" + property + "'.";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// Identifier identifierValue = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test2");
// 
// when(webdriverService.isElementInElement(session, identifier, identifierValue)).thenReturn(Boolean.TRUE);
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementInElement");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
// Assert.assertEquals("OK", tcsace.getReturnCode());
// Assert.assertEquals("Y", tcsace.getFatal());
// }
@Test
public void testVerifyElementEqualsWithNotCompatibleApplication() {
    String xpath = "/foo/bar";
    String expectedElement = "<bar>baz</bar>";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyElementEquals");
    tcsace.setValue1(xpath);
    tcsace.setValue2(expectedElement);
    tcsace.setFatal("Y");
    TestCaseStepExecution tcse = new TestCaseStepExecution();
    tcse.settCExecution(tCExecution);
    TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
    tcsae.setTestCaseStepExecution(tcse);
    tcsace.setTestCaseStepActionExecution(tcsae);
    this.controlService.doControl(tcsace);
    Assert.assertEquals(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION.getCode(), tcsace.getControlResultMessage().getCode());
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) Test(org.junit.Test)

Example 30 with TestCaseStepActionExecution

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

the class ControlServiceTest method testDoControlElementNotVisibleWhenPropertyNull.

// @Ignore
// @Test
// public void testDoControlElementNotPresentWhenWebDriverException() {
// String property = "id=test";
// String value = "null";
// String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementNotPresent");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// when(webdriverService.isElementPresent(session, identifier)).thenThrow(new WebDriverException());
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg));
// Assert.assertEquals("CA", tcsace.getReturnCode());
// Assert.assertEquals("Y", tcsace.getFatal());
// }
// @Ignore
// @Test
// public void testDoControlElementNotVisibleWhenSuccess() {
// String property = "id=test";
// String value = "null";
// String msg = "Element '" + property + "' is present and not visible on the page.";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementNotVisible");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);
// when(webdriverService.isElementNotVisible(session, identifier)).thenReturn(true);
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
// Assert.assertEquals("OK", tcsace.getReturnCode());
// }
// 
// @Ignore
// @Test
// public void testDoControlElementNotVisibleWhenFail() {
// String property = "id=test";
// String value = "null";
// String msg = "Element '" + property + "' is visible on the page.";
// Identifier identifier = new Identifier();
// identifier.setIdentifier("id");
// identifier.setLocator("test");
// 
// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
// tcsace.setControl("verifyElementNotVisible");
// tcsace.setValue1(property);
// tcsace.setValue2(value);
// tcsace.setFatal("Y");
// TestCaseStepExecution tcse = new TestCaseStepExecution();
// tcse.settCExecution(tCExecution);
// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
// tcsae.setTestCaseStepExecution(tcse);
// tcsace.setTestCaseStepActionExecution(tcsae);
// 
// when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);
// when(webdriverService.isElementNotVisible(session, identifier)).thenReturn(false);
// 
// this.controlService.doControl(tcsace);
// 
// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
// Assert.assertEquals("KO", tcsace.getReturnCode());
// Assert.assertEquals("Y", tcsace.getFatal());
// }
@Test
public void testDoControlElementNotVisibleWhenPropertyNull() {
    String property = "null";
    String value = "id=test";
    String msg = "Object is 'null'. This is mandatory in order to perform the control verify element not visible";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyElementNotVisible");
    tcsace.setValue1(property);
    tcsace.setValue2(value);
    tcsace.setFatal("Y");
    TestCaseStepExecution tcse = new TestCaseStepExecution();
    tcse.settCExecution(tCExecution);
    TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();
    tcsae.setTestCaseStepExecution(tcse);
    tcsace.setTestCaseStepActionExecution(tcsae);
    this.controlService.doControl(tcsace);
    Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());
    Assert.assertEquals("KO", tcsace.getReturnCode());
    Assert.assertEquals("Y", tcsace.getFatal());
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) TestCaseStepActionControlExecution(org.cerberus.crud.entity.TestCaseStepActionControlExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) Test(org.junit.Test)

Aggregations

TestCaseStepActionExecution (org.cerberus.crud.entity.TestCaseStepActionExecution)40 TestCaseStepActionControlExecution (org.cerberus.crud.entity.TestCaseStepActionControlExecution)29 TestCaseStepExecution (org.cerberus.crud.entity.TestCaseStepExecution)28 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)6 IFactoryTestCaseStepActionExecution (org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution)5 TestCaseExecutionFile (org.cerberus.crud.entity.TestCaseExecutionFile)4 MessageEvent (org.cerberus.engine.entity.MessageEvent)4 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 AnswerList (org.cerberus.util.answer.AnswerList)3 JSONObject (org.json.JSONObject)3 FileItem (org.apache.commons.fileupload.FileItem)2 FileUploadException (org.apache.commons.fileupload.FileUploadException)2 DiskFileItemFactory (org.apache.commons.fileupload.disk.DiskFileItemFactory)2 ServletFileUpload (org.apache.commons.fileupload.servlet.ServletFileUpload)2 IRecorderService (org.cerberus.engine.execution.IRecorderService)2 AnswerItem (org.cerberus.util.answer.AnswerItem)2