How to use setLastServiceCalled method of org.cerberus.crud.entity.TestCaseExecution class

Best Cerberus-source code snippet using org.cerberus.crud.entity.TestCaseExecution.setLastServiceCalled

Source:ActionService.java Github

copy

Full Screen

...1353 lastServiceCalledAnswer = serviceService.callService(value1, value2, value3, null, null, null, null, tCExecution);1354 message = lastServiceCalledAnswer.getResultMessage();1355 if (lastServiceCalledAnswer.getItem() != null) {1356 AppService lastServiceCalled = (AppService) lastServiceCalledAnswer.getItem();1357 tCExecution.setLastServiceCalled(lastServiceCalled);1358 tCExecution.setOriginalLastServiceCalled(lastServiceCalled.getResponseHTTPBody());1359 tCExecution.setOriginalLastServiceCalledContent(lastServiceCalled.getResponseHTTPBodyContentType());1360 /**1361 * Record the Request and Response in file system.1362 */1363 testCaseStepActionExecution.addFileList(recorderService.recordServiceCall(tCExecution, testCaseStepActionExecution, 0, null, lastServiceCalled));1364 }1365 return message;1366 }1367 private MessageEvent doActionRemoveDifference(TestCaseStepActionExecution testCaseStepActionExecution, String object, String property) {1368 // Filters differences from the given object pattern1369 String filteredDifferences = xmlUnitService.removeDifference(object, property);1370 // If filtered differences are null then service has returned with errors1371 if (filteredDifferences == null) {1372 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_REMOVEDIFFERENCE);1373 message.setDescription(message.getDescription().replace("%DIFFERENCE%", object));1374 message.setDescription(message.getDescription().replace("%DIFFERENCES%", property));1375 return message;1376 }1377 // Sets the property value to the new filtered one1378 for (TestCaseExecutionData data : testCaseStepActionExecution.getTestCaseExecutionDataList()) {1379 if (data.getProperty().equals(testCaseStepActionExecution.getPropertyName())) {1380 data.setValue(filteredDifferences);1381 break;1382 }1383 }1384 // Sends success1385 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_REMOVEDIFFERENCE);1386 message.setDescription(message.getDescription().replace("%DIFFERENCE%", object));1387 message.setDescription(message.getDescription().replace("%DIFFERENCES%", property));1388 return message;1389 }1390 private MessageEvent doActionCalculateProperty(TestCaseStepActionExecution testCaseStepActionExecution, String value1, String value2) {1391 MessageEvent message;1392 AnswerItem<String> answerDecode = new AnswerItem<>();1393 if (StringUtil.isNullOrEmpty(value1)) {1394 // Value1 is a mandatory parameter.1395 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_MISSINGPROPERTY);1396 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY));1397 } else {1398 try {1399 TestCaseExecution tCExecution = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution();1400 // Getting the Country property definition.1401 TestCaseCountryProperties tccp = null;1402 boolean propertyExistOnAnyCountry = false;1403 for (TestCaseCountryProperties object : tCExecution.getTestCaseCountryPropertyList()) {1404 if ((object.getProperty().equalsIgnoreCase(value1)) && (object.getCountry().equalsIgnoreCase(tCExecution.getCountry()))) {1405 tccp = object;1406 }1407 if ((object.getProperty().equalsIgnoreCase(value1))) {1408 propertyExistOnAnyCountry = true;1409 }1410 }1411 if (tccp == null) { // Could not find a country property inside the existing execution.1412 if (propertyExistOnAnyCountry) {1413 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NO_PROPERTY_DEFINITION);1414 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1415 .replace("%PROP%", value1)1416 .replace("%COUNTRY%", tCExecution.getCountry()));1417 return message;1418 } else {1419 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_PROPERTYNOTFOUND);1420 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1421 .replace("%PROP%", value1)1422 .replace("%COUNTRY%", tCExecution.getCountry()));1423 return message;1424 }1425 } else {1426 if (!(StringUtil.isNullOrEmpty(value2))) {1427 // If value2 is fed with something, we control here that value is a valid property name and gets its defintion.1428 tccp = null;1429 propertyExistOnAnyCountry = false;1430 for (TestCaseCountryProperties object : tCExecution.getTestCaseCountryPropertyList()) {1431 if ((object.getProperty().equalsIgnoreCase(value2)) && (object.getCountry().equalsIgnoreCase(tCExecution.getCountry()))) {1432 tccp = object;1433 }1434 if ((object.getProperty().equalsIgnoreCase(value2))) {1435 propertyExistOnAnyCountry = true;1436 }1437 }1438 if (tccp == null) { // Could not find a country property inside the existing execution.1439 if (propertyExistOnAnyCountry) {1440 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NO_PROPERTY_DEFINITION);1441 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1442 .replace("%PROP%", value2)1443 .replace("%COUNTRY%", tCExecution.getCountry()));1444 return message;1445 } else {1446 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_PROPERTYNOTFOUND);1447 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1448 .replace("%PROP%", value2)1449 .replace("%COUNTRY%", tCExecution.getCountry()));1450 return message;1451 }1452 }1453 }1454 // We calculate the property here.1455 long now = new Date().getTime();1456 TestCaseExecutionData tcExeData;1457 tcExeData = factoryTestCaseExecutionData.create(tCExecution.getId(), tccp.getProperty(), 1, tccp.getDescription(), null, tccp.getType(),1458 tccp.getRank(), tccp.getValue1(), tccp.getValue2(), null, null, now, now, now, now, new MessageEvent(MessageEventEnum.PROPERTY_PENDING),1459 tccp.getRetryNb(), tccp.getRetryPeriod(), tccp.getDatabase(), tccp.getValue1(), tccp.getValue2(), tccp.getLength(), tccp.getLength(),1460 tccp.getRowLimit(), tccp.getNature(), "", "", "", "", "", "N");1461 tcExeData.setTestCaseCountryProperties(tccp);1462 propertyService.calculateProperty(tcExeData, tCExecution, testCaseStepActionExecution, tccp, true);1463 // Property message goes to Action message.1464 message = tcExeData.getPropertyResultMessage();1465 if (message.getCodeString().equals("OK")) {1466 // If Property calculated successfully we summarize the message to a shorter version.1467 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CALCULATEPROPERTY);1468 message.resolveDescription("VALUE", tcExeData.getValue());1469 message.resolveDescription("PROP", value1);1470 if (tcExeData.getDataLibRawData() != null) {1471 message.setDescription(message.getDescription() + " %NBROWS% row(s) with %NBSUBDATA% Subdata(s) calculated."1472 .replace("%NBROWS%", String.valueOf(tcExeData.getDataLibRawData().size()))1473 .replace("%NBSUBDATA%", String.valueOf(tcExeData.getDataLibRawData().get(0).size())));1474 }1475 }1476 if (!(StringUtil.isNullOrEmpty(value2))) {1477 // If value2 is fed we force the result to value1.1478 tcExeData.setProperty(value1);1479 }1480 //saves the result1481 try {1482 testCaseExecutionDataService.save(tcExeData, tCExecution.getSecrets());1483 LOG.debug("Adding into Execution data list. Property : '" + tcExeData.getProperty() + "' Index : '" + tcExeData.getIndex() + "' Value : '" + tcExeData.getValue() + "'");1484 tCExecution.getTestCaseExecutionDataMap().put(tcExeData.getProperty(), tcExeData);1485 if (tcExeData.getDataLibRawData() != null) { // If the property is a TestDataLib, we same all rows retreived in order to support nature such as NOTINUSe or RANDOMNEW.1486 for (int i = 1; i < (tcExeData.getDataLibRawData().size()); i++) {1487 now = new Date().getTime();1488 TestCaseExecutionData tcedS = factoryTestCaseExecutionData.create(tcExeData.getId(), tcExeData.getProperty(), (i + 1),1489 tcExeData.getDescription(), tcExeData.getDataLibRawData().get(i).get(""), tcExeData.getType(), tcExeData.getRank(), "", "",1490 tcExeData.getRC(), "", now, now, now, now, null, 0, 0, "", "", "", "", "", 0, "", "", "", "", "", "", "N");1491 testCaseExecutionDataService.save(tcedS, tCExecution.getSecrets());1492 }1493 }1494 } catch (CerberusException cex) {1495 LOG.error(cex.getMessage(), cex);1496 }1497 }1498 } catch (Exception ex) {1499 LOG.error(ex.toString(), ex);1500 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC).resolveDescription("DETAIL", ex.toString());1501 }1502 }1503 return message;1504 }1505 private MessageEvent doActionSetNetworkTrafficContent(TestCaseExecution exe, TestCaseStepActionExecution actionexe, String urlToFilter, String withResponseContent) throws IOException {1506 MessageEvent message;1507 try {1508 // Check that robot has executor activated1509 if (!"Y".equalsIgnoreCase(exe.getRobotExecutorObj().getExecutorProxyActive()) || StringUtil.isNullOrEmpty(exe.getRobotExecutorObj().getExecutorProxyHost())) {1510 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SETNETWORKTRAFFICCONTENT_ROBOTEXECUTORPROXYNOTACTIVATED);1511 message.setDescription(message.getDescription().replace("%ROBOT%", exe.getRobotExecutorObj().getRobot()).replace("%EXECUTOR%", exe.getRobotExecutorObj().getExecutor()));1512 return message;1513 }1514 LOG.debug("Getting Network Traffic content.");1515 Integer indexFrom = 0;1516 if (!exe.getNetworkTrafficIndexList().isEmpty()) {1517 // Take the value from the last entry.1518 indexFrom = exe.getNetworkTrafficIndexList().get(exe.getNetworkTrafficIndexList().size() - 1).getIndexRequestNb();1519 }1520 // We now get the har data.1521 boolean doWithResponse = ParameterParserUtil.parseBooleanParam(withResponseContent, false);1522 JSONObject har = executorService.getHar(urlToFilter, doWithResponse, exe.getRobotExecutorObj().getExecutorExtensionHost(), exe.getRobotExecutorObj().getExecutorExtensionPort(), exe.getRemoteProxyUUID(), exe.getSystem(), indexFrom);1523 har = harService.enrichWithStats(har, exe.getCountryEnvironmentParameters().getDomain(), exe.getSystem(), exe.getNetworkTrafficIndexList());1524 AppService appSrv = factoryAppService.create("", AppService.TYPE_REST, AppService.METHOD_HTTPGET, "", "", "", "", "", "", "", "", "", "", "", true, "", "", false, "", "", "", null, "", null, null);1525 appSrv.setResponseHTTPBody(har.toString());1526 appSrv.setResponseHTTPBodyContentType(AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON);1527 appSrv.setRecordTraceFile(false);1528 exe.setLastServiceCalled(appSrv);1529 /**1530 * Record the Request and Response in file system.1531 */1532 actionexe.addFileList(recorderService.recordNetworkTrafficContent(exe, actionexe, 0, null, appSrv, true));1533 // Forcing the apptype to SRV in order to allow all controls to plug to the json context of the har.1534 exe.setAppTypeEngine(Application.TYPE_SRV);1535 if (!exe.getNetworkTrafficIndexList().isEmpty()) {1536 // Message will include the index and request nb when the content start.1537 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SETNETWORKTRAFFICCONTENT).resolveDescription("INDEX", String.valueOf(exe.getNetworkTrafficIndexList().size())).resolveDescription("NBHITS", String.valueOf(indexFrom));1538 } else {1539 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SETNETWORKTRAFFICCONTENT_FROMINDEX0);1540 }1541 return message;1542 } catch (Exception ex) {1543 LOG.error("Error doing Action setNetworkTrafficContent :" + ex, ex);1544 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SETNETWORKTRAFFICCONTENT);1545 message.setDescription(message.getDescription().replace("%DETAIL%", ex.toString()));1546 return message;1547 }1548 }1549 private MessageEvent doActionIndexNetworkTraffic(TestCaseExecution exe, TestCaseStepActionExecution actionexe, String value1) throws IOException {1550 MessageEvent message;1551 try {1552 // Check that robot has executor activated1553 if (!"Y".equalsIgnoreCase(exe.getRobotExecutorObj().getExecutorProxyActive()) || StringUtil.isNullOrEmpty(exe.getRobotExecutorObj().getExecutorProxyHost())) {1554 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_INDEXNETWORKTRAFFIC_ROBOTEXECUTORPROXYNOTACTIVATED);1555 message.setDescription(message.getDescription().replace("%ROBOT%", exe.getRobotExecutorObj().getRobot()).replace("%EXECUTOR%", exe.getRobotExecutorObj().getExecutor()));1556 return message;1557 }1558 LOG.debug("Getting Network Traffic index");1559 /**1560 * Building the url to get the Latest index from cerberus-executor1561 */1562 Integer nbHits = executorService.getHitsNb(exe.getRobotExecutorObj().getExecutorExtensionHost(), exe.getRobotExecutorObj().getExecutorExtensionPort(), exe.getRemoteProxyUUID());1563 NetworkTrafficIndex nti = new NetworkTrafficIndex();1564 if (StringUtil.isNullOrEmpty(value1)) {1565 value1 = "INDEX" + (exe.getNetworkTrafficIndexList().size() + 1);1566 }1567 nti.setName(value1);1568 nti.setIndexRequestNb(nbHits);1569 exe.appendNetworkTrafficIndexList(nti);1570 LOG.debug("New Index : " + exe.getNetworkTrafficIndexList());1571 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_INDEXNETWORKTRAFFIC).resolveDescription("NB", nbHits.toString()).resolveDescription("INDEX", String.valueOf(exe.getNetworkTrafficIndexList().size()));1572 return message;1573 } catch (Exception ex) {1574 LOG.error("Error doing Action indexNetworkTraffic :" + ex, ex);1575 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_INDEXNETWORKTRAFFIC);1576 message.setDescription(message.getDescription().replace("%DETAIL%", ex.toString()));1577 return message;1578 }1579 }1580 private MessageEvent doActionSetConsoleContent(TestCaseExecution exe, TestCaseStepActionExecution actionexe, String textToFilter) throws IOException {1581 MessageEvent message;1582 try {1583 /**1584 * Building the url to get the Har file from cerberus-executor1585 */1586 LOG.debug("Getting Console Logs content.");1587 JSONObject consoleRecap = new JSONObject();1588 JSONArray consoleLogs = webdriverService.getJSONConsoleLog(exe.getSession());1589 consoleRecap.put("logs", consoleLogs);1590 JSONObject consoleStat = new JSONObject();1591 consoleStat = consolelogService.enrichWithStats(consoleLogs);1592 consoleRecap.put("stat", consoleStat);1593 AppService appSrv = factoryAppService.create("", "", "", "", "", "", "", "", "", "", "", "", "", "", false, "", "", false, "", null, "", null, "", null, "");1594 appSrv.setResponseHTTPBody(consoleRecap.toString());1595 appSrv.setResponseHTTPBodyContentType(AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON);1596 appSrv.setRecordTraceFile(false);1597 exe.setLastServiceCalled(appSrv);1598 /**1599 * Record the Request and Response in file system.1600 */1601 actionexe.addFileList(recorderService.recordConsoleContent(exe, actionexe, 0, null, consoleRecap, true));1602 // Forcing the apptype to SRV in order to allow all controls to plug to the json context of the har.1603 exe.setAppTypeEngine(Application.TYPE_SRV);1604 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SETCONSOLECONTENT);1605 return message;1606 } catch (Exception ex) {1607 LOG.error("Error doing Action setNetworkTrafficContent :" + ex);1608 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SETCONSOLECONTENT);1609 message.setDescription(message.getDescription().replace("%DETAIL%", ex.toString()));1610 return message;1611 }1612 }1613 private MessageEvent doActionSetContent(TestCaseExecution exe, TestCaseStepActionExecution actionexe, String textContent) throws IOException {1614 MessageEvent message;1615 try {1616 /**1617 * Building the url to get the Har file from cerberus-executor1618 */1619 LOG.debug("Setting static content.");1620 AppService appSrv = factoryAppService.create("", "", "", "", "", "", "", "", "", "", "", "", "", "", false, "", "", false, "", "", "", null, "", null, "");1621 appSrv.setResponseHTTPBody(textContent);1622 appSrv.setResponseHTTPBodyContentType(appServiceService.guessContentType(appSrv, AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON));1623 appSrv.setRecordTraceFile(false);1624 exe.setLastServiceCalled(appSrv);1625 /**1626 * Record the Request and Response in file system.1627 */1628 actionexe.addFileList(recorderService.recordContent(exe, actionexe, 0, null, textContent, appSrv.getResponseHTTPBodyContentType()));1629 // Forcing the apptype to SRV in order to allow all controls to plug to the json context of the har.1630 exe.setAppTypeEngine(Application.TYPE_SRV);1631 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SETCONTENT);1632 message.resolveDescription("TYPE", appSrv.getResponseHTTPBodyContentType());1633 return message;1634 } catch (Exception ex) {1635 LOG.error("Error doing Action setNetworkTrafficContent :" + ex);1636 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SETCONTENT);1637 message.setDescription(message.getDescription().replace("%DETAIL%", ex.toString()));1638 return message;...

Full Screen

Full Screen

setLastServiceCalled

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.service.ITestCaseExecutionService;3import org.springframework.beans.factory.annotation.Autowired;4import org.springframework.stereotype.Component;5public class MyCerberusBean {6 private ITestCaseExecutionService testCaseExecutionService;7 public String getLastServiceCalled(String test, String testCase, int testCaseExecutionId) {8 TestCaseExecution testCaseExecution = testCaseExecutionService.findTestCaseExecutionByKey(test, testCase, testCaseExecutionId);9 return testCaseExecution.getLastServiceCalled();10 }11}12import org.cerberus.crud.entity.TestCaseExecution;13import org.cerberus.crud.service.ITestCaseExecutionService;14import org.springframework.beans.factory.annotation.Autowired;15import org.springframework.stereotype.Component;16public class MyCerberusBean {17 private ITestCaseExecutionService testCaseExecutionService;18 public String getLastServiceCalled(String test, String testCase, int testCaseExecutionId) {19 TestCaseExecution testCaseExecution = testCaseExecutionService.findTestCaseExecutionByKey(test, testCase, testCaseExecutionId);20 return testCaseExecution.getLastServiceCalled();21 }22}23import org.cerberus.crud.entity.TestCaseExecution;24import org.cerberus.crud.service.ITestCaseExecutionService;25import org.springframework.beans.factory.annotation.Autowired;26import org.springframework.stereotype.Component;27public class MyCerberusBean {28 private ITestCaseExecutionService testCaseExecutionService;29 public String getLastServiceCalled(String test, String testCase, int testCaseExecutionId) {30 TestCaseExecution testCaseExecution = testCaseExecutionService.findTestCaseExecutionByKey(test, testCase, testCaseExecutionId);31 return testCaseExecution.getLastServiceCalled();32 }33}34import org.cerberus.crud.entity.TestCaseExecution;35import org.cerberus.crud.service.ITestCaseExecutionService;36import org.springframework.beans.factory.annotation.Autowired;37import org.springframework.stereotype.Component;38public class MyCerberusBean {39 private ITestCaseExecutionService testCaseExecutionService;40 public String getLastServiceCalled(String test, String testCase, int testCaseExecutionId) {

Full Screen

Full Screen

setLastServiceCalled

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import org.cerberus.crud.entity.TestCaseExecution;3public class TestCaseExecution {4 private String lastServiceCalled;5 public String getLastServiceCalled() {6 return lastServiceCalled;7 }8 public void setLastServiceCalled(String lastServiceCalled) {9 this.lastServiceCalled = lastServiceCalled;10 }11}12package org.cerberus.engine.execution.impl;13import org.apache.logging.log4j.LogManager;14import org.apache.logging.log4j.Logger;15import org.cerberus.crud.entity.Application;16import org.cerberus.crud.entity.TestCaseExecution;17import org.cerberus.crud.service.IApplicationService;18import org.cerberus.engine.entity.MessageEvent;19import org.cerberus.engine.entity.MessageGeneral;20import org.cerberus.engine.execution.IAfterService;21import org.cerberus.enums.MessageEventEnum;22import org.cerberus.enums.MessageGeneralEnum;23import org.cerberus.exception.CerberusEventException;24import org.cerberus.exception.CerberusException;25import org.cerberus.service.datalib.IDataLibService;26import org.cerberus.service.engine.IRecorderService;27import org.cerberus.service.engine.ISeleniumServerService;28import org.cerberus.service.engine.IVariableService;29import org.cerberus.util.answer.AnswerItem;30import org.springframework.beans.factory.annotation.Autowired;31import org.springframework.stereotype.Service;32public class AfterService implements IAfterService {33 private static final Logger LOG = LogManager.getLogger(AfterService.class);34 private IVariableService variableService;35 private IRecorderService recorderService;36 private ISeleniumServerService seleniumServerService;37 private IDataLibService dataLibService;38 private IApplicationService applicationService;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in TestCaseExecution

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful