use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class TestCaseLabelService method duplicateList.
@Override
public Answer duplicateList(List<TestCaseLabel> dataList, String targetTest, String targetTestCase) {
Answer ans = new Answer(null);
List<TestCaseLabel> listToCreate = new ArrayList();
for (TestCaseLabel objectToDuplicate : dataList) {
objectToDuplicate.setTest(targetTest);
objectToDuplicate.setTestcase(targetTestCase);
listToCreate.add(objectToDuplicate);
}
return createList(listToCreate);
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class TestCaseLabelService method compareListAndUpdateInsertDeleteElements.
@Override
public Answer compareListAndUpdateInsertDeleteElements(String test, String testCase, List<TestCaseLabel> newList) {
Answer ans = new Answer(null);
MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);
Answer finalAnswer = new Answer(msg1);
List<TestCaseLabel> oldList = new ArrayList();
try {
oldList = this.convert(this.readByTestTestCase(test, testCase));
} catch (CerberusException ex) {
LOG.error(ex);
}
/**
* Update and Create all objects database Objects from newList
*/
List<TestCaseLabel> listToUpdateOrInsert = new ArrayList(newList);
listToUpdateOrInsert.removeAll(oldList);
List<TestCaseLabel> listToUpdateOrInsertToIterate = new ArrayList(listToUpdateOrInsert);
for (TestCaseLabel objectDifference : listToUpdateOrInsertToIterate) {
for (TestCaseLabel objectInDatabase : oldList) {
if (objectDifference.hasSameKey(objectInDatabase)) {
ans = this.update(objectDifference);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
listToUpdateOrInsert.remove(objectDifference);
}
}
}
/**
* Delete all objects database Objects that do not exist from newList
*/
List<TestCaseLabel> listToDelete = new ArrayList(oldList);
listToDelete.removeAll(newList);
List<TestCaseLabel> listToDeleteToIterate = new ArrayList(listToDelete);
for (TestCaseLabel tcsDifference : listToDeleteToIterate) {
for (TestCaseLabel tcsInPage : newList) {
if (tcsDifference.hasSameKey(tcsInPage)) {
listToDelete.remove(tcsDifference);
}
}
}
if (!listToDelete.isEmpty()) {
ans = this.deleteList(listToDelete);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
}
// We insert only at the end (after deletion of all potencial enreg - linked with #1281)
if (!listToUpdateOrInsert.isEmpty()) {
ans = this.createList(listToUpdateOrInsert);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
}
return finalAnswer;
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class TestCaseStepActionService method duplicateList.
@Override
public Answer duplicateList(List<TestCaseStepAction> objectList, String targetTest, String targetTestCase) {
Answer ans = new Answer(null);
List<TestCaseStepAction> listToCreate = new ArrayList();
for (TestCaseStepAction objectToDuplicate : objectList) {
objectToDuplicate.setTest(targetTest);
objectToDuplicate.setTestCase(targetTestCase);
listToCreate.add(objectToDuplicate);
}
ans = createList(listToCreate);
return ans;
}
use of org.cerberus.util.answer.Answer 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);
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class TestDataLibDataService method compareListAndUpdateInsertDeleteElements.
@Override
public Answer compareListAndUpdateInsertDeleteElements(Integer testDataLibId, List<TestDataLibData> newList) {
Answer ans = new Answer(null);
MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);
Answer finalAnswer = new Answer(msg1);
List<TestDataLibData> oldList = new ArrayList();
try {
oldList = this.convert(this.readByVarious(testDataLibId, null, null, null));
} catch (CerberusException ex) {
LOG.error(ex);
}
/**
* Update and Create all objects database Objects from newList
*/
List<TestDataLibData> listToUpdateOrInsert = new ArrayList(newList);
listToUpdateOrInsert.removeAll(oldList);
List<TestDataLibData> listToUpdateOrInsertToIterate = new ArrayList(listToUpdateOrInsert);
for (TestDataLibData objectDifference : listToUpdateOrInsertToIterate) {
for (TestDataLibData objectInDatabase : oldList) {
if (objectDifference.hasSameKey(objectInDatabase)) {
ans = this.update(objectDifference);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
listToUpdateOrInsert.remove(objectDifference);
}
}
}
/**
* Delete all objects database Objects that do not exist from newList
*/
List<TestDataLibData> listToDelete = new ArrayList(oldList);
listToDelete.removeAll(newList);
List<TestDataLibData> listToDeleteToIterate = new ArrayList(listToDelete);
for (TestDataLibData tcsDifference : listToDeleteToIterate) {
for (TestDataLibData tcsInPage : newList) {
if (tcsDifference.hasSameKey(tcsInPage)) {
listToDelete.remove(tcsDifference);
}
}
}
if (!listToDelete.isEmpty()) {
ans = this.deleteList(listToDelete);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
}
// We insert only at the end (after deletion of all potencial enreg - linked with #1281)
if (!listToUpdateOrInsert.isEmpty()) {
ans = this.createList(listToUpdateOrInsert);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
}
return finalAnswer;
}
Aggregations