Search in sources :

Example 11 with TestCaseStep

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

the class TestCaseService method findTestCaseByKeyWithDependency.

@Override
public TestCase findTestCaseByKeyWithDependency(String test, String testCase) throws CerberusException {
    TestCase newTcase;
    newTcase = findTestCaseByKey(test, testCase);
    if (newTcase == null) {
        // TODO:FN temporary debug messages
        LOG.warn("test case is null - test: " + test + " testcase: " + testCase);
    } else {
        List<TestCaseCountry> testCaseCountry = testCaseCountryService.findTestCaseCountryByTestTestCase(test, testCase);
        List<TestCaseCountry> testCaseCountryToAdd = new ArrayList();
        for (TestCaseCountry tcc : testCaseCountry) {
            List<TestCaseCountryProperties> properties = testCaseCountryPropertiesService.findListOfPropertyPerTestTestCaseCountry(test, testCase, tcc.getCountry());
            tcc.setTestCaseCountryProperty(properties);
            testCaseCountryToAdd.add(tcc);
        }
        newTcase.setTestCaseCountry(testCaseCountryToAdd);
        String initialTest = test;
        String initialTc = testCase;
        List<TestCaseStep> tcs = testCaseStepService.getListOfSteps(test, testCase);
        List<TestCaseStep> tcsToAdd = new ArrayList();
        for (TestCaseStep step : tcs) {
            int stepNumber = step.getStep();
            int initialStep = step.getStep();
            if (step.getUseStep().equals("Y")) {
                test = step.getUseStepTest();
                testCase = step.getUseStepTestCase();
                stepNumber = step.getUseStepStep();
            }
            List<TestCaseStepAction> tcsa = testCaseStepActionService.getListOfAction(test, testCase, stepNumber);
            List<TestCaseStepAction> tcsaToAdd = new ArrayList();
            for (TestCaseStepAction action : tcsa) {
                List<TestCaseStepActionControl> tcsac = testCaseStepActionControlService.findControlByTestTestCaseStepSequence(test, testCase, stepNumber, action.getSequence());
                List<TestCaseStepActionControl> tcsacToAdd = new ArrayList();
                for (TestCaseStepActionControl control : tcsac) {
                    control.setTest(initialTest);
                    control.setTestCase(initialTc);
                    control.setStep(initialStep);
                    tcsacToAdd.add(control);
                }
                action.setTestCaseStepActionControl(tcsacToAdd);
                action.setTest(initialTest);
                action.setTestCase(initialTc);
                action.setStep(initialStep);
                tcsaToAdd.add(action);
            }
            step.setTestCaseStepAction(tcsaToAdd);
            tcsToAdd.add(step);
        }
        newTcase.setTestCaseStep(tcsToAdd);
    }
    return newTcase;
}
Also used : TestCaseStepAction(org.cerberus.crud.entity.TestCaseStepAction) TestCaseCountryProperties(org.cerberus.crud.entity.TestCaseCountryProperties) ArrayList(java.util.ArrayList) TestCaseStep(org.cerberus.crud.entity.TestCaseStep) TestCase(org.cerberus.crud.entity.TestCase) IFactoryTestCase(org.cerberus.crud.factory.IFactoryTestCase) TestCaseCountry(org.cerberus.crud.entity.TestCaseCountry) TestCaseStepActionControl(org.cerberus.crud.entity.TestCaseStepActionControl)

Example 12 with TestCaseStep

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

the class TestCaseStepService method updateTestCaseStepUsingTestCaseStepInList.

private void updateTestCaseStepUsingTestCaseStepInList(List<TestCaseStep> testCaseStepList) throws CerberusException {
    for (TestCaseStep tcsDifference : testCaseStepList) {
        if (tcsDifference.isIsStepInUseByOtherTestCase()) {
            List<TestCaseStep> tcsUsingStep = this.getTestCaseStepUsingStepInParamter(tcsDifference.getTest(), tcsDifference.getTestCase(), tcsDifference.getInitialStep());
            for (TestCaseStep tcsUS : tcsUsingStep) {
                tcsUS.setUseStepStep(tcsDifference.getStep());
                this.updateTestCaseStep(tcsUS);
            }
        }
    }
}
Also used : TestCaseStep(org.cerberus.crud.entity.TestCaseStep)

Example 13 with TestCaseStep

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

the class TestCaseStepService method compareListAndUpdateInsertDeleteElements.

@Override
public void compareListAndUpdateInsertDeleteElements(List<TestCaseStep> newList, List<TestCaseStep> oldList, boolean duplicate) throws CerberusException {
    /**
     * Iterate on (TestCaseStep From Page - TestCaseStep From Database) If
     * TestCaseStep in Database has same key : Update and remove from the
     * list. If TestCaseStep in database does ot exist : Insert it.
     */
    List<TestCaseStep> tcsToUpdateOrInsert = new ArrayList(newList);
    tcsToUpdateOrInsert.removeAll(oldList);
    List<TestCaseStep> tcsToUpdateOrInsertToIterate = new ArrayList(tcsToUpdateOrInsert);
    for (TestCaseStep tcsDifference : tcsToUpdateOrInsertToIterate) {
        for (TestCaseStep tcsInDatabase : oldList) {
            if (tcsDifference.hasSameKey(tcsInDatabase)) {
                this.updateTestCaseStep(tcsDifference);
                tcsToUpdateOrInsert.remove(tcsDifference);
                List<TestCaseStep> tcsDependencyToUpd = new ArrayList<TestCaseStep>();
                tcsDependencyToUpd.add(tcsDifference);
                updateTestCaseStepUsingTestCaseStepInList(tcsDependencyToUpd);
            }
        }
    }
    /**
     * Iterate on (TestCaseStep From Database - TestCaseStep From Page). If
     * TestCaseStep in Page has same key : remove from the list. Then delete
     * the list of TestCaseStep
     */
    if (!duplicate) {
        List<TestCaseStep> tcsToDelete = new ArrayList(oldList);
        tcsToDelete.removeAll(newList);
        List<TestCaseStep> tcsToDeleteToIterate = new ArrayList(tcsToDelete);
        for (TestCaseStep tcsDifference : tcsToDeleteToIterate) {
            for (TestCaseStep tcsInPage : newList) {
                if (tcsDifference.hasSameKey(tcsInPage)) {
                    tcsToDelete.remove(tcsDifference);
                }
            }
        }
        updateTestCaseStepUsingTestCaseStepInList(tcsToDelete);
        this.deleteListTestCaseStep(tcsToDelete);
    }
    // We insert only at the end (after deletion of all potencial enreg - linked with #1281)
    this.createList(tcsToUpdateOrInsert);
    updateTestCaseStepUsingTestCaseStepInList(tcsToUpdateOrInsert);
}
Also used : ArrayList(java.util.ArrayList) TestCaseStep(org.cerberus.crud.entity.TestCaseStep)

Example 14 with TestCaseStep

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

the class TestCaseStepService method modifyTestCaseStepDataFromUsedStep.

@Override
public TestCaseStep modifyTestCaseStepDataFromUsedStep(TestCaseStep masterStep) {
    if (masterStep.getUseStep().equals("Y")) {
        TestCaseStep usedStep = findTestCaseStep(masterStep.getUseStepTest(), masterStep.getUseStepTestCase(), masterStep.getUseStepStep());
        // Copy the usedStep property to main step. Loop and conditionoper are taken from used step.
        if (usedStep != null) {
            masterStep.setLoop(usedStep.getLoop());
            masterStep.setConditionOper(usedStep.getConditionOper());
            masterStep.setConditionVal1(usedStep.getConditionVal1());
            masterStep.setConditionVal2(usedStep.getConditionVal2());
        }
    }
    return masterStep;
}
Also used : TestCaseStep(org.cerberus.crud.entity.TestCaseStep)

Example 15 with TestCaseStep

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

the class TestCaseStepService method duplicateList.

@Override
public Answer duplicateList(List<TestCaseStep> listOfSteps, String targetTest, String targetTestCase) {
    Answer ans = new Answer(null);
    List<TestCaseStep> listToCreate = new ArrayList();
    for (TestCaseStep objectToDuplicate : listOfSteps) {
        objectToDuplicate.setTest(targetTest);
        objectToDuplicate.setTestCase(targetTestCase);
        listToCreate.add(objectToDuplicate);
    }
    return createList(listToCreate);
}
Also used : Answer(org.cerberus.util.answer.Answer) ArrayList(java.util.ArrayList) TestCaseStep(org.cerberus.crud.entity.TestCaseStep)

Aggregations

TestCaseStep (org.cerberus.crud.entity.TestCaseStep)41 ArrayList (java.util.ArrayList)20 IFactoryTestCaseStep (org.cerberus.crud.factory.IFactoryTestCaseStep)19 ITestCaseStepService (org.cerberus.crud.service.ITestCaseStepService)16 TestCase (org.cerberus.crud.entity.TestCase)15 TestCaseStepAction (org.cerberus.crud.entity.TestCaseStepAction)13 JSONObject (org.json.JSONObject)13 ApplicationContext (org.springframework.context.ApplicationContext)12 SQLException (java.sql.SQLException)11 TestCaseCountryProperties (org.cerberus.crud.entity.TestCaseCountryProperties)11 TestCaseStepActionControl (org.cerberus.crud.entity.TestCaseStepActionControl)11 Connection (java.sql.Connection)10 PreparedStatement (java.sql.PreparedStatement)10 ResultSet (java.sql.ResultSet)10 ITestCaseService (org.cerberus.crud.service.ITestCaseService)10 JSONArray (org.json.JSONArray)10 PolicyFactory (org.owasp.html.PolicyFactory)10 ITestCaseStepActionService (org.cerberus.crud.service.ITestCaseStepActionService)9 MessageEvent (org.cerberus.engine.entity.MessageEvent)9 TestCaseCountry (org.cerberus.crud.entity.TestCaseCountry)8