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;
}
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);
}
}
}
}
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);
}
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;
}
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);
}
Aggregations