Search in sources :

Example 16 with TestCaseStepExecution

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

the class ControlServiceTest method testDoControlIntegerDifferentWhenValueNotNumeric.

@Test
public void testDoControlIntegerDifferentWhenValueNotNumeric() {
    String property = "10";
    String value = "five";
    String msg = "At least one of the Properties is not numeric, can not compare properties!";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyNumericDifferent");
    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 17 with TestCaseStepExecution

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

the class ControlServiceTest method testDoControlIntegerEqualsWhenValueNotNumeric.

@Test
public void testDoControlIntegerEqualsWhenValueNotNumeric() {
    String property = "10";
    String value = "five";
    String msg = "At least one of the Properties is not numeric, can not compare properties!";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyNumericEquals");
    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 18 with TestCaseStepExecution

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

the class ControlServiceTest method testDoControlIntegerDifferentWhenPropertyNotNumeric.

@Test
public void testDoControlIntegerDifferentWhenPropertyNotNumeric() {
    String property = "five";
    String value = "5";
    String msg = "At least one of the Properties is not numeric, can not compare properties!";
    TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();
    tcsace.setControl("verifyNumericDifferent");
    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 19 with TestCaseStepExecution

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

the class ControlServiceTest method testDoControlIntegerMinorWhenValueNotNumeric.

@Test
public void testDoControlIntegerMinorWhenValueNotNumeric() {
    String property = "10";
    String value = "five";
    String msg = "At least one of the Properties is not numeric, can not compare properties!";
    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 20 with TestCaseStepExecution

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

the class UpdateTestCaseExecution method updateTestCaseStepExecutionFromJsonArray.

/**
 * update Step execution with stepArray and all the parameter belonging to it (action, control)
 * @param JSONObject testCaseJson
 * @param ApplicationContext appContext
 * @throws JSONException
 * @throws IOException
 */
String updateTestCaseStepExecutionFromJsonArray(JSONArray stepArray, ApplicationContext appContext) throws JSONException, IOException {
    String returnCodeOfTestCase = "OK";
    for (int i = 0; i < stepArray.length(); i++) {
        JSONObject currentStep = stepArray.getJSONObject(i);
        long id = currentStep.getLong("id");
        String test = currentStep.getString("test");
        String testCase = currentStep.getString("testcase");
        int step = currentStep.getInt("step");
        int index = currentStep.getInt("index");
        int sort = 0;
        String loop = currentStep.getString("loop");
        String conditionOper = currentStep.getString("conditionOper");
        String conditionVal1Init = currentStep.getString("conditionVal1Init");
        String conditionVal2Init = currentStep.getString("conditionVal2Init");
        String conditionVal1 = currentStep.getString("conditionVal1");
        String conditionVal2 = currentStep.getString("conditionVal2");
        String batNumExe = "NULL";
        long start = currentStep.getLong("start");
        long end = currentStep.getLong("end");
        long fullStart = currentStep.getLong("fullStart");
        long fullEnd = currentStep.getLong("fullEnd");
        // to change
        BigDecimal timeElapsed = new BigDecimal(0);
        String returnCode = currentStep.getString("returnCode");
        // update return code if needed
        if (returnCode.equals("KO"))
            returnCodeOfTestCase = "KO";
        else if (returnCode.equals("FA") && !returnCodeOfTestCase.equals("KO"))
            returnCodeOfTestCase = "FA";
        String description = currentStep.getString("description");
        // String possibly wrote by the user
        String returnMessage = StringUtil.sanitize(currentStep.getString("returnMessage"));
        if (// default message unchanged
        returnMessage == "Step not executed")
            returnMessage = "Step executed manually";
        // create this testCaseStepExecution and update the bdd with it
        TestCaseStepExecution currentTestCaseStepExecution = createTestCaseStepExecution(id, test, testCase, step, index, sort, loop, conditionOper, conditionVal1Init, conditionVal2Init, conditionVal1, conditionVal2, batNumExe, start, end, fullStart, fullEnd, timeElapsed, returnCode, returnMessage, description);
        ITestCaseStepExecutionService testCaseStepExecutionService = appContext.getBean(ITestCaseStepExecutionService.class);
        testCaseStepExecutionService.updateTestCaseStepExecution(currentTestCaseStepExecution);
        // update action list belonging to the current Step
        updateTestCaseStepActionFromJsonArray(currentStep.getJSONArray("actionArr"), appContext);
    }
    return returnCodeOfTestCase;
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) JSONObject(org.json.JSONObject) BigDecimal(java.math.BigDecimal) ITestCaseStepExecutionService(org.cerberus.crud.service.ITestCaseStepExecutionService)

Aggregations

TestCaseStepExecution (org.cerberus.crud.entity.TestCaseStepExecution)35 TestCaseStepActionExecution (org.cerberus.crud.entity.TestCaseStepActionExecution)28 TestCaseStepActionControlExecution (org.cerberus.crud.entity.TestCaseStepActionControlExecution)26 Test (org.junit.Test)26 IFactoryTestCaseStepExecution (org.cerberus.crud.factory.IFactoryTestCaseStepExecution)5 ArrayList (java.util.ArrayList)4 AnswerList (org.cerberus.util.answer.AnswerList)3 BigDecimal (java.math.BigDecimal)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Timestamp (java.sql.Timestamp)2 Date (java.util.Date)2 TestCaseExecutionFile (org.cerberus.crud.entity.TestCaseExecutionFile)2 MessageEvent (org.cerberus.engine.entity.MessageEvent)2 CerberusEventException (org.cerberus.exception.CerberusEventException)2 Ignore (org.junit.Ignore)2 CountryEnvLink (org.cerberus.crud.entity.CountryEnvLink)1 CountryEnvParam (org.cerberus.crud.entity.CountryEnvParam)1