use of org.cerberus.crud.entity.TestCaseExecutionData in project cerberus-source by cerberustesting.
the class PropertyService method calculateProperty.
@Override
public void calculateProperty(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseStepActionExecution testCaseStepActionExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceRecalculation) {
testCaseExecutionData.setStart(new Date().getTime());
MessageEvent res;
String test = tCExecution.getTest();
String testCase = tCExecution.getTestCase();
AnswerItem<String> answerDecode = new AnswerItem();
if (LOG.isDebugEnabled()) {
LOG.debug("Starting to calculate Property : '" + testCaseCountryProperty.getProperty() + "'");
}
// Checking recursive decode.
if ((tCExecution.getRecursiveAlreadyCalculatedPropertiesList() != null) && (tCExecution.getRecursiveAlreadyCalculatedPropertiesList().contains(testCaseCountryProperty.getProperty()))) {
res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_RECURSIVE);
res.setDescription(res.getDescription().replace("%PROPERTY%", testCaseCountryProperty.getProperty()).replace("%HISTO%", tCExecution.getRecursiveAlreadyCalculatedPropertiesList().toString()));
testCaseExecutionData.setPropertyResultMessage(res);
testCaseExecutionData.setEnd(new Date().getTime());
LOG.debug("Finished to calculate Property (interupted) : '" + testCaseCountryProperty.getProperty() + "' : " + testCaseExecutionData.getPropertyResultMessage().getDescription());
return;
}
if (tCExecution.getRecursiveAlreadyCalculatedPropertiesList() != null) {
tCExecution.getRecursiveAlreadyCalculatedPropertiesList().add(testCaseCountryProperty.getProperty());
}
try {
// Check if cache activated and cache entry exist.
int cacheValue = testCaseCountryProperty.getCacheExpire();
boolean useCache = false;
AnswerItem<TestCaseExecutionData> answerData = null;
if (cacheValue > 0) {
answerData = testCaseExecutionDataService.readLastCacheEntry(tCExecution.getApplicationObj().getSystem(), tCExecution.getEnvironment(), tCExecution.getCountry(), testCaseCountryProperty.getProperty(), cacheValue);
if (answerData.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && answerData.getItem() != null) {
useCache = true;
}
}
if (!useCache) {
/**
* Decode Property replacing properties encapsulated with %
*/
if (testCaseCountryProperty.getValue1().contains("%")) {
answerDecode = variableService.decodeStringCompletly(testCaseCountryProperty.getValue1(), tCExecution, null, false);
testCaseExecutionData.setValue1((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the property result.
testCaseExecutionData.setPropertyResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Property Value1"));
testCaseExecutionData.setEnd(new Date().getTime());
testCaseExecutionData.setStopExecution(answerDecode.getResultMessage().isStopTest());
LOG.debug("Finished to calculate Property (interupted) : '" + testCaseCountryProperty.getProperty() + "' : " + testCaseExecutionData.getPropertyResultMessage().getDescription());
return;
}
}
if (testCaseCountryProperty.getValue2() != null && testCaseCountryProperty.getValue2().contains("%")) {
answerDecode = variableService.decodeStringCompletly(testCaseCountryProperty.getValue2(), tCExecution, null, false);
testCaseExecutionData.setValue2((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the property result.
testCaseExecutionData.setPropertyResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Property Value2"));
testCaseExecutionData.setEnd(new Date().getTime());
testCaseExecutionData.setStopExecution(answerDecode.getResultMessage().isStopTest());
LOG.debug("Finished to calculate Property (interupted) : '" + testCaseCountryProperty.getProperty() + "' : " + testCaseExecutionData.getPropertyResultMessage().getDescription());
return;
}
}
// cache not activated or no entry exist.
int execution_count = 0;
int retries = testCaseCountryProperty.getRetryNb();
int periodms = testCaseCountryProperty.getRetryPeriod();
LOG.debug("Init Retries : " + retries + " Period : " + periodms);
/**
* Controling that retrynb and retryperiod are correctly feeded.
* <br>
* This is to avoid that <br>
* 1/ retry is greater than cerberus_property_maxretry <br>
* 2/ total duration of property calculation is longuer than
* cerberus_property_maxretrytotalduration
*/
boolean forced_retry = false;
String forced_retry_message = "";
if (!(retries == 0)) {
int maxretry = parameterService.getParameterIntegerByKey("cerberus_property_maxretry", "", 50);
if (retries > maxretry) {
retries = maxretry;
forced_retry = true;
}
int maxtotalduration = parameterService.getParameterIntegerByKey("cerberus_property_maxretrytotalduration", "", 1800000);
if (periodms > maxtotalduration) {
periodms = maxtotalduration;
forced_retry = true;
}
if (retries * periodms > maxtotalduration) {
retries = (int) maxtotalduration / periodms;
forced_retry = true;
}
if (forced_retry) {
forced_retry_message = "WARNING : Forced Retries : " + testCaseCountryProperty.getRetryNb() + "-->" + retries + " and Period : " + testCaseCountryProperty.getRetryPeriod() + "-->" + periodms + " (in order to respect the constrains cerberus_property_maxretry " + maxretry + " & cerberus_property_maxtotalduration " + maxtotalduration + ")";
LOG.debug("Forced Retries : " + retries + " Period : " + periodms + " in order to respect the constrains cerberus_property_maxretry " + maxretry + " & cerberus_property_maxtotalduration " + maxtotalduration);
}
}
/**
* Looping on calculating the action until result is OK or reach
* the max retry.
*/
while (execution_count <= retries && !(testCaseExecutionData.getPropertyResultMessage().getCodeString().equals("OK"))) {
LOG.debug("Attempt #" + execution_count + " " + testCaseCountryProperty.getProperty() + " " + testCaseCountryProperty.getValue1());
if (execution_count >= 1) {
// We only wait the period if not on the very first calculation.
try {
Thread.sleep(periodms);
LOG.debug("Attempt #" + execution_count + " " + testCaseCountryProperty.getProperty() + " " + testCaseCountryProperty.getValue1() + " Waiting " + periodms + " ms");
} catch (InterruptedException ex) {
LOG.error(ex.toString());
}
}
/**
* Calculate Property regarding the type
*/
switch(testCaseCountryProperty.getType()) {
case TestCaseCountryProperties.TYPE_TEXT:
testCaseExecutionData = this.property_calculateText(testCaseExecutionData, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMDATALIB:
testCaseExecutionData = this.property_getFromDataLib(testCaseExecutionData, tCExecution, testCaseStepActionExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMSQL:
testCaseExecutionData = this.property_getFromSql(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMHTML:
testCaseExecutionData = this.property_getFromHtml(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMHTMLVISIBLE:
testCaseExecutionData = this.property_getFromHtmlVisible(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMJS:
testCaseExecutionData = this.property_getFromJS(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETATTRIBUTEFROMHTML:
testCaseExecutionData = this.property_getAttributeFromHtml(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMCOOKIE:
testCaseExecutionData = this.property_getFromCookie(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMXML:
testCaseExecutionData = this.property_getFromXml(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETDIFFERENCESFROMXML:
testCaseExecutionData = this.property_getDifferencesFromXml(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMJSON:
testCaseExecutionData = this.property_getFromJson(testCaseExecutionData, tCExecution, forceRecalculation);
break;
case TestCaseCountryProperties.TYPE_GETFROMGROOVY:
testCaseExecutionData = this.property_getFromGroovy(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceRecalculation);
break;
case // DEPRECATED
TestCaseCountryProperties.TYPE_EXECUTESOAPFROMLIB:
testCaseExecutionData = this.property_executeSoapFromLib(testCaseExecutionData, tCExecution, testCaseStepActionExecution, testCaseCountryProperty, forceRecalculation);
res = testCaseExecutionData.getPropertyResultMessage();
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
testCaseExecutionData.setPropertyResultMessage(res);
logEventService.createForPrivateCalls("ENGINE", TestCaseCountryProperties.TYPE_EXECUTESOAPFROMLIB, MESSAGE_DEPRECATED + " Deprecated Property triggered by TestCase : ['" + test + "|" + testCase + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Property " + TestCaseCountryProperties.TYPE_EXECUTESOAPFROMLIB + " triggered by TestCase : ['" + test + "'|'" + testCase + "']");
break;
case // DEPRECATED
TestCaseCountryProperties.TYPE_EXECUTESQLFROMLIB:
testCaseExecutionData = this.property_executeSqlFromLib(testCaseExecutionData, testCaseCountryProperty, tCExecution, forceRecalculation);
res = testCaseExecutionData.getPropertyResultMessage();
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
testCaseExecutionData.setPropertyResultMessage(res);
logEventService.createForPrivateCalls("ENGINE", TestCaseCountryProperties.TYPE_EXECUTESQLFROMLIB, MESSAGE_DEPRECATED + " Deprecated Property triggered by TestCase : ['" + test + "|" + testCase + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Property " + TestCaseCountryProperties.TYPE_EXECUTESQLFROMLIB + " triggered by TestCase : ['" + test + "'|'" + testCase + "']");
break;
default:
res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_UNKNOWNPROPERTY);
res.setDescription(res.getDescription().replace("%PROPERTY%", testCaseCountryProperty.getType()));
testCaseExecutionData.setPropertyResultMessage(res);
}
execution_count++;
}
if (execution_count >= 2) {
// If there were at least 1 retry, we notify it in the result message.
res = testCaseExecutionData.getPropertyResultMessage();
res.setDescription("Retried " + (execution_count - 1) + " time(s) with " + periodms + "ms period - " + res.getDescription());
testCaseExecutionData.setPropertyResultMessage(res);
}
if (forced_retry) {
// If the retry and period parameter was changed, we notify it in the result message.
res = testCaseExecutionData.getPropertyResultMessage();
res.setDescription(forced_retry_message + " - " + res.getDescription());
testCaseExecutionData.setPropertyResultMessage(res);
}
} else {
// cache activated and entry exist. We set the current value with cache entry data and notify the result from the messsage.
TestCaseExecutionData testCaseExecutionDataFromCache = (TestCaseExecutionData) answerData.getItem();
testCaseExecutionData.setFromCache("Y");
testCaseExecutionData.setDataLib(testCaseExecutionDataFromCache.getDataLib());
testCaseExecutionData.setValue(testCaseExecutionDataFromCache.getValue());
testCaseExecutionData.setJsonResult(testCaseExecutionDataFromCache.getJsonResult());
DateFormat df = new SimpleDateFormat(DateUtil.DATE_FORMAT_DISPLAY);
res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_FROMCACHE).resolveDescription("ID", String.valueOf(testCaseExecutionDataFromCache.getId())).resolveDescription("DATE", df.format(testCaseExecutionDataFromCache.getStart()));
testCaseExecutionData.setPropertyResultMessage(res);
if (!StringUtil.isNullOrEmpty(testCaseExecutionDataFromCache.getJsonResult())) {
// Convert json to HashMap.
List<HashMap<String, String>> result = null;
result = new ArrayList();
try {
LOG.debug("Converting Json : " + testCaseExecutionDataFromCache.getJsonResult());
JSONArray json = new JSONArray(testCaseExecutionDataFromCache.getJsonResult());
for (int i = 0; i < json.length(); i++) {
JSONObject explrObject = json.getJSONObject(i);
LOG.debug(explrObject.toString());
HashMap<String, String> resultHash = new HashMap<String, String>();
Iterator<String> nameItr = explrObject.keys();
while (nameItr.hasNext()) {
String name = nameItr.next();
if (name.equals("KEY")) {
resultHash.put("", explrObject.getString(name));
} else {
resultHash.put(name, explrObject.getString(name));
}
}
result.add(resultHash);
}
} catch (JSONException ex) {
java.util.logging.Logger.getLogger(PropertyService.class.getName()).log(Level.SEVERE, null, ex);
LOG.error(ex);
}
testCaseExecutionData.setDataLibRawData(result);
// Record result in filessytem.
recorderService.recordTestDataLibProperty(tCExecution.getId(), testCaseCountryProperty.getProperty(), 1, result);
}
}
} catch (CerberusEventException ex) {
LOG.error(ex.toString());
testCaseExecutionData.setEnd(new Date().getTime());
testCaseExecutionData.setPropertyResultMessage(ex.getMessageError());
}
testCaseExecutionData.setEnd(new Date().getTime());
if (LOG.isDebugEnabled()) {
LOG.debug("Finished to calculate Property : '" + testCaseCountryProperty.getProperty() + "'");
}
}
use of org.cerberus.crud.entity.TestCaseExecutionData in project cerberus-source by cerberustesting.
the class ExecutionRunService method executeStep.
private TestCaseStepExecution executeStep(TestCaseStepExecution testCaseStepExecution, TestCaseExecution tcExecution) {
long runID = testCaseStepExecution.getId();
String logPrefix = runID + " - ";
AnswerItem<String> answerDecode = new AnswerItem();
// Initialise the Step Data List.
List<TestCaseExecutionData> myStepDataList = new ArrayList<TestCaseExecutionData>();
testCaseStepExecution.setTestCaseExecutionDataList(myStepDataList);
// Initialise the Data List used to enter the action.
/**
* Iterate Actions
*/
List<TestCaseStepAction> testCaseStepActionList = testCaseStepExecution.getTestCaseStep().getTestCaseStepAction();
LOG.debug("Getting list of actions of the step. " + testCaseStepActionList.size() + " action(s) to perform.");
for (TestCaseStepAction testCaseStepAction : testCaseStepActionList) {
/**
* Start Execution of TestCaseStepAction
*/
long startAction = new Date().getTime();
/**
* Create and Register TestCaseStepActionExecution.
*/
TestCaseStepActionExecution testCaseStepActionExecution = factoryTestCaseStepActionExecution.create(testCaseStepExecution.getId(), testCaseStepAction.getTest(), testCaseStepAction.getTestCase(), testCaseStepAction.getStep(), testCaseStepExecution.getIndex(), testCaseStepAction.getSequence(), testCaseStepAction.getSort(), null, null, testCaseStepAction.getConditionOper(), testCaseStepAction.getConditionVal1(), testCaseStepAction.getConditionVal2(), testCaseStepAction.getConditionVal1(), testCaseStepAction.getConditionVal2(), testCaseStepAction.getAction(), testCaseStepAction.getValue1(), testCaseStepAction.getValue2(), testCaseStepAction.getValue1(), testCaseStepAction.getValue2(), testCaseStepAction.getForceExeStatus(), startAction, 0, startAction, 0, new MessageEvent(MessageEventEnum.ACTION_PENDING), testCaseStepAction.getDescription(), testCaseStepAction, testCaseStepExecution);
this.testCaseStepActionExecutionService.insertTestCaseStepActionExecution(testCaseStepActionExecution);
/**
* We populate the TestCase Action List
*/
testCaseStepExecution.addTestCaseStepActionExecutionList(testCaseStepActionExecution);
/**
* If execution is not manual, evaluate the condition at the action
* level
*/
AnswerItem<Boolean> conditionAnswer;
boolean conditionDecodeError = false;
if (!tcExecution.getManualExecution().equals("Y")) {
try {
answerDecode = variableService.decodeStringCompletly(testCaseStepActionExecution.getConditionVal1(), tcExecution, null, false);
testCaseStepActionExecution.setConditionVal1((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the action result.
testCaseStepActionExecution.setActionResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Action Condition Value1"));
testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));
testCaseStepActionExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());
testCaseStepActionExecution.setEnd(new Date().getTime());
LOG.debug("Action interupted due to decode 'Action Condition Value1' Error.");
conditionDecodeError = true;
}
} catch (CerberusEventException cex) {
LOG.warn(cex);
}
try {
answerDecode = variableService.decodeStringCompletly(testCaseStepActionExecution.getConditionVal2(), tcExecution, null, false);
testCaseStepActionExecution.setConditionVal2((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the action result.
testCaseStepActionExecution.setActionResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Action Condition Value2"));
testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));
testCaseStepActionExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());
testCaseStepActionExecution.setEnd(new Date().getTime());
LOG.debug("Action interupted due to decode 'Action Condition Value2' Error.");
conditionDecodeError = true;
}
} catch (CerberusEventException cex) {
LOG.warn(cex);
}
}
if (!(conditionDecodeError)) {
conditionAnswer = this.conditionService.evaluateCondition(testCaseStepActionExecution.getConditionOper(), testCaseStepActionExecution.getConditionVal1(), testCaseStepActionExecution.getConditionVal2(), tcExecution);
boolean execute_Action = (boolean) conditionAnswer.getItem();
/**
* If condition OK or if manual execution, then execute the
* action
*/
if (conditionAnswer.getResultMessage().getMessage().getCodeString().equals("PE") || tcExecution.getManualExecution().equals("Y")) {
// Execute or not the action here.
if (execute_Action || tcExecution.getManualExecution().equals("Y")) {
LOG.debug("Executing action : " + testCaseStepActionExecution.getAction() + " with val1 : " + testCaseStepActionExecution.getValue1() + " and val2 : " + testCaseStepActionExecution.getValue2());
/**
* We execute the Action
*/
testCaseStepActionExecution = this.executeAction(testCaseStepActionExecution, tcExecution);
/**
* If Action or property reported to stop the testcase,
* we stop it and update the step with the message.
*/
testCaseStepExecution.setStopExecution(testCaseStepActionExecution.isStopExecution());
if ((!(testCaseStepActionExecution.getExecutionResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_OK)))) && (!(testCaseStepActionExecution.getExecutionResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTEXECUTING))))) {
testCaseStepExecution.setExecutionResultMessage(testCaseStepActionExecution.getExecutionResultMessage());
testCaseStepExecution.setStepResultMessage(testCaseStepActionExecution.getActionResultMessage());
}
if (testCaseStepActionExecution.isStopExecution()) {
break;
}
} else {
// We don't execute the action and record a generic execution.
/**
* Record Screenshot, PageSource
*/
testCaseStepActionExecution.addFileList(recorderService.recordExecutionInformationAfterStepActionandControl(testCaseStepActionExecution, null));
LOG.debug("Registering Action : " + testCaseStepActionExecution.getAction());
// We change the Action message only if the action is not executed due to condition.
MessageEvent actionMes = new MessageEvent(MessageEventEnum.CONDITION_TESTCASEACTION_NOTEXECUTED);
testCaseStepActionExecution.setActionResultMessage(actionMes);
testCaseStepActionExecution.setReturnMessage(testCaseStepActionExecution.getReturnMessage().replace("%COND%", testCaseStepActionExecution.getConditionOper()).replace("%MESSAGE%", conditionAnswer.getResultMessage().getDescription()));
testCaseStepActionExecution.setEnd(new Date().getTime());
this.testCaseStepActionExecutionService.updateTestCaseStepActionExecution(testCaseStepActionExecution);
LOG.debug("Registered Action");
}
} else {
// Error when performing the condition evaluation. We force no execution (false)
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITION);
mes.setDescription(mes.getDescription().replace("%COND%", testCaseStepActionExecution.getConditionOper()).replace("%AREA%", "action ").replace("%MES%", conditionAnswer.getResultMessage().getDescription()));
testCaseStepActionExecution.setExecutionResultMessage(mes);
testCaseStepExecution.setExecutionResultMessage(testCaseStepActionExecution.getExecutionResultMessage());
testCaseStepExecution.setStopExecution(testCaseStepActionExecution.isStopExecution());
testCaseStepActionExecution.setActionResultMessage(new MessageEvent(MessageEventEnum.CONDITION_TESTCASEACTION_FAILED).resolveDescription("AREA", "").resolveDescription("COND", testCaseStepActionExecution.getConditionOper()).resolveDescription("MESSAGE", conditionAnswer.getResultMessage().getDescription()));
testCaseStepExecution.setStepResultMessage(new MessageEvent(MessageEventEnum.CONDITION_TESTCASESTEP_FAILED).resolveDescription("AREA", "action ").resolveDescription("COND", testCaseStepActionExecution.getConditionOper()).resolveDescription("MESSAGE", conditionAnswer.getResultMessage().getDescription()));
testCaseStepActionExecution.setEnd(new Date().getTime());
this.testCaseStepActionExecutionService.updateTestCaseStepActionExecution(testCaseStepActionExecution);
LOG.debug("Action interupted due to condition error.");
// We stop any further Action execution.
break;
}
} else {
testCaseStepActionExecution.setEnd(new Date().getTime());
testCaseStepExecution.setExecutionResultMessage(testCaseStepActionExecution.getExecutionResultMessage());
testCaseStepExecution.setStepResultMessage(testCaseStepActionExecution.getActionResultMessage());
testCaseStepExecution.setStopExecution(testCaseStepActionExecution.isStopExecution());
this.testCaseStepActionExecutionService.updateTestCaseStepActionExecution(testCaseStepActionExecution);
LOG.debug("Registered Action");
if (testCaseStepActionExecution.isStopExecution()) {
break;
}
}
/**
* Log TestCaseStepActionExecution
*/
if (tcExecution.getVerbose() > 0) {
LOG.info(testCaseStepActionExecution.toJson(false, true));
}
}
testCaseStepExecution.setEnd(new Date().getTime());
this.testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);
// Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.
if (tcExecution.isCerberus_featureflipping_activatewebsocketpush()) {
TestCaseExecutionEndPoint.getInstance().send(tcExecution, false);
}
return testCaseStepExecution;
}
use of org.cerberus.crud.entity.TestCaseExecutionData in project cerberus-source by cerberustesting.
the class TestCaseExecutionDataService method readByIdWithDependency.
@Override
public AnswerList<TestCaseExecutionData> readByIdWithDependency(long id) {
AnswerList data = this.readByIdByCriteria(id, 0, 0, "exd.property", "asc", null, null);
AnswerList response = null;
List<TestCaseExecutionData> tcsaceList = new ArrayList();
for (Object mydata : data.getDataList()) {
TestCaseExecutionData tcsace = (TestCaseExecutionData) mydata;
AnswerList files = testCaseExecutionFileService.readByVarious(id, tcsace.getProperty() + "-" + tcsace.getIndex());
tcsace.setFileList((List<TestCaseExecutionFile>) files.getDataList());
tcsaceList.add(tcsace);
}
response = new AnswerList(tcsaceList, data.getTotalRows());
return response;
}
use of org.cerberus.crud.entity.TestCaseExecutionData in project cerberus-source by cerberustesting.
the class TestCaseExecutionService method readByKeyWithDependency.
@Override
public AnswerItem readByKeyWithDependency(long executionId) {
AnswerItem tce = this.readByKey(executionId);
TestCaseExecution testCaseExecution = (TestCaseExecution) tce.getItem();
AnswerItem<TestCase> ai = testCaseService.readByKeyWithDependency(testCaseExecution.getTest(), testCaseExecution.getTestCase());
testCaseExecution.setTestCaseObj(ai.getItem());
AnswerList a = testCaseExecutionDataService.readByIdWithDependency(executionId);
for (Object object : a.getDataList()) {
TestCaseExecutionData tced = (TestCaseExecutionData) object;
if (tced.getIndex() == 1) {
testCaseExecution.getTestCaseExecutionDataMap().put(tced.getProperty(), tced);
}
}
// We frist add the 'Pres Testing' testcase execution steps.
AnswerList preTestCaseSteps = testCaseStepExecutionService.readByVarious1WithDependency(executionId, "Pre Testing", null);
testCaseExecution.setTestCaseStepExecutionList(preTestCaseSteps.getDataList());
// Then we add the steps from the main testcase.
AnswerList steps = testCaseStepExecutionService.readByVarious1WithDependency(executionId, testCaseExecution.getTest(), testCaseExecution.getTestCase());
testCaseExecution.addTestCaseStepExecutionList(steps.getDataList());
AnswerList files = testCaseExecutionFileService.readByVarious(executionId, "");
testCaseExecution.setFileList((List<TestCaseExecutionFile>) files.getDataList());
AnswerItem response = new AnswerItem(testCaseExecution, tce.getResultMessage());
return response;
}
use of org.cerberus.crud.entity.TestCaseExecutionData in project cerberus-source by cerberustesting.
the class ActionService method doActionRemoveDifference.
private MessageEvent doActionRemoveDifference(TestCaseStepActionExecution testCaseStepActionExecution, String object, String property) {
// Filters differences from the given object pattern
String filteredDifferences = xmlUnitService.removeDifference(object, property);
// If filtered differences are null then service has returned with errors
if (filteredDifferences == null) {
MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_REMOVEDIFFERENCE);
message.setDescription(message.getDescription().replace("%DIFFERENCE%", object));
message.setDescription(message.getDescription().replace("%DIFFERENCES%", property));
return message;
}
// Sets the property value to the new filtered one
for (TestCaseExecutionData data : testCaseStepActionExecution.getTestCaseExecutionDataList()) {
if (data.getProperty().equals(testCaseStepActionExecution.getPropertyName())) {
data.setValue(filteredDifferences);
break;
}
}
// Sends success
MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_REMOVEDIFFERENCE);
message.setDescription(message.getDescription().replace("%DIFFERENCE%", object));
message.setDescription(message.getDescription().replace("%DIFFERENCES%", property));
return message;
}
Aggregations