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

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

Source:ControlService.java Github

copy

Full Screen

...472 } catch (WebDriverException exception) {473 return parseWebDriverException(exception);474 }475 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {476 if (tCExecution.getLastServiceCalled() != null) {477 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();478 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {479 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:480 if (xmlUnitService.isElementPresent(responseBody, elementPath)) {481 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);482 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));483 return mes;484 } else {485 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);486 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));487 return mes;488 }489 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {490 try {491 if (jsonService.getFromJson(responseBody, null, elementPath) != null) {492 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);493 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));494 return mes;495 } else {496 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);497 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));498 return mes;499 }500 } catch (Exception ex) {501 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);502 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));503 return mes;504 }505 }506 default:507 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);508 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));509 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementPresent"));510 return mes;511 }512 } else {513 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);514 return mes;515 }516 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {517 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator());518 } else {519 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);520 mes.setDescription(mes.getDescription().replace("%CONTROL%", "VerifyElementPresent"));521 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));522 return mes;523 }524 } else {525 return new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT_NULL);526 }527 }528 private MessageEvent verifyElementNotPresent(TestCaseExecution tCExecution, String elementPath) {529 LOG.debug("Control : verifyElementNotPresent on : " + elementPath);530 MessageEvent mes;531 if (!StringUtil.isNull(elementPath)) {532 Identifier identifier = identifierService.convertStringToIdentifier(elementPath);533 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)534 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)535 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {536 try {537 if (identifier.getIdentifier().equals("picture")) {538 return sikuliService.doSikuliVerifyElementNotPresent(tCExecution.getSession(), identifier.getLocator());539 } else if (!this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {540 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);541 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));542 return mes;543 } else {544 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);545 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));546 return mes;547 }548 } catch (WebDriverException exception) {549 return parseWebDriverException(exception);550 }551 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {552 return sikuliService.doSikuliVerifyElementNotPresent(tCExecution.getSession(), identifier.getLocator());553 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {554 if (tCExecution.getLastServiceCalled() != null) {555 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();556 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {557 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:558 if (!(xmlUnitService.isElementPresent(responseBody, elementPath))) {559 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);560 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));561 return mes;562 } else {563 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);564 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));565 return mes;566 }567 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {568 try {569 if (jsonService.getFromJson(responseBody, null, elementPath) == null) {570 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);571 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));572 return mes;573 } else {574 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);575 mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));576 return mes;577 }578 } catch (Exception ex) {579 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);580 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));581 return mes;582 }583 }584 default:585 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);586 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));587 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementNotPresent"));588 return mes;589 }590 } else {591 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);592 return mes;593 }594 } else {595 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);596 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementNotPresent"));597 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));598 return mes;599 }600 } else {601 return new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT_NULL);602 }603 }604 private MessageEvent verifyElementInElement(TestCaseExecution tCExecution, String element, String childElement) {605 if (LOG.isDebugEnabled()) {606 LOG.debug("Control : verifyElementInElement on : '" + element + "' is child of '" + childElement + "'");607 }608 MessageEvent mes;609 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)610 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {611 if (!StringUtil.isNull(element) && !StringUtil.isNull(childElement)) {612 try {613 Identifier identifier = identifierService.convertStringToIdentifier(element);614 Identifier childIdentifier = identifierService.convertStringToIdentifier(childElement);615 if (this.webdriverService.isElementInElement(tCExecution.getSession(), identifier, childIdentifier)) {616 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTINELEMENT);617 mes.setDescription(mes.getDescription().replace("%STRING2%", element).replace("%STRING1%", childElement));618 return mes;619 } else {620 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);621 mes.setDescription(mes.getDescription().replace("%STRING2%", element).replace("%STRING1%", childElement));622 return mes;623 }624 } catch (WebDriverException exception) {625 return parseWebDriverException(exception);626 }627 } else {628 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);629 mes.setDescription(mes.getDescription().replace("%STRING2%", element).replace("%STRING1%", childElement));630 return mes;631 }632 } else {633 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);634 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementInElement"));635 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));636 return mes;637 }638 }639 private MessageEvent verifyElementVisible(TestCaseExecution tCExecution, String html) {640 LOG.debug("Control : verifyElementVisible on : " + html);641 MessageEvent mes;642 if (!StringUtil.isNull(html)) {643 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)644 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)645 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {646 try {647 Identifier identifier = identifierService.convertStringToIdentifier(html);648 if (this.webdriverService.isElementVisible(tCExecution.getSession(), identifier)) {649 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_VISIBLE);650 mes.setDescription(mes.getDescription().replace("%STRING1%", html));651 return mes;652 } else {653 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE);654 mes.setDescription(mes.getDescription().replace("%STRING1%", html));655 return mes;656 }657 } catch (WebDriverException exception) {658 return parseWebDriverException(exception);659 }660 } else {661 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);662 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementVisible"));663 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));664 return mes;665 }666 } else {667 return new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE_NULL);668 }669 }670 private MessageEvent verifyElementNotVisible(TestCaseExecution tCExecution, String html) {671 LOG.debug("Control : verifyElementNotVisible on : " + html);672 MessageEvent mes;673 if (!StringUtil.isNull(html)) {674 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)675 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)676 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {677 try {678 Identifier identifier = identifierService.convertStringToIdentifier(html);679 if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {680 if (this.webdriverService.isElementNotVisible(tCExecution.getSession(), identifier)) {681 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTVISIBLE);682 mes.setDescription(mes.getDescription().replace("%STRING1%", html));683 return mes;684 } else {685 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE);686 mes.setDescription(mes.getDescription().replace("%STRING1%", html));687 return mes;688 }689 } else {690 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);691 mes.setDescription(mes.getDescription().replace("%STRING1%", html));692 return mes;693 }694 } catch (WebDriverException exception) {695 return parseWebDriverException(exception);696 }697 } else {698 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);699 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementNotVisible"));700 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));701 return mes;702 }703 } else {704 return new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE_NULL);705 }706 }707 private MessageEvent verifyElementEquals(TestCaseExecution tCExecution, String xpath, String expectedElement) {708 LOG.debug("Control : verifyElementEquals on : " + xpath + " expected Element : " + expectedElement);709 MessageEvent mes = null;710 // If case of not compatible application then exit with error711 if (!tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {712 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);713 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementEquals"));714 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));715 return mes;716 }717 // Check if element on the given xpath is equal to the given expected element718 if (tCExecution.getLastServiceCalled() != null) {719 String xmlResponse = tCExecution.getLastServiceCalled().getResponseHTTPBody();720 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {721 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:722 mes = xmlUnitService.isElementEquals(xmlResponse, xpath, expectedElement) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTEQUALS) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTEQUALS);723 mes.setDescription(mes.getDescription().replace("%XPATH%", xpath));724 mes.setDescription(mes.getDescription().replace("%EXPECTED_ELEMENT%", expectedElement));725 return mes;726 default:727 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);728 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));729 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementEquals"));730 return mes;731 }732 // TODO Give the actual element found into the description.733 } else {734 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);735 return mes;736 }737 }738 private MessageEvent verifyElementDifferent(TestCaseExecution tCExecution, String xpath, String differentElement) {739 LOG.debug("Control : verifyElementDifferent on : " + xpath + " expected Element : " + differentElement);740 MessageEvent mes = null;741 // If case of not compatible application then exit with error742 if (!tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {743 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);744 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementDifferent"));745 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));746 return mes;747 }748 // Check if element on the given xpath is different from the given different element749// SOAPExecution lastSoapCalled = (SOAPExecution) tCExecution.getLastSOAPCalled().getItem();750 if (tCExecution.getLastServiceCalled() != null) {751 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {752 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:753 String xmlResponse = tCExecution.getLastServiceCalled().getResponseHTTPBody();754 mes = xmlUnitService.isElementEquals(xmlResponse, xpath, differentElement) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTDIFFERENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTDIFFERENT);755 mes.setDescription(mes.getDescription().replace("%XPATH%", xpath));756 mes.setDescription(mes.getDescription().replace("%DIFFERENT_ELEMENT%", differentElement));757 return mes;758 default:759 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);760 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));761 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementDifferent"));762 return mes;763 }764 // TODO Give the actual element found into the description.765 } else {766 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);767 return mes;768 }769 }770 private MessageEvent verifyTextInElement(TestCaseExecution tCExecution, String path, String expected) {771 if (LOG.isDebugEnabled()) {772 LOG.debug("Control: verifyTextInElement on " + path + " element against value: " + expected);773 }774 // Get value from the path element according to the application type775 String actual = null;776 try {777 Identifier identifier = identifierService.convertStringToIdentifier(path);778 String applicationType = tCExecution.getApplicationObj().getType();779 if (Application.TYPE_GUI.equalsIgnoreCase(applicationType)780 || Application.TYPE_APK.equalsIgnoreCase(applicationType)781 || Application.TYPE_IPA.equalsIgnoreCase(applicationType)) {782 actual = webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);783 // In case of null actual value then we alert user784 if (actual == null) {785 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NULL);786 mes.setDescription(mes.getDescription().replace("%STRING1%", path));787 return mes;788 }789 // Construct the message from the actual response790 MessageEvent mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT);791 mes.setDescription(mes.getDescription().replace("%STRING1%", path));792 mes.setDescription(mes.getDescription().replace("%STRING2%", actual));793 mes.setDescription(mes.getDescription().replace("%STRING3%", expected));794 return mes;795 } else if (Application.TYPE_SRV.equalsIgnoreCase(applicationType)) {796 if (tCExecution.getLastServiceCalled() != null) {797 MessageEvent mes;798 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();799 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {800 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:801 if (!xmlUnitService.isElementPresent(responseBody, path)) {802 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);803 mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));804 return mes;805 }806 String newPath = StringUtil.addSuffixIfNotAlready(path, "/text()");807 actual = xmlUnitService.getFromXml(responseBody, newPath);808 // In case of null actual value then we alert user809 if (actual == null) {810 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NULL);811 mes.setDescription(mes.getDescription().replace("%STRING1%", path));812 return mes;813 }814 // Construct the message from the actual response815 mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT);816 mes.setDescription(mes.getDescription().replace("%STRING1%", path));817 mes.setDescription(mes.getDescription().replace("%STRING2%", actual));818 mes.setDescription(mes.getDescription().replace("%STRING3%", expected));819 return mes;820 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {821 try {822 actual = jsonService.getFromJson(responseBody, null, path);823 } catch (Exception ex) {824 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);825 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));826 return mes;827 }828 }829 // In case of null actual value then we alert user830 if (actual == null) {831 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);832 mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));833 return mes;834 }835 // Construct the message from the actual response836 mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT);837 mes.setDescription(mes.getDescription().replace("%STRING1%", path));838 mes.setDescription(mes.getDescription().replace("%STRING2%", actual));839 mes.setDescription(mes.getDescription().replace("%STRING3%", expected));840 return mes;841 default:842 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);843 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));844 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextInElement"));845 return mes;846 }847 // TODO Give the actual element found into the description.848 } else {849 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);850 return mes;851 }852 } else {853 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);854 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextInElement"));855 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));856 return mes;857 }858 } catch (NoSuchElementException exception) {859 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);860 mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));861 return mes;862 } catch (WebDriverException exception) {863 return parseWebDriverException(exception);864 }865 }866 private MessageEvent verifyTextNotInElement(TestCaseExecution tCExecution, String path, String expected) {867 if (LOG.isDebugEnabled()) {868 LOG.debug("Control: verifyTextNotInElement on " + path + " element against value: " + expected);869 }870 // Get value from the path element according to the application type871 String actual = null;872 try {873 Identifier identifier = identifierService.convertStringToIdentifier(path);874 String applicationType = tCExecution.getApplicationObj().getType();875 if (Application.TYPE_GUI.equalsIgnoreCase(applicationType)876 || Application.TYPE_APK.equalsIgnoreCase(applicationType)877 || Application.TYPE_IPA.equalsIgnoreCase(applicationType)) {878 actual = webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);879 // In case of null actual value then we alert user880 if (actual == null) {881 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT_NULL);882 mes.setDescription(mes.getDescription().replace("%STRING1%", path));883 return mes;884 }885 // Construct the message from the actual response886 MessageEvent mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTNOTINELEMENT);887 mes.setDescription(mes.getDescription().replace("%STRING1%", path));888 mes.setDescription(mes.getDescription().replace("%STRING2%", actual));889 mes.setDescription(mes.getDescription().replace("%STRING3%", expected));890 return mes;891 } else if (Application.TYPE_SRV.equalsIgnoreCase(applicationType)) {892 if (tCExecution.getLastServiceCalled() != null) {893 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();894 MessageEvent mes;895 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {896 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:897 if (!xmlUnitService.isElementPresent(responseBody, path)) {898 throw new NoSuchElementException("Unable to find element " + path);899 }900 String newPath = StringUtil.addSuffixIfNotAlready(path, "/text()");901 actual = xmlUnitService.getFromXml(responseBody, newPath);902 // In case of null actual value then we alert user903 if (actual == null) {904 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT_NULL);905 mes.setDescription(mes.getDescription().replace("%STRING1%", path));906 return mes;907 }908 // Construct the message from the actual response909 mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTNOTINELEMENT);910 mes.setDescription(mes.getDescription().replace("%STRING1%", path));911 mes.setDescription(mes.getDescription().replace("%STRING2%", actual));912 mes.setDescription(mes.getDescription().replace("%STRING3%", expected));913 return mes;914 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {915 try {916 actual = jsonService.getFromJson(responseBody, null, path);917 } catch (Exception ex) {918 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);919 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));920 return mes;921 }922 }923 // In case of null actual value then we alert user924 if (actual == null) {925 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);926 mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));927 return mes;928 }929 // Construct the message from the actual response930 mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTNOTINELEMENT);931 mes.setDescription(mes.getDescription().replace("%STRING1%", path));932 mes.setDescription(mes.getDescription().replace("%STRING2%", actual));933 mes.setDescription(mes.getDescription().replace("%STRING3%", expected));934 return mes;935 default:936 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);937 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));938 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextNotInElement"));939 return mes;940 }941 } else {942 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);943 return mes;944 }945 } else {946 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);947 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextNotInElement"));948 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));949 return mes;950 }951 } catch (NoSuchElementException exception) {952 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT_NO_SUCH_ELEMENT);953 mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));954 return mes;955 } catch (WebDriverException exception) {956 return parseWebDriverException(exception);957 }958 }959 private MessageEvent VerifyRegexInElement(TestCaseExecution tCExecution, String path, String regex) {960 LOG.debug("Control : verifyRegexInElement on : " + path + " element against value : " + regex);961 MessageEvent mes;962 String pathContent = null;963 try {964 Identifier identifier = identifierService.convertStringToIdentifier(path);965 String applicationType = tCExecution.getApplicationObj().getType();966 // Get value from the path element according to the application type967 if (Application.TYPE_GUI.equalsIgnoreCase(applicationType)968 || Application.TYPE_APK.equalsIgnoreCase(applicationType)969 || Application.TYPE_IPA.equalsIgnoreCase(applicationType)) {970 pathContent = this.webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);971 } else if (Application.TYPE_SRV.equalsIgnoreCase(applicationType)) {972 if (tCExecution.getLastServiceCalled() != null) {973 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();974 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {975 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:976 if (!xmlUnitService.isElementPresent(responseBody, path)) {977 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);978 mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));979 return mes;980 }981 String newPath = StringUtil.addSuffixIfNotAlready(path, "/text()");982 pathContent = xmlUnitService.getFromXml(responseBody, newPath);983 break;984 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON:985 try {986 pathContent = jsonService.getFromJson(responseBody, null, path);987 } catch (Exception ex) {988 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);989 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));990 return mes;991 }992 break;993 default:994 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);995 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));996 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyRegexInElement"));997 return mes;998 }999 // TODO Give the actual element found into the description.1000 } else {1001 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);1002 return mes;1003 }1004 } else {1005 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1006 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyRegexInElement"));1007 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1008 return mes;1009 }1010 LOG.debug("Control : verifyRegexInElement element : " + path + " has value : " + StringUtil.sanitize(pathContent));1011 if (path != null && pathContent != null) {1012 try {1013 Pattern pattern = Pattern.compile(regex);1014 Matcher matcher = pattern.matcher(pathContent);1015 if (matcher.find()) {1016 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_REGEXINELEMENT);1017 mes.setDescription(mes.getDescription().replace("%STRING1%", path));1018 mes.setDescription(mes.getDescription().replace("%STRING2%", StringUtil.sanitize(pathContent)));1019 mes.setDescription(mes.getDescription().replace("%STRING3%", regex));1020 return mes;1021 } else {1022 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT);1023 mes.setDescription(mes.getDescription().replace("%STRING1%", path));1024 mes.setDescription(mes.getDescription().replace("%STRING2%", StringUtil.sanitize(pathContent)));1025 mes.setDescription(mes.getDescription().replace("%STRING3%", regex));1026 return mes;1027 }1028 } catch (PatternSyntaxException e) {1029 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT_INVALIDPATERN);1030 mes.setDescription(mes.getDescription().replace("%PATERN%", regex));1031 mes.setDescription(mes.getDescription().replace("%ERROR%", e.getMessage()));1032 return mes;1033 }1034 } else if (pathContent != null) {1035 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT_NULL);1036 return mes;1037 } else {1038 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT_NO_SUCH_ELEMENT);1039 mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));1040 return mes;1041 }1042 } catch (NoSuchElementException exception) {1043 LOG.debug(exception.toString());1044 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT_NO_SUCH_ELEMENT);1045 mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));1046 return mes;1047 } catch (WebDriverException exception) {1048 return parseWebDriverException(exception);1049 }1050 }1051 private MessageEvent verifyTextInDialog(TestCaseExecution tCExecution, String property, String value) {1052 LOG.debug("Control : verifyTextInDialog against value : " + value);1053 MessageEvent mes;1054 if (Application.TYPE_GUI.equalsIgnoreCase(tCExecution.getApplicationObj().getType())) {1055 try {1056 String str = this.webdriverService.getAlertText(tCExecution.getSession());1057 LOG.debug("Control : verifyTextInAlertPopup has value : " + str);1058 if (str != null) {1059 String valueToTest = property;1060 if (valueToTest == null || "".equals(valueToTest.trim())) {1061 valueToTest = value;1062 }1063 if (str.trim().equalsIgnoreCase(valueToTest)) {1064 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTINALERT);1065 mes.setDescription(mes.getDescription().replace("%STRING1%", str));1066 mes.setDescription(mes.getDescription().replace("%STRING2%", valueToTest));1067 return mes;1068 } else {1069 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINALERT);1070 mes.setDescription(mes.getDescription().replace("%STRING1%", str));1071 mes.setDescription(mes.getDescription().replace("%STRING2%", valueToTest));1072 return mes;1073 }1074 } else {1075 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINALERT_NULL);1076 return mes;1077 }1078 } catch (WebDriverException exception) {1079 return parseWebDriverException(exception);1080 }1081 } else {1082 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1083 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextInDialog"));1084 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1085 return mes;1086 }1087 }1088 private MessageEvent VerifyTextInPage(TestCaseExecution tCExecution, String regex) {1089 LOG.debug("Control : verifyTextInPage on : " + regex);1090 MessageEvent mes;1091 if (Application.TYPE_GUI.equalsIgnoreCase(tCExecution.getApplicationObj().getType())1092 || Application.TYPE_APK.equalsIgnoreCase(tCExecution.getApplicationObj().getType())1093 || Application.TYPE_IPA.equalsIgnoreCase(tCExecution.getApplicationObj().getType())) {1094 String pageSource;1095 try {1096 pageSource = this.webdriverService.getPageSource(tCExecution.getSession());1097 if (LOG.isDebugEnabled()) {1098 LOG.debug(pageSource);1099 }1100 try {1101 Pattern pattern = Pattern.compile(regex);1102 Matcher matcher = pattern.matcher(pageSource);1103 if (matcher.find()) {1104 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTINPAGE);1105 mes.setDescription(mes.getDescription().replace("%STRING1%", Pattern.quote(regex)));1106 return mes;1107 } else {1108 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINPAGE);1109 mes.setDescription(mes.getDescription().replace("%STRING1%", Pattern.quote(regex)));1110 return mes;1111 }1112 } catch (PatternSyntaxException e) {1113 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINPAGE_INVALIDPATERN);1114 mes.setDescription(mes.getDescription().replace("%PATERN%", Pattern.quote(regex)));1115 mes.setDescription(mes.getDescription().replace("%ERROR%", e.getMessage()));1116 return mes;1117 }1118 } catch (WebDriverException exception) {1119 return parseWebDriverException(exception);1120 }1121 } else if (Application.TYPE_FAT.equalsIgnoreCase(tCExecution.getApplicationObj().getType())) {1122 return sikuliService.doSikuliVerifyTextInPage(tCExecution.getSession(), regex);1123 } else {1124 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1125 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextInPage"));1126 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1127 return mes;1128 }1129 }1130 private MessageEvent VerifyTextNotInPage(TestCaseExecution tCExecution, String regex) {1131 LOG.debug("Control : VerifyTextNotInPage on : " + regex);1132 MessageEvent mes;1133 if (Application.TYPE_GUI.equalsIgnoreCase(tCExecution.getApplicationObj().getType())1134 || Application.TYPE_APK.equalsIgnoreCase(tCExecution.getApplicationObj().getType())1135 || Application.TYPE_IPA.equalsIgnoreCase(tCExecution.getApplicationObj().getType())) {1136 String pageSource;1137 try {1138 pageSource = this.webdriverService.getPageSource(tCExecution.getSession());1139 if (LOG.isDebugEnabled()) {1140 LOG.debug(pageSource);1141 }1142 try {1143 Pattern pattern = Pattern.compile(regex);1144 Matcher matcher = pattern.matcher(pageSource);1145 if (!(matcher.find())) {1146 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTNOTINPAGE);1147 mes.setDescription(mes.getDescription().replace("%STRING1%", Pattern.quote(regex)));1148 return mes;1149 } else {1150 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINPAGE);1151 mes.setDescription(mes.getDescription().replace("%STRING1%", Pattern.quote(regex)));1152 return mes;1153 }1154 } catch (PatternSyntaxException e) {1155 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINPAGE_INVALIDPATERN);1156 mes.setDescription(mes.getDescription().replace("%PATERN%", Pattern.quote(regex)));1157 mes.setDescription(mes.getDescription().replace("%ERROR%", e.getMessage()));1158 return mes;1159 }1160 } catch (WebDriverException exception) {1161 return parseWebDriverException(exception);1162 }1163 } else {1164 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1165 mes.setDescription(mes.getDescription().replace("%CONTROL%", "VerifyTextNotInPage"));1166 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1167 return mes;1168 }1169 }1170 private MessageEvent verifyUrl(TestCaseExecution tCExecution, String value1) throws CerberusEventException {1171 LOG.debug("Control : verifyUrl on : " + value1);1172 if (Application.TYPE_GUI.equalsIgnoreCase(tCExecution.getApplicationObj().getType())) {1173 MessageEvent mes;1174 try {1175 String url = this.webdriverService.getCurrentUrl(tCExecution.getSession(), tCExecution.getUrl());1176 // Control is made forcing the / at the beginning of URL. getCurrentUrl from Selenium 1177 // already have that control but value1 is specified by user and could miss it.1178 String controlUrl = StringUtil.addPrefixIfNotAlready(value1, "/");1179 if (url.equalsIgnoreCase(controlUrl)) {1180 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_URL);1181 mes.setDescription(mes.getDescription().replace("%STRING1%", url));1182 mes.setDescription(mes.getDescription().replace("%STRING2%", controlUrl));1183 return mes;1184 } else {1185 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_URL);1186 mes.setDescription(mes.getDescription().replace("%STRING1%", url));1187 mes.setDescription(mes.getDescription().replace("%STRING2%", controlUrl));1188 return mes;1189 }1190 } catch (WebDriverException exception) {1191 return parseWebDriverException(exception);1192 }1193 } else {1194 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1195 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyUrl"));1196 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1197 return mes;1198 }1199 }1200 private MessageEvent verifyTitle(TestCaseExecution tCExecution, String title) {1201 LOG.debug("Control : verifyTitle on : " + title);1202 MessageEvent mes;1203 if (Application.TYPE_GUI.equalsIgnoreCase(tCExecution.getApplicationObj().getType())) {1204 try {1205 String pageTitle = this.webdriverService.getTitle(tCExecution.getSession());1206 if (pageTitle.equalsIgnoreCase(title)) {1207 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TITLE);1208 mes.setDescription(mes.getDescription().replace("%STRING1%", pageTitle));1209 mes.setDescription(mes.getDescription().replace("%STRING2%", title));1210 return mes;1211 } else {1212 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TITLE);1213 mes.setDescription(mes.getDescription().replace("%STRING1%", pageTitle));1214 mes.setDescription(mes.getDescription().replace("%STRING2%", title));1215 return mes;1216 }1217 } catch (WebDriverException exception) {1218 return parseWebDriverException(exception);1219 }1220 } else {1221 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1222 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTitle"));1223 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1224 return mes;1225 }1226 }1227 private MessageEvent verifyXmlTreeStructure(TestCaseExecution tCExecution, String controlProperty, String controlValue) {1228 LOG.debug("Control : verifyXmlTreeStructure on : " + controlProperty);1229 MessageEvent mes;1230 if (Application.TYPE_SRV.equalsIgnoreCase(tCExecution.getApplicationObj().getType())) {1231 try {1232 if (tCExecution.getLastServiceCalled() != null) {1233 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {1234 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:1235 String xmlResponse = tCExecution.getLastServiceCalled().getResponseHTTPBody();1236 if (this.xmlUnitService.isSimilarTree(xmlResponse, controlProperty, controlValue)) {1237 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_SIMILARTREE);1238 mes.setDescription(mes.getDescription().replace("%STRING1%", StringUtil.sanitize(controlProperty)));1239 mes.setDescription(mes.getDescription().replace("%STRING2%", StringUtil.sanitize(controlValue)));1240 return mes;1241 } else {1242 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_SIMILARTREE);1243 mes.setDescription(mes.getDescription().replace("%STRING1%", StringUtil.sanitize(controlProperty)));1244 mes.setDescription(mes.getDescription().replace("%STRING2%", StringUtil.sanitize(controlValue)));1245 return mes;1246 }1247 default:1248 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);1249 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));1250 mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyXmlTreeStructure"));1251 return mes;1252 }1253 } else {1254 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);1255 return mes;1256 }1257 } catch (Exception exception) {1258 LOG.fatal(exception.toString());1259 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED);1260 return mes;1261 }1262 } else {1263 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);...

Full Screen

Full Screen

Source:VariableService.java Github

copy

Full Screen

...318 }319 /**320 * Last Service Called Variables.321 */322 if (!(execution.getLastServiceCalled() == null)) {323 stringToDecode = stringToDecode.replace("%system.LASTSERVICE_HTTPCODE%", String.valueOf(execution.getLastServiceCalled().getResponseHTTPCode()));324 stringToDecode = stringToDecode.replace("%system.LASTSERVICE_CALL%", execution.getLastServiceCalled().toJSONOnDefaultExecution().toString());325 if (!(execution.getLastServiceCalled().getResponseHTTPBody() == null)) {326 stringToDecode = stringToDecode.replace("%system.LASTSERVICE_RESPONSE%", execution.getLastServiceCalled().getResponseHTTPBody());327 } else {328 stringToDecode = stringToDecode.replace("%system.LASTSERVICE_RESPONSE%", VALUE_WHEN_NULL);329 }330 } else {331 stringToDecode = stringToDecode.replace("%system.LASTSERVICE_HTTPCODE%", VALUE_WHEN_NULL);332 stringToDecode = stringToDecode.replace("%system.LASTSERVICE_CALL%", VALUE_WHEN_NULL);333 stringToDecode = stringToDecode.replace("%system.LASTSERVICE_RESPONSE%", VALUE_WHEN_NULL);334 }335 if (!(execution.getLastServiceCalled() == null)) {336 stringToDecode = stringToDecode.replace("%SYS_LASTSERVICE_HTTPCODE%", String.valueOf(execution.getLastServiceCalled().getResponseHTTPCode()));337 stringToDecode = stringToDecode.replace("%SYS_LASTSERVICE_CALL%", execution.getLastServiceCalled().toJSONOnDefaultExecution().toString());338 if (!(execution.getLastServiceCalled().getResponseHTTPBody() == null)) {339 stringToDecode = stringToDecode.replace("%SYS_LASTSERVICE_RESPONSE%", execution.getLastServiceCalled().getResponseHTTPBody());340 } else {341 stringToDecode = stringToDecode.replace("%SYS_LASTSERVICE_RESPONSE%", VALUE_WHEN_NULL);342 }343 } else {344 stringToDecode = stringToDecode.replace("%SYS_LASTSERVICE_HTTPCODE%", VALUE_WHEN_NULL);345 stringToDecode = stringToDecode.replace("%SYS_LASTSERVICE_CALL%", VALUE_WHEN_NULL);346 stringToDecode = stringToDecode.replace("%SYS_LASTSERVICE_RESPONSE%", VALUE_WHEN_NULL);347 }348 /**349 * Trying to replace date variables .350 */351 stringToDecode = stringToDecode.replace("%SYS_TODAY-yyyy%", DateUtil.getTodayFormat("yyyy"));352 stringToDecode = stringToDecode.replace("%SYS_TODAY-MM%", DateUtil.getTodayFormat("MM"));353 stringToDecode = stringToDecode.replace("%SYS_TODAY-dd%", DateUtil.getTodayFormat("dd"));...

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.service.impl;2import java.util.List;3import org.cerberus.crud.entity.TestCaseExecution;4import org.cerberus.crud.service.ITestCaseExecutionService;5import org.cerberus.engine.entity.MessageEvent;6import org.cerberus.engine.entity.MessageGeneral;7import org.cerberus.engine.execution.IRecorderService;8import org.cerberus.engine.execution.impl.RecorderService;9import org.cerberus.engine.queuemanagement.IExecutionThreadPoolService;10import org.cerberus.engine.queuemanagement.IExecutionThreadPoolServiceFactory;11import org.cerberus.engine.queuemanagement.entity.ExecutionThreadPoolService;12import org.cerberus.engine.queuemanagement.entity.ExecutionThreadPoolServiceFactory;13import org.cerberus.exception.CerberusException;14import org.cerberus.log.MyLogger;15import org.cerberus.util.answer.Answer;16import org.cerberus.util.answer.AnswerItem;17import org.cerberus.util.answer.AnswerList;18import org.springframework.beans.factory.annotation.Autowired;19import org.springframework.stereotype.Service;20public class TestCaseExecutionService implements ITestCaseExecutionService {21 private IRecorderService recorderService;22 private IExecutionThreadPoolServiceFactory executionThreadPoolServiceFactory;23 public AnswerList<TestCaseExecution> readByVarious1(String test, String testCase, String country, String environment, String build, String revision) {24 }25 public AnswerList<TestCaseExecution> readByVarious2(String test, String testCase, String country, String environment, String build, String revision, int start, int amount, String column, String dir, String searchTerm, String individualSearch) {26 }27 public AnswerItem<TestCaseExecution> readByKey(long id) {28 }29 public Answer create(TestCaseExecution object) {30 try {31 recorderService.recordTestCaseExecution(object);32 return new Answer(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.Date;3public class TestCaseExecution {4 private long id;5 private String test;6 private String testCase;7 private String country;8 private String environment;9 private String browser;10 private String browserFullVersion;11 private String platform;12 private String version;13 private String revision;14 private String status;15 private String controlStatus;16 private String controlMessage;17 private String application;18 private String ip;19 private String url;20 private String urlLogin;21 private String tag;22 private String verbose;23 private String screenshot;24 private String pageSource;25 private String seleniumLog;26 private String robotLog;27 private String robotHost;28 private String robotPort;29 private String robotDecli;30 private String robotExecutor;31 private String robotBrowser;32 private String robotPlatform;33 private String robotScreenSize;34 private String robotCapabilities;35 private String robotOutputVideo;36 private String robotOutputLog;37 private String robotOutputFolder;38 private String robotOutputRessource;39 private String description;40 private String userAgent;41 private String browserVersion;42 private String browserMajorVersion;43 private String browserMinorVersion;44 private String browserSize;45 private String browserSizeWidth;46 private String browserSizeHeight;47 private String browserSizeDepth;48 private String browserSizeOrientation;49 private String browserSizeOrientationAngle;50 private String browserSizeOrientationType;51 private String browserSizeOrientationIsPrimary;52 private String browserSizeOrientationIsDefault;53 private String browserSizeOrientationIsPortraitPrimary;54 private String browserSizeOrientationIsLandscapePrimary;55 private String browserSizeOrientationIsPortrait;56 private String browserSizeOrientationIsLandscape;57 private String browserSizeOrientationIsSquare;58 private String browserSizeOrientationIsUndefined;59 private String browserSizeOrientationPlatform;60 private String browserSizeOrientationPlatformType;61 private String browserSizeOrientationPlatformVersion;62 private String browserSizeOrientationPlatformVendor;63 private String browserSizeOrientationPlatformVendorName;64 private String browserSizeOrientationPlatformVendorCodeName;65 private String browserSizeOrientationPlatformVendorProduct;66 private String browserSizeOrientationPlatformVendorProductVersion;67 private String browserSizeOrientationPlatformVendorProductBuildId;68 private String browserSizeOrientationPlatformVendorProductBuildDate;69 private String browserSizeOrientationPlatformVendorProductBuildType;

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.Date;3public class TestCaseExecution {4 private String test;5 private String testCase;6 private int id;7 private String build;8 private String revision;9 private String environment;10 private String country;11 private String controlStatus;12 private String controlMessage;13 private String application;14 private String ip;15 private String url;16 private String port;17 private String browser;18 private String browserFullVersion;19 private String browserVersion;20 private String platform;21 private String screenSize;22 private String userAgent;23 private String seleniumIP;24 private String seleniumPort;25 private String seleniumLogPath;26 private String tag;27 private String verbose;28 private String timeout;29 private String manualExecution;30 private String pageSource;31 private String seleniumLog;32 private String screenshot;33 private String pageSourceFile;34 private String screenshotFile;35 private String seleniumLogfile;36 private String robotLogfile;37 private String robotHost;38 private String robotPort;39 private String robotDecli;40 private String robotPlatform;41 private String robotBrowser;42 private String robotBrowserVersion;43 private String robotScreenSize;44 private String robotSeleniumLogPath;45 private String robotTimeout;46 private String robotVerbose;47 private String robotOutputDirectory;48 private String robotLogFile;49 private String robotReportFile;50 private String robotReportURL;51 private String robotOutputURL;52 private String robotExecutor;53 private String robotExecutorIP;54 private String robotExecutorPort;55 private String robotExecutorContextRoot;56 private String robotExecutorVersion;57 private String robotExecutorRevision;58 private String robotExecutorQueueID;59 private String robotExecutorBuild;60 private String robotExecutorCountry;61 private String robotExecutorEnvironment;62 private String robotExecutorControlStatus;63 private String robotExecutorControlMessage;64 private String robotExecutorStart;65 private String robotExecutorEnd;66 private String robotExecutorTimeElapsed;67 private String robotExecutorTimeTotal;68 private String robotExecutorTimeToWait;69 private String robotExecutorTimeToWaitForNextExe;70 private String robotExecutorTimeToWaitForNextExeAfterManual;71 private String robotExecutorTimeToWaitForNextExeAfterError;72 private String robotExecutorTimeToWaitForNextExeAfterWarning;

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.Date;3import org.cerberus.crud.entity.TestCaseExecution;4public class TestCaseExecution {5 private long id;6 private String test;7 private String testCase;8 private String build;9 private String revision;10 private String environment;11 private String country;12 private String browser;13 private String version;14 private String platform;15 private String browserfullversion;16 private String browserVersion;17 private String browserMajor;18 private String browserMinor;19 private String screenSize;20 private String robot;21 private String robotDecli;22 private String robotHost;23 private String robotPort;24 private String robotPlatform;25 private String robotBrowser;26 private String robotBrowserVersion;27 private String tag;28 private String verbose;29 private String timeout;30 private String pageSource;31 private String seleniumLog;32 private String screenshot;33 private String manualURL;34 private String manualExecution;35 private String myHost;36 private String myContextRoot;37 private String myLoginRelativeURL;38 private String myEnvData;39 private String seleniumIP;40 private String seleniumPort;41 private String seleniumLogPath;42 private String screenshotPath;43 private String pageSourcePath;44 private String outputFormat;45 private String controlStatus;46 private String controlMessage;47 private String state;48 private String stateCode;49 private String controlProperty;50 private String controlValue;51 private String application;52 private String start;53 private String end;54 private String queueId;55 private String userAgent;56 private String screenSizeHeight;57 private String screenSizeWidth;58 private String screenSizeDepth;59 private String screenSizeOrientation;60 private String screenSizePixelDepth;61 private String screenSizeColorDepth;62 private String screenSizeAvailableHeight;63 private String screenSizeAvailableWidth;64 private String screenSizeInnerHeight;65 private String screenSizeInnerWidth;66 private String screenSizeOuterHeight;67 private String screenSizeOuterWidth;68 private String screenSizePageXOffset;69 private String screenSizePageYOffset;70 private String screenSizeScreenX;71 private String screenSizeScreenY;72 private String screenSizeScrollX;73 private String screenSizeScrollY;74 private String screenSizeScreenLeft;75 private String screenSizeScreenTop;76 private String screenSizeAvailHeight;77 private String screenSizeAvailWidth;78 private String screenSizeAvailLeft;79 private String screenSizeAvailTop;

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.entity.TestCaseExecution;3import org.cerberus.service.engine.IExecutionService;4import org.springframework.beans.factory.annotation.Autowired;5import org.springframework.stereotype.Service;6import org.springframework.web.context.support.SpringBeanAutowiringSupport;7public class 3 extends SpringBeanAutowiringSupport {8 private IExecutionService executionService;9 private TestCaseExecution tCExecution = new TestCaseExecution();10 public TestCaseExecution gettCExecution() {11 return tCExecution;12 }13 public void settCExecution(TestCaseExecution tCExecution) {14 this.tCExecution = tCExecution;15 }16 public String getLastServiceCalled() {17 return tCExecution.getLastServiceCalled();18 }19}20import org.cerberus.crud.entity.TestCaseExecution;21import org.cerberus.crud.entity.TestCaseExecution;22import org.cerberus.service.engine.IExecutionService;23import org.springframework.beans.factory.annotation.Autowired;24import org.springframework.stereotype.Service;25import org.springframework.web.context.support.SpringBeanAutowiringSupport;26public class 1 extends SpringBeanAutowiringSupport {27 private IExecutionService executionService;28 private TestCaseExecution tCExecution = new TestCaseExecution();29 public TestCaseExecution gettCExecution() {30 return tCExecution;31 }32 public void settCExecution(TestCaseExecution tCExecution) {33 this.tCExecution = tCExecution;34 }35 public String getLastServiceCalled() {36 return tCExecution.getLastServiceCalled();37 }38}39import org.cerberus.crud.entity.TestCaseExecution;40import org.cerberus.crud.entity.TestCaseExecution;41import org.cerberus.service.engine.IExecutionService;42import org.springframework.beans.factory.annotation.Autowired;43import org.springframework.stereotype.Service;44import org.springframework.web.context.support.SpringBeanAutowiringSupport;45public class 2 extends SpringBeanAutowiringSupport {46 private IExecutionService executionService;47 private TestCaseExecution tCExecution = new TestCaseExecution();48 public TestCaseExecution gettCExecution() {49 return tCExecution;50 }51 public void settCExecution(TestCaseExecution tCExecution) {

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import org.cerberus.crud.entity.TestCaseExecution;3import java.util.Date;4import java.util.List;5public class TestCaseExecution {6 private long id;7 private String test;8 private String testCase;9 private String country;10 private String environment;11 private String browser;12 private String browserVersion;13 private String platform;14 private String controlStatus;15 private String controlMessage;16 private String application;17 private String ip;18 private String url;19 private String tag;20 private String crbVersion;21 private String executor;22 private String robot;23 private String robotDecli;24 private String robotIP;25 private String robotPort;26 private String screenshotURL;27 private String videoURL;28 private String pageSourceURL;29 private String manualExecution;30 private Date start;31 private Date end;32 private String state;33 private String verbose;34 private String screenshot;35 private String pageSource;36 private String timeout;37 private String retries;38 private String manualURL;39 private String manualHost;40 private String manualContextRoot;41 private String manualLoginRelativeURL;42 private String manualEnvData;43 private String seleniumIP;44 private String seleniumPort;45 private String seleniumLogPath;46 private String seleniumLogLevel;47 private String description;48 private String usrCreated;49 private Date dateCreated;50 private String usrModif;51 private Date dateModif;52 private String build;53 private String revision;54 private String chain;55 private String status;56 private String statusMessage;57 private String controlStatusMessage;58 private Date controlExecutionTime;59 private String controlExecutionTimeStr;60 private String controlExecutionTimeStrLong;61 private Date startLong;62 private Date endLong;63 private String startLongStr;64 private String endLongStr;65 private String startStr;66 private String endStr;67 private String startStrLong;68 private String endStrLong;69 private String startStrLongShort;70 private String endStrLongShort;71 private String startStrShort;72 private String endStrShort;73 private String startStrShortShort;74 private String endStrShortShort;75 private String startStrLongShortShort;76 private String endStrLongShortShort;77 private String startStrShortShort;78 private String endStrShortShort;

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseExecution;2public class 3{3 public static void main(String args[]){4 TestCaseExecution tce = new TestCaseExecution();5 System.out.println(tce.getLastServiceCalled());6 }7}8import org.cerberus.crud.entity.TestCaseExecution;9public class 4{10 public static void main(String args[]){11 TestCaseExecution tce = new TestCaseExecution();12 System.out.println(tce.getLastServiceCalled());13 }14}15import org.cerberus.crud.entity.TestCaseExecution;16public class 5{17 public static void main(String args[]){18 TestCaseExecution tce = new TestCaseExecution();19 System.out.println(tce.getLastServiceCalled());20 }21}22import org.cerberus.crud.entity.TestCaseExecution;23public class 6{24 public static void main(String args[]){25 TestCaseExecution tce = new TestCaseExecution();26 System.out.println(tce.getLastServiceCalled

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1package com.cerberus.crud.service;2import com.cerberus.crud.entity.TestCaseExecution;3import java.util.ArrayList;4public class TestCaseExecutionService {5 public static void main(String[] args) {6 TestCaseExecution testCaseExecution = new TestCaseExecution();7 ArrayList<String> serviceList = new ArrayList<String>();8 serviceList.add("Service1");9 serviceList.add("Service2");10 serviceList.add("Service3");11 serviceList.add("Service4");12 serviceList.add("Service5");13 testCaseExecution.setServiceList(serviceList);14 System.out.println(testCaseExecution.getLastServiceCalled());15 }16}17package com.cerberus.crud.service;18import com.cerberus.crud.entity.TestCaseExecution;19import java.util.ArrayList;20public class TestCaseExecutionService {21 public static void main(String[] args) {22 TestCaseExecution testCaseExecution = new TestCaseExecution();23 System.out.println(testCaseExecution.getCountryFromIp("

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1package com.cerberus.service;2import com.cerberus.crud.entity.TestCaseExecution;3public class Service {4public static void main(String[] args) {5 TestCaseExecution tce = new TestCaseExecution();6 tce.setLastServiceCalled("get");7 String lastServiceCalled = tce.getLastServiceCalled();8 System.out.println(lastServiceCalled);9}10}11package com.cerberus.service;12import com.cerberus.crud.entity.TestCaseExecution;13public class Service {14public static void main(String[] args) {15 TestCaseExecution tce = new TestCaseExecution();16 tce.setLastServiceCalled("post");17 String lastServiceCalled = tce.getLastServiceCalled();18 System.out.println(lastServiceCalled);19}20}21package com.cerberus.service;22import com.cerberus.crud.entity.TestCaseExecution;23public class Service {24public static void main(String[] args) {25 TestCaseExecution tce = new TestCaseExecution();26 tce.setMyHost("localhost");27 String myHost = tce.getMyHost();28 System.out.println(myHost);29}30}31package com.cerberus.service;32import com.cerberus.crud.entity.TestCaseExecution;33public class Service {34public static void main(String[] args) {35 TestCaseExecution tce = new TestCaseExecution();36 tce.setMyHost("

Full Screen

Full Screen

getLastServiceCalled

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.entity.TestCaseExecutionData;3TestCaseExecution tce = new TestCaseExecution();4String lastServiceCalled = tce.getLastServiceCalled();5TestCaseExecutionData tced = new TestCaseExecutionData();6String lastServiceCalledProperties = tced.getLastServiceCalledProperties(lastServiceCalled);7String lastServiceCalledProperty = tced.getLastServiceCalledProperty(lastServiceCalledProperties, "property");8import org.cerberus.crud.entity.TestCaseExecution;9import org.cerberus.crud.entity.TestCaseExecutionData;10TestCaseExecution tce = new TestCaseExecution();11String lastServiceCalled = tce.getLastServiceCalled();12TestCaseExecutionData tced = new TestCaseExecutionData();13String lastServiceCalledProperties = tced.getLastServiceCalledProperties(lastServiceCalled);14String lastServiceCalledProperty = tced.getLastServiceCalledProperty(lastServiceCalledProperties, "property");

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