Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.RecorderService.recordTestDataLibProperty
Source:PropertyService.java
...748 testCaseExecutionData.setDataLibRawData(result);749 // Adding secrets if property looks like a password750 addPropertyASecret(testCaseExecutionData, execution);751 //Record result in filessytem.752 recorderService.recordTestDataLibProperty(execution.getId(), testCaseCountryProperty.getProperty(), 1, result, execution.getSecrets());753 }754 }755 } catch (CerberusEventException ex) {756 LOG.error(ex.toString(), ex);757 testCaseExecutionData.setEnd(new Date().getTime());758 testCaseExecutionData.setPropertyResultMessage(ex.getMessageError());759 }760 testCaseExecutionData.setEnd(new Date().getTime());761 if (LOG.isDebugEnabled()) {762 LOG.debug("Finished to calculate Property : '" + testCaseCountryProperty.getProperty() + "'");763 }764 }765 private void addPropertyASecret(TestCaseExecutionData executionData, TestCaseExecution execution) {766 if (executionData.getProperty().contains("PASSW")) {767 execution.appendSecret(executionData.getValue());768 }769 }770 private TestCaseExecutionData property_getFromCommand(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceRecalculation) {771 // Check if script has been correctly defined772 String script = testCaseExecutionData.getValue1();773 if (script == null || script.isEmpty()) {774 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMCOMMAND_NULL));775 return testCaseExecutionData;776 }777 // Try to evaluate Command script778 try {779 if (tCExecution.getAppTypeEngine().equals(Application.TYPE_APK)) {780 String message = androidAppiumService.executeCommandString(tCExecution.getSession(), script, testCaseExecutionData.getValue2());781 String value = "";782 if (!StringUtil.isNullOrEmpty(message)) {783 value = message;784 }785 testCaseExecutionData.setValue(value);786 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMCOMMAND).resolveDescription("VALUE", value));787 } else if (tCExecution.getAppTypeEngine().equals(Application.TYPE_IPA)) {788 String message = iosAppiumService.executeCommandString(tCExecution.getSession(), script, testCaseExecutionData.getValue2());789 String value = "";790 if (!StringUtil.isNullOrEmpty(message)) {791 value = message;792 }793 testCaseExecutionData.setValue(value);794 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMCOMMAND).resolveDescription("VALUE", value));795 } else {796 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_FEATURENOTSUPPORTED);797 res.setDescription(res.getDescription().replace("%APPTYPE%", tCExecution.getAppTypeEngine()));798 res.setDescription(res.getDescription().replace("%PROPTYPE%", testCaseExecutionData.getType()));799 testCaseExecutionData.setPropertyResultMessage(res);800 }801 } catch (Exception e) {802 LOG.debug("Exception Running Command Script :" + e.getMessage());803 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMCOMMAND_EXCEPTION).resolveDescription("REASON", e.getMessage()));804 }805 return testCaseExecutionData;806 }807 private TestCaseExecutionData property_getElementPosition(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceRecalculation) {808 // Check if script has been correctly defined809 String script = testCaseExecutionData.getValue1();810 if (script == null || script.isEmpty()) {811 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETELEMENTPOSITION_NULL));812 return testCaseExecutionData;813 }814 try {815 Identifier identifier = new Identifier();816 if (script != null) {817 identifier = identifierService.convertStringToIdentifier(script);818 }819 if (tCExecution.getAppTypeEngine().equals(Application.TYPE_APK)) {820 String message = androidAppiumService.getElementPosition(tCExecution.getSession(), identifier);821 String value = "";822 if (!StringUtil.isNullOrEmpty(message)) {823 value = message;824 }825 testCaseExecutionData.setValue(value);826 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETELEMENTPOSITION).resolveDescription("VALUE", value));827 } else if (tCExecution.getAppTypeEngine().equals(Application.TYPE_IPA)) {828 String message = iosAppiumService.getElementPosition(tCExecution.getSession(), identifier);829 String value = "";830 if (!StringUtil.isNullOrEmpty(message)) {831 value = message;832 }833 testCaseExecutionData.setValue(value);834 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETELEMENTPOSITION).resolveDescription("VALUE", value));835 } else {836 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_FEATURENOTSUPPORTED);837 res.setDescription(res.getDescription().replace("%APPTYPE%", tCExecution.getAppTypeEngine()));838 res.setDescription(res.getDescription().replace("%PROPTYPE%", testCaseExecutionData.getType()));839 testCaseExecutionData.setPropertyResultMessage(res);840 }841 } catch (Exception e) {842 LOG.debug("Exception Running Command Script :" + e.getMessage());843 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETELEMENTPOSITION_EXCEPTION).resolveDescription("REASON", e.getMessage()));844 }845 return testCaseExecutionData;846 }847 private TestCaseExecutionData property_executeSqlFromLib(TestCaseExecutionData testCaseExecutionData, TestCaseCountryProperties testCaseCountryProperty, TestCaseExecution tCExecution, boolean forceCalculation) {848 try {849 String script = this.sqlLibraryService.findSqlLibraryByKey(testCaseExecutionData.getValue1()).getScript();850 testCaseExecutionData.setValue1(script); //TODO use the new library851 } catch (CerberusException ex) {852 LOG.warn(ex);853 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_SQL_SQLLIB_NOTEXIT);854 res.setDescription(res.getDescription().replace("%SQLLIB%", testCaseExecutionData.getValue1()));855 testCaseExecutionData.setPropertyResultMessage(res);856 testCaseExecutionData.setEnd(new Date().getTime());857 return testCaseExecutionData;858 }859 testCaseExecutionData = this.property_getFromSql(testCaseExecutionData, tCExecution, testCaseCountryProperty, forceCalculation);860 return testCaseExecutionData;861 }862 private TestCaseExecutionData property_getFromNetworkTraffic(TestCaseExecutionData testCaseExecutionData, TestCaseCountryProperties testCaseCountryProperty, TestCaseExecution execution, boolean forceCalculation) {863 if ("Y".equalsIgnoreCase(execution.getRobotExecutorObj().getExecutorProxyActive())) {864 String jsonPath = testCaseExecutionData.getValue2();865 if (StringUtil.isNullOrEmpty(jsonPath)) {866 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMNETWORKTRAFFIC_MISSINGJSONPATH);867 testCaseExecutionData.setPropertyResultMessage(res);868 return testCaseExecutionData;869 }870 try {871 //TODO : check if HAR is the same than the last one to avoid to download same har file several times872 // String remoteHarMD5 = "http://" + tCExecution.getRobotExecutorObj().getHost() + ":" + tCExecution.getRobotExecutorObj().getExecutorExtensionPort() + "/getHarMD5?uuid="+tCExecution.getRemoteProxyUUID();873 Integer indexFrom = 0;874 if (!execution.getNetworkTrafficIndexList().isEmpty()) {875 // Take the value from the last entry.876 indexFrom = execution.getNetworkTrafficIndexList().get(execution.getNetworkTrafficIndexList().size() - 1).getIndexRequestNb();877 }878 JSONObject harRes = executorService.getHar(testCaseExecutionData.getValue1(), false, execution.getRobotExecutorObj().getExecutorExtensionHost(), execution.getRobotExecutorObj().getExecutorExtensionPort(),879 execution.getRemoteProxyUUID(), execution.getSystem(), indexFrom);880 harRes = harService.enrichWithStats(harRes, execution.getCountryEnvironmentParameters().getDomain(), execution.getSystem(), execution.getNetworkTrafficIndexList());881 //Record result in filessytem.882 testCaseExecutionData.addFileList(recorderService.recordProperty(execution.getId(), testCaseExecutionData.getProperty(), 1, harRes.toString(1), execution.getSecrets()));883 String valueFromJson = this.jsonService.getFromJson(harRes.toString(), null, jsonPath);884 if (valueFromJson != null) {885 testCaseExecutionData.setValue(valueFromJson);886 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMNETWORKTRAFFIC)887 .resolveDescription("PARAM", jsonPath)888 .resolveDescription("VALUE", valueFromJson)889 .resolveDescription("INDEX", String.valueOf(execution.getNetworkTrafficIndexList().size()))890 .resolveDescription("NBHITS", String.valueOf(indexFrom));891 testCaseExecutionData.setPropertyResultMessage(res);892 } else {893 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMNETWORKTRAFFIC_PATHNOTFOUND);894 res.setDescription(res.getDescription().replace("%PARAM%", jsonPath));895 testCaseExecutionData.setPropertyResultMessage(res);896 }897 } catch (Exception ex) {898 LOG.warn("Exception when getting property from Network Traffic.", ex);899 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMNETWORKTRAFFIC_PROXYNOTACTIVE);900 res.setDescription(res.getDescription().replace("%DETAIL%", ex.toString()));901 testCaseExecutionData.setPropertyResultMessage(res);902 testCaseExecutionData.setEnd(new Date().getTime());903 return testCaseExecutionData;904 }905 } else {906 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMNETWORKTRAFFIC_PROXYNOTACTIVE);907 res.setDescription(res.getDescription().replace("%ROBOT%", execution.getRobot()));908 res.setDescription(res.getDescription().replace("%EXECUTOR%", execution.getRobotExecutor()));909 testCaseExecutionData.setPropertyResultMessage(res);910 }911 return testCaseExecutionData;912 }913 private TestCaseExecutionData property_getOTP(TestCaseExecutionData testCaseExecutionData, TestCaseCountryProperties testCaseCountryProperty, TestCaseExecution tCExecution, boolean forceCalculation) {914 if (StringUtil.isNullOrEmpty(testCaseExecutionData.getValue1())) {915 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETOTP_MISSINGPARAMETER);916 testCaseExecutionData.setPropertyResultMessage(res);917 testCaseExecutionData.setEnd(new Date().getTime());918 return testCaseExecutionData;919 }920 try {921 String secretKey = testCaseExecutionData.getValue1();922 Totp totp = new Totp(secretKey);923 String val = totp.now();924 testCaseExecutionData.setValue(val);925 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETOTP).resolveDescription("VALUE", val));926 } catch (Exception ex) {927 LOG.warn("Exception when getting property from OTP secret.", ex);928 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETOTP);929 res.setDescription(res.getDescription().replace("%DETAIL%", ex.toString()));930 testCaseExecutionData.setPropertyResultMessage(res);931 testCaseExecutionData.setEnd(new Date().getTime());932 return testCaseExecutionData;933 }934 return testCaseExecutionData;935 }936 private TestCaseExecutionData property_getFromSql(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {937 return sQLService.calculateOnDatabase(testCaseExecutionData, testCaseCountryProperty, tCExecution);938 }939 private TestCaseExecutionData property_calculateText(TestCaseExecutionData testCaseExecutionData, TestCaseCountryProperties testCaseCountryProperty, boolean forceRecalculation) {940 if (TestCaseCountryProperties.NATURE_RANDOM.equals(testCaseCountryProperty.getNature())941 //TODO CTE Voir avec B. Civel "RANDOM_NEW"942 || (testCaseCountryProperty.getNature().equals(TestCaseCountryProperties.NATURE_RANDOMNEW))) {943 if (testCaseCountryProperty.getLength().equals("0")) {944 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_TEXTRANDOMLENGHT0);945 testCaseExecutionData.setPropertyResultMessage(res);946 } else {947 String charset;948 if (testCaseExecutionData.getValue1() != null && !"".equals(testCaseExecutionData.getValue1().trim())) {949 charset = testCaseExecutionData.getValue1();950 } else {951 charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";952 }953 String value = StringUtil.getRandomString(ParameterParserUtil.parseIntegerParam(testCaseCountryProperty.getLength(), 0), charset);954 testCaseExecutionData.setValue(value);955 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_RANDOM);956 res.setDescription(res.getDescription().replace("%FORCED%", forceRecalculation == true ? "Re-" : ""));957 res.setDescription(res.getDescription().replace("%VALUE%", ParameterParserUtil.securePassword(value, testCaseCountryProperty.getProperty())));958 testCaseExecutionData.setPropertyResultMessage(res);959// if (testCaseCountryProperty.getNature().equals("RANDOM_NEW")) {960// //TODO check if value exist on DB ( used in another test case of the revision )961// }962 }963 } else {964 LOG.debug("Setting value : " + testCaseExecutionData.getValue1());965 String value = testCaseExecutionData.getValue1();966 testCaseExecutionData.setValue(value);967 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_TEXT);968 res.setDescription(res.getDescription().replace("%VALUE%", ParameterParserUtil.securePassword(value, testCaseCountryProperty.getProperty())));969 testCaseExecutionData.setPropertyResultMessage(res);970 }971 return testCaseExecutionData;972 }973 private TestCaseExecutionData property_getFromHtmlVisible(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {974 try {975 Identifier identifier = identifierService.convertStringToIdentifier(testCaseExecutionData.getValue1());976 String valueFromHTML = this.webdriverService.getValueFromHTMLVisible(tCExecution.getSession(), identifier);977 if (valueFromHTML != null) {978 testCaseExecutionData.setValue(valueFromHTML);979 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_HTMLVISIBLE);980 res.setDescription(res.getDescription().replace("%ELEMENT%", testCaseExecutionData.getValue1()));981 res.setDescription(res.getDescription().replace("%VALUE%", valueFromHTML));982 testCaseExecutionData.setPropertyResultMessage(res);983 } else {984 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_HTMLVISIBLE_ELEMENTDONOTEXIST);985 res.setDescription(res.getDescription().replace("%ELEMENT%", testCaseExecutionData.getValue1()));986 testCaseExecutionData.setPropertyResultMessage(res);987 }988 } catch (NoSuchElementException exception) {989 LOG.debug(exception.toString());990 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_HTMLVISIBLE_ELEMENTDONOTEXIST);991 res.setDescription(res.getDescription().replace("%ELEMENT%", testCaseExecutionData.getValue1()));992 testCaseExecutionData.setPropertyResultMessage(res);993 }994 return testCaseExecutionData;995 }996 private TestCaseExecutionData property_getFromHtml(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {997 if (tCExecution.getAppTypeEngine().equals(Application.TYPE_APK)998 || tCExecution.getAppTypeEngine().equals(Application.TYPE_IPA)999 || tCExecution.getAppTypeEngine().equals(Application.TYPE_GUI)) {1000 try {1001 Identifier identifier = identifierService.convertStringToIdentifier(testCaseExecutionData.getValue1());1002 String valueFromHTML = this.webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);1003 if (valueFromHTML != null) {1004 testCaseExecutionData.setValue(valueFromHTML);1005 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_HTML);1006 res.setDescription(res.getDescription().replace("%ELEMENT%", testCaseExecutionData.getValue1()));1007 res.setDescription(res.getDescription().replace("%VALUE%", valueFromHTML));1008 testCaseExecutionData.setPropertyResultMessage(res);1009 }1010 } catch (NoSuchElementException exception) {1011 LOG.debug(exception.toString());1012 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_HTML_ELEMENTDONOTEXIST);1013 res.setDescription(res.getDescription().replace("%ELEMENT%", testCaseExecutionData.getValue1()));1014 testCaseExecutionData.setPropertyResultMessage(res);1015 }1016 } else {1017 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_FEATURENOTSUPPORTED);1018 res.setDescription(res.getDescription().replace("%APPTYPE%", tCExecution.getAppTypeEngine()));1019 res.setDescription(res.getDescription().replace("%PROPTYPE%", testCaseExecutionData.getType()));1020 }1021 return testCaseExecutionData;1022 }1023 private TestCaseExecutionData property_getFromJS(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {1024 String script = testCaseExecutionData.getValue1();1025 String valueFromJS;1026 String message = "";1027 if (tCExecution.getManualExecution().equals("Y")) {1028 MessageEvent mes = new MessageEvent(MessageEventEnum.PROPERTY_NOTPOSSIBLE);1029 testCaseExecutionData.setPropertyResultMessage(mes);1030 } else {1031 try {1032 valueFromJS = this.webdriverService.getValueFromJS(tCExecution.getSession(), script);1033 } catch (Exception e) {1034 message = e.getMessage().split("\n")[0];1035 LOG.debug("Exception Running JS Script :" + message);1036 valueFromJS = null;1037 }1038 if (valueFromJS != null) {1039 testCaseExecutionData.setValue(valueFromJS);1040 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_JS);1041 res.setDescription(res.getDescription().replace("%SCRIPT%", script));1042 res.resolveDescription("VALUE", valueFromJS);1043 testCaseExecutionData.setPropertyResultMessage(res);1044 } else {1045 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_JS_EXCEPTION);1046 res.setDescription(res.getDescription().replace("%EXCEPTION%", message));1047 testCaseExecutionData.setPropertyResultMessage(res);1048 }1049 }1050 return testCaseExecutionData;1051 }1052 private TestCaseExecutionData property_getFromGroovy(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {1053 // Check if script has been correctly defined1054 String script = testCaseExecutionData.getValue1();1055 if (script == null || script.isEmpty()) {1056 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMGROOVY_NULL));1057 return testCaseExecutionData;1058 }1059 // Try to evaluate Groovy script1060 try {1061 String valueFromGroovy = groovyService.eval(script);1062 testCaseExecutionData.setValue(valueFromGroovy);1063 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMGROOVY)1064 .resolveDescription("VALUE", valueFromGroovy));1065 } catch (IGroovyService.IGroovyServiceException e) {1066 LOG.debug("Exception Running Grrovy Script :" + e.getMessage());1067 testCaseExecutionData.setPropertyResultMessage(new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMGROOVY_EXCEPTION).resolveDescription("REASON", e.getMessage()));1068 }1069 return testCaseExecutionData;1070 }1071 private TestCaseExecutionData property_getAttributeFromHtml(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {1072 MessageEvent res;1073 try {1074 Identifier identifier = identifierService.convertStringToIdentifier(testCaseExecutionData.getValue1());1075 String valueFromHTML = this.webdriverService.getAttributeFromHtml(tCExecution.getSession(), identifier, testCaseExecutionData.getValue2());1076 if (valueFromHTML != null) {1077 testCaseExecutionData.setValue(valueFromHTML);1078 res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETATTRIBUTEFROMHTML);1079 res.setDescription(res.getDescription().replace("%VALUE%", valueFromHTML));1080 } else {1081 res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_HTML_ATTRIBUTEDONOTEXIST);1082 }1083 res.setDescription(res.getDescription().replace("%ELEMENT%", testCaseExecutionData.getValue1()));1084 res.setDescription(res.getDescription().replace("%ATTRIBUTE%", testCaseExecutionData.getValue2()));1085 } catch (NoSuchElementException exception) {1086 LOG.debug(exception.toString());1087 res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_HTMLVISIBLE_ELEMENTDONOTEXIST);1088 res.setDescription(res.getDescription().replace("%ELEMENT%", testCaseExecutionData.getValue1()));1089 }1090 testCaseExecutionData.setPropertyResultMessage(res);1091 return testCaseExecutionData;1092 }1093 private TestCaseExecutionData property_executeSoapFromLib(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseStepActionExecution testCaseStepActionExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {1094 String result = null;1095 AnswerItem<String> answerDecode = new AnswerItem<>();1096 try {1097 AppService appService = this.appServiceService.findAppServiceByKey(testCaseExecutionData.getValue1());1098 if (appService != null) {1099 String decodedEnveloppe = appService.getServiceRequest();1100 String decodedServicePath = appService.getServicePath();1101 String decodedMethod = appService.getOperation();1102 String decodedAttachement = appService.getAttachementURL();1103 if (appService.getServiceRequest().contains("%")) {1104 answerDecode = variableService.decodeStringCompletly(appService.getServiceRequest(), tCExecution, testCaseStepActionExecution, false);1105 decodedEnveloppe = answerDecode.getItem();1106 if (!(answerDecode.isCodeStringEquals("OK"))) {1107 // If anything wrong with the decode --> we stop here with decode message in the action result.1108 testCaseExecutionData.setPropertyResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "SOAP Service Request"));1109 testCaseExecutionData.setStopExecution(answerDecode.getResultMessage().isStopTest());1110 LOG.debug("Property interupted due to decode 'SOAP Service Request' Error.");1111 return testCaseExecutionData;1112 }1113 }1114 if (appService.getServicePath().contains("%")) {1115 answerDecode = variableService.decodeStringCompletly(appService.getServicePath(), tCExecution, testCaseStepActionExecution, false);1116 decodedServicePath = answerDecode.getItem();1117 if (!(answerDecode.isCodeStringEquals("OK"))) {1118 // If anything wrong with the decode --> we stop here with decode message in the action result.1119 testCaseExecutionData.setPropertyResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "SOAP Service Path"));1120 testCaseExecutionData.setStopExecution(answerDecode.getResultMessage().isStopTest());1121 LOG.debug("Property interupted due to decode 'SOAP Service Path.");1122 return testCaseExecutionData;1123 }1124 }1125 if (appService.getOperation().contains("%")) {1126 answerDecode = variableService.decodeStringCompletly(appService.getOperation(), tCExecution, testCaseStepActionExecution, false);1127 decodedMethod = answerDecode.getItem();1128 if (!(answerDecode.isCodeStringEquals("OK"))) {1129 // If anything wrong with the decode --> we stop here with decode message in the action result.1130 testCaseExecutionData.setPropertyResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "SOAP Operation"));1131 testCaseExecutionData.setStopExecution(answerDecode.getResultMessage().isStopTest());1132 LOG.debug("Property interupted due to decode 'SOAP Operation.");1133 return testCaseExecutionData;1134 }1135 }1136 if (appService.getAttachementURL().contains("%")) {1137 answerDecode = variableService.decodeStringCompletly(appService.getAttachementURL(), tCExecution, testCaseStepActionExecution, false);1138 decodedAttachement = answerDecode.getItem();1139 if (!(answerDecode.isCodeStringEquals("OK"))) {1140 // If anything wrong with the decode --> we stop here with decode message in the action r1141 // If anything wrong with the decode --> we stop here with decode message in the acesult.1142 testCaseExecutionData.setPropertyResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "SOAP Attachement URL"));1143 testCaseExecutionData.setStopExecution(answerDecode.getResultMessage().isStopTest());1144 LOG.debug("Property interupted due to decode 'SOAP Attachement URL.");1145 return testCaseExecutionData;1146 }1147 }1148 //Call Soap and set LastSoapCall of the testCaseExecution.1149 AnswerItem soapCall = soapService.callSOAP(decodedEnveloppe, decodedServicePath, decodedMethod, decodedAttachement, null, null, 60000, tCExecution.getApplicationObj().getSystem());1150 AppService se1 = (AppService) soapCall.getItem();1151// tCExecution.setLastSOAPCalled(soapCall);1152 if (soapCall.isCodeEquals(200)) {1153// SOAPExecution lastSoapCalled = (SOAPExecution) tCExecution.getLastSOAPCalled().getItem();1154 String xmlResponse = se1.getResponseHTTPBody();1155 result = xmlUnitService.getFromXml(xmlResponse, appService.getAttachementURL());1156 }1157 if (result != null) {1158 testCaseExecutionData.setValue(result);1159 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_SOAP);1160 testCaseExecutionData.setPropertyResultMessage(res);1161 } else {1162 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_SOAPFROMLIB_NODATA);1163 testCaseExecutionData.setPropertyResultMessage(res);1164 }1165 }1166 } catch (CerberusException exception) {1167 LOG.error(exception.toString(), exception);1168 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_TESTDATA_PROPERTYDONOTEXIST);1169 res.setDescription(res.getDescription().replace("%PROPERTY%", testCaseExecutionData.getValue1()));1170 testCaseExecutionData.setPropertyResultMessage(res);1171 } catch (CerberusEventException ex) {1172 LOG.error(ex.toString(), ex);1173 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSOAP);1174 message.setDescription(message.getDescription().replace("%SOAPNAME%", testCaseExecutionData.getValue1()));1175 message.setDescription(message.getDescription().replace("%DESCRIPTION%", ex.getMessageError().getDescription()));1176 testCaseExecutionData.setPropertyResultMessage(message);1177 }1178 return testCaseExecutionData;1179 }1180 private TestCaseExecutionData property_getFromXml(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {1181 // 1. Get XML value to parse1182 String xmlToParse = null;1183 // If value2 is defined, then take it as XML value to parse1184 if (!(StringUtil.isNullOrEmpty(testCaseExecutionData.getValue2()))) {1185 xmlToParse = testCaseExecutionData.getValue2();1186 } // Else try to get the last known response from service call1187 else if (tCExecution.getLastServiceCalled() != null) {1188 xmlToParse = tCExecution.getLastServiceCalled().getResponseHTTPBody();1189 } // If XML to parse is still null, then there is an error in XML value definition1190 else if (xmlToParse == null) {1191 testCaseExecutionData.setPropertyResultMessage(1192 new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMXML)1193 .resolveDescription("VALUE1", testCaseExecutionData.getValue1())1194 .resolveDescription("VALUE2", testCaseExecutionData.getValue2()));1195 return testCaseExecutionData;1196 }1197 // Else we can try to parse it thanks to the dedicated service1198 try {1199 String valueFromXml = xmlUnitService.getFromXml(xmlToParse, testCaseExecutionData.getValue1());1200 if (valueFromXml != null) {1201 testCaseExecutionData.setValue(valueFromXml);1202 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMXML);1203 res.setDescription(res.getDescription().replace("%VALUE%", valueFromXml));1204 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1205 testCaseExecutionData.setPropertyResultMessage(res);1206 } else {1207 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMXML);1208 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1209 res.setDescription(res.getDescription().replace("%VALUE2%", testCaseExecutionData.getValue2()));1210 testCaseExecutionData.setPropertyResultMessage(res);1211 }1212 } catch (Exception ex) {1213 LOG.debug(ex.toString());1214 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMXML);1215 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1216 res.setDescription(res.getDescription().replace("%VALUE2%", testCaseExecutionData.getValue2()));1217 testCaseExecutionData.setPropertyResultMessage(res);1218 }1219 return testCaseExecutionData;1220 }1221 private TestCaseExecutionData property_getRawFromXml(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {1222 // 1. Get XML value to parse1223 String xmlToParse = null;1224 // If value2 is defined, then take it as XML value to parse1225 if (!(StringUtil.isNullOrEmpty(testCaseExecutionData.getValue2()))) {1226 xmlToParse = testCaseExecutionData.getValue2();1227 } // Else try to get the last known response from service call1228 else if (tCExecution.getLastServiceCalled() != null) {1229 xmlToParse = tCExecution.getLastServiceCalled().getResponseHTTPBody();1230 } // If XML to parse is still null, then there is an error in XML value definition1231 else if (xmlToParse == null) {1232 testCaseExecutionData.setPropertyResultMessage(1233 new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMXML)1234 .resolveDescription("VALUE1", testCaseExecutionData.getValue1())1235 .resolveDescription("VALUE2", testCaseExecutionData.getValue2()));1236 return testCaseExecutionData;1237 }1238 // Else we can try to parse it thanks to the dedicated service1239 try {1240 String valueFromXml = xmlUnitService.getRawFromXml(xmlToParse, testCaseExecutionData.getValue1());1241 if (valueFromXml != null) {1242 testCaseExecutionData.setValue(valueFromXml);1243 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMXML);1244 res.setDescription(res.getDescription().replace("%VALUE%", valueFromXml));1245 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1246 testCaseExecutionData.setPropertyResultMessage(res);1247 } else {1248 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMXML);1249 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1250 res.setDescription(res.getDescription().replace("%VALUE2%", testCaseExecutionData.getValue2()));1251 testCaseExecutionData.setPropertyResultMessage(res);1252 }1253 } catch (Exception ex) {1254 LOG.debug(ex.toString());1255 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMXML);1256 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1257 res.setDescription(res.getDescription().replace("%VALUE2%", testCaseExecutionData.getValue2()));1258 testCaseExecutionData.setPropertyResultMessage(res);1259 }1260 return testCaseExecutionData;1261 }1262 private TestCaseExecutionData property_getFromCookie(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {1263 try {1264 String valueFromCookie = this.webdriverService.getFromCookie(tCExecution.getSession(), testCaseExecutionData.getValue1(), testCaseExecutionData.getValue2());1265 if (valueFromCookie != null) {1266 if (!valueFromCookie.equals("cookieNotFound")) {1267 testCaseExecutionData.setValue(valueFromCookie);1268 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMCOOKIE);1269 res.setDescription(res.getDescription().replace("%COOKIE%", testCaseExecutionData.getValue1()));1270 res.setDescription(res.getDescription().replace("%PARAM%", testCaseExecutionData.getValue2()));1271 res.setDescription(res.getDescription().replace("%VALUE%", valueFromCookie));1272 testCaseExecutionData.setPropertyResultMessage(res);1273 } else {1274 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMCOOKIE_COOKIENOTFOUND);1275 res.setDescription(res.getDescription().replace("%COOKIE%", testCaseExecutionData.getValue1()));1276 res.setDescription(res.getDescription().replace("%PARAM%", testCaseExecutionData.getValue2()));1277 testCaseExecutionData.setPropertyResultMessage(res);1278 }1279 } else {1280 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMCOOKIE_PARAMETERNOTFOUND);1281 res.setDescription(res.getDescription().replace("%COOKIE%", testCaseExecutionData.getValue1()));1282 res.setDescription(res.getDescription().replace("%PARAM%", testCaseExecutionData.getValue2()));1283 testCaseExecutionData.setPropertyResultMessage(res);1284 }1285 } catch (Exception exception) {1286 LOG.debug(exception.toString());1287 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMCOOKIE_COOKIENOTFOUND);1288 res.setDescription(res.getDescription().replace("%COOKIE%", testCaseExecutionData.getValue1()));1289 res.setDescription(res.getDescription().replace("%PARAM%", testCaseExecutionData.getValue2()));1290 testCaseExecutionData.setPropertyResultMessage(res);1291 }1292 return testCaseExecutionData;1293 }1294 private TestCaseExecutionData property_getDifferencesFromXml(TestCaseExecutionData testCaseExecutionData, TestCaseExecution tCExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceCalculation) {1295 try {1296 LOG.debug("Computing differences between " + testCaseExecutionData.getValue1() + " and " + testCaseExecutionData.getValue2());1297 String differences = xmlUnitService.getDifferencesFromXml(testCaseExecutionData.getValue1(), testCaseExecutionData.getValue2());1298 if (differences != null) {1299 LOG.debug("Computing done.");1300 testCaseExecutionData.setValue(differences);1301 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETDIFFERENCESFROMXML);1302 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1303 res.setDescription(res.getDescription().replace("%VALUE2%", testCaseExecutionData.getValue2()));1304 testCaseExecutionData.setPropertyResultMessage(res);1305 } else {1306 LOG.debug("Computing failed.");1307 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETDIFFERENCESFROMXML);1308 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1309 res.setDescription(res.getDescription().replace("%VALUE2%", testCaseExecutionData.getValue2()));1310 testCaseExecutionData.setPropertyResultMessage(res);1311 }1312 } catch (Exception ex) {1313 LOG.debug(ex.toString());1314 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETDIFFERENCESFROMXML);1315 res.setDescription(res.getDescription().replace("%VALUE1%", testCaseExecutionData.getValue1()));1316 res.setDescription(res.getDescription().replace("%VALUE2%", testCaseExecutionData.getValue2()));1317 testCaseExecutionData.setPropertyResultMessage(res);1318 }1319 return testCaseExecutionData;1320 }1321 private TestCaseExecutionData property_getFromJson(TestCaseExecutionData testCaseExecutionData, TestCaseExecution execution, boolean forceRecalculation) {1322 String jsonResponse = "";1323 if (null != execution.getLastServiceCalled()) {1324 jsonResponse = execution.getLastServiceCalled().getResponseHTTPBody();1325 }1326 if (!(StringUtil.isNullOrEmpty(testCaseExecutionData.getValue2()))) {1327 try {1328 jsonResponse = this.jsonService.callUrlAndGetJsonResponse(testCaseExecutionData.getValue2());1329 } catch (MalformedURLException e) {1330 LOG.debug("URL is invalid so we consider that it is a json file.");1331 jsonResponse = testCaseExecutionData.getValue2();1332 }1333 }1334 try {1335 //Record result in filessytem.1336 recorderService.recordProperty(execution.getId(), testCaseExecutionData.getProperty(), 1, jsonResponse, execution.getSecrets());1337 String valueFromJson = this1338 .jsonService1339 .getFromJson(jsonResponse, null, testCaseExecutionData.getValue1());1340 if (valueFromJson == null) {1341 throw new InvalidPathException();1342 }1343 testCaseExecutionData.setValue(valueFromJson);1344 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMJSON);1345 res.setDescription(res.getDescription().replace("%URL%", testCaseExecutionData.getValue2()));1346 res.setDescription(res.getDescription().replace("%PARAM%", testCaseExecutionData.getValue1()));1347 res.setDescription(res.getDescription().replace("%VALUE%", valueFromJson));1348 testCaseExecutionData.setPropertyResultMessage(res);1349 } catch (InvalidPathException exception) { //Path not found, invalid path syntax or empty path1350 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMJSON_PARAMETERNOTFOUND);1351 res.setDescription(res.getDescription().replace("%URL%", testCaseExecutionData.getValue2()));1352 res.setDescription(res.getDescription().replace("%PARAM%", testCaseExecutionData.getValue1()));1353 res.setDescription(res.getDescription().replace("%ERROR%", ""));1354 testCaseExecutionData.setPropertyResultMessage(res);1355 }1356 return testCaseExecutionData;1357 }1358 private TestCaseExecutionData property_getRawFromJson(TestCaseExecutionData testCaseExecutionData, TestCaseExecution execution) {1359 String jsonResponse = "";1360 //If tCExecution LastServiceCalled exist, get the response1361 if (execution.getLastServiceCalled() != null) {1362 jsonResponse = execution.getLastServiceCalled().getResponseHTTPBody();1363 }1364 if (!(StringUtil.isNullOrEmpty(testCaseExecutionData.getValue2()))) {1365 try {1366 jsonResponse = this.jsonService.callUrlAndGetJsonResponse(testCaseExecutionData.getValue2());1367 } catch (MalformedURLException e) {1368 LOG.debug("URL is invalid so we consider that it is a json file.");1369 jsonResponse = testCaseExecutionData.getValue2();1370 }1371 }1372 //Process1373 try {1374 //Record result in filesystem.1375 recorderService.recordProperty(execution.getId(), testCaseExecutionData.getProperty(), 1, jsonResponse, execution.getSecrets());1376 //Get the raw1377 String valueFromJson = this.jsonService.getRawFromJson(jsonResponse, testCaseExecutionData.getValue1());1378 testCaseExecutionData.setValue(valueFromJson);1379 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMJSON);1380 res.setDescription(res.getDescription().replace("%URL%", testCaseExecutionData.getValue2()));1381 res.setDescription(res.getDescription().replace("%PARAM%", testCaseExecutionData.getValue1()));1382 res.setDescription(res.getDescription().replace("%VALUE%", valueFromJson));1383 testCaseExecutionData.setPropertyResultMessage(res);1384 } catch (JsonProcessingException | InvalidPathException exception) { //Path not found, invalid path syntax or empty path1385 if (LOG.isDebugEnabled()) {1386 LOG.error("Exception when getting property from JSON.", exception);1387 }1388 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMJSON_PARAMETERNOTFOUND);1389 res.setDescription(res.getDescription().replace("%URL%", testCaseExecutionData.getValue2()));1390 res.setDescription(res.getDescription().replace("%PARAM%", testCaseExecutionData.getValue1()));1391 res.setDescription(res.getDescription().replace("%ERROR%", ""));1392 testCaseExecutionData.setPropertyResultMessage(res);1393 }1394 return testCaseExecutionData;1395 }1396 private TestCaseExecutionData property_getFromDataLib(TestCaseExecutionData testCaseExecutionData, TestCaseExecution execution,1397 TestCaseStepActionExecution testCaseStepActionExecution, TestCaseCountryProperties testCaseCountryProperty, boolean forceRecalculation) {1398 MessageEvent res = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMDATALIB);1399 TestDataLib testDataLib;1400 List<HashMap<String, String>> result = null;1401 AnswerItem<String> answerDecode = new AnswerItem<>();1402 // We get here the correct TestDataLib entry from the Value1 (name) that better match the context on system, environment and country.1403 AnswerItem<TestDataLib> answer = testDataLibService.readByNameBySystemByEnvironmentByCountry(testCaseExecutionData.getValue1(),1404 execution.getApplicationObj().getSystem(), execution.getEnvironmentData(),1405 execution.getCountry());1406 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && answer.getItem() != null) {1407 testDataLib = answer.getItem();1408 AnswerList<HashMap<String, String>> serviceAnswer;1409 // Here, we try to decode the SQL field if datalib is SQL type.1410 try {1411 if (testDataLib.getType().equals(TestDataLib.TYPE_SQL)) {1412 //check if the script contains properties that neeed to be calculated1413 answerDecode = variableService.decodeStringCompletly(testDataLib.getScript(), execution, testCaseStepActionExecution, false);1414 String decodedScript = answerDecode.getItem();1415 testDataLib.setScript(decodedScript);1416 if (!(answerDecode.isCodeStringEquals("OK"))) {1417 // If anything wrong with the decode --> we stop here with decode message in the action result.1418 testCaseExecutionData.setPropertyResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "SQL Script"));1419 testCaseExecutionData.setStopExecution(answerDecode.getResultMessage().isStopTest());1420 LOG.debug("Property interupted due to decode 'SQL Script'.");1421 return testCaseExecutionData;1422 }1423 }1424 } catch (CerberusEventException cex) {1425 LOG.error(cex.toString(), cex);1426 }1427 String decodedLength = null;1428 // Here, we try to decode testCaseCountryProperty field `length` to get the value of property if needed1429 try {1430 answerDecode = variableService.decodeStringCompletly(testCaseCountryProperty.getLength(), execution, testCaseStepActionExecution, false);1431 decodedLength = answerDecode.getItem();1432 if (!(answerDecode.isCodeStringEquals("OK"))) {1433 testCaseExecutionData.setPropertyResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "length"));1434 testCaseExecutionData.setStopExecution(answerDecode.getResultMessage().isStopTest());1435 LOG.debug("Property interupted due to decode 'Length field'.");1436 return testCaseExecutionData;1437 }1438 } catch (CerberusEventException cex) {1439 LOG.error(cex.toString(), cex);1440 }1441 // We cast from string to integer ((String)testcasecountryproperty field `length` -> (Integer)testcaseexecutiondata field `length`)1442 // if we can't, testCaseExecutionData field `length` will be equal to 01443 // if we can, we set the value of testCaseExecutionData field `length` to the casted value1444 if (decodedLength != null) {1445 try {1446 Integer.parseInt(decodedLength);1447 testCaseExecutionData.setLength(decodedLength);1448 } catch (NumberFormatException e) {1449 LOG.error(e.toString(), e);1450 MessageEvent msg = new MessageEvent(MessageEventEnum.CASTING_OPERATION_FAILED);1451 msg.setDescription(msg.getDescription().replace("%ERROR%", e.toString()));1452 msg.setDescription(msg.getDescription().replace("%FIELD%", "field length"));1453 testCaseExecutionData.setPropertyResultMessage(msg);1454 testCaseExecutionData.setStopExecution(msg.isStopTest());1455 return testCaseExecutionData;1456 }1457 }1458 // We calculate here the result for the lib1459 serviceAnswer = dataLibService.getFromDataLib(testDataLib, testCaseCountryProperty, execution, testCaseExecutionData);1460 testCaseExecutionData.setDataLib(testDataLib.getName());1461 res = serviceAnswer.getResultMessage();1462 result = serviceAnswer.getDataList(); //test data library returned by the service1463 if (result != null) {1464 // Keeping raw data to testCaseExecutionData object.1465 testCaseExecutionData.setDataLibRawData(result);1466 // Value of testCaseExecutionData object takes the master subdata entry "".1467 String value = result.get(0).get("");1468 if (value == null) {1469 testCaseExecutionData.setValue(VALUE_NULL);1470 } else {1471 testCaseExecutionData.setValue(value);1472 // Converting HashMap to json.1473 String jsonText = "";1474 JSONArray jsonResult = null;1475 try {1476 jsonResult = dataLibService.convertToJSONObject(result);1477 jsonText = jsonResult.toString();1478 } catch (JSONException ex) {1479 java.util.logging.Logger.getLogger(PropertyService.class.getName()).log(Level.SEVERE, null, ex);1480 }1481 testCaseExecutionData.setJsonResult(jsonText);1482 }1483 //Record result in filessytem.1484 testCaseExecutionData.addFileList(recorderService.recordTestDataLibProperty(execution.getId(), testCaseCountryProperty.getProperty(), 1, result, execution.getSecrets()));1485 }1486 res.resolveDescription("ENTRY", testDataLib.getName());1487 res.resolveDescription("ENTRYID", String.valueOf(testDataLib.getTestDataLibID()));1488 } else {//no TestDataLib found was returned1489 //the library does not exist at all1490 AnswerList nameExistsAnswer = testDataLibService.readNameListByName(testCaseExecutionData.getValue1(), 1, false);1491 if (nameExistsAnswer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && nameExistsAnswer.getTotalRows() > 0) {1492 //if the library name exists but was not available or does not exist for the current specification but exists for other countries/environments/systems1493 res = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_NOT_FOUND_ERROR);1494 res.setDescription(res.getDescription().replace("%ITEM%", testCaseExecutionData.getValue1()).1495 replace("%COUNTRY%", execution.getCountryEnvironmentParameters().getCountry()).1496 replace("%ENVIRONMENT%", execution.getCountryEnvironmentParameters().getEnvironment()).1497 replace("%SYSTEM%", execution.getCountryEnvironmentParameters().getSystem()));1498 } else {...
Source:RecorderService.java
...461 }462 return objectFileList;463 }464 @Override465 public TestCaseExecutionFile recordTestDataLibProperty(Long runId, String property, int propertyIndex, List<HashMap<String, String>> result) {466 TestCaseExecutionFile object = null;467 // Used for logging purposes468 String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - ";469 try {470 JSONArray jsonResult = null;471 jsonResult = dataLibService.convertToJSONObject(result);472 // RESULT.473 Recorder recorder = this.initFilenames(runId, null, null, null, null, null, null, property, propertyIndex, "result", "json", false);474 recordFile(recorder.getFullPath(), recorder.getFileName(), jsonResult.toString());475 // Index file created to database.476 object = testCaseExecutionFileFactory.create(0, runId, recorder.getLevel(), "Result", recorder.getRelativeFilenameURL(), "JSON", "", null, "", null);477 testCaseExecutionFileService.save(object);478 } catch (CerberusException | JSONException ex) {479 LOG.error(logPrefix + "TestDataLib file was not saved due to unexpected error." + ex.toString());...
recordTestDataLibProperty
Using AI Code Generation
1package org.cerberus.engine.execution.impl;2import org.cerberus.engine.entity.MessageEvent;3import org.cerberus.engine.entity.MessageGeneral;4import org.cerberus.engine.execution.IRecorderService;5import org.cerberus.engine.execution.IRecorderServiceFactory;6import org.cerberus.engine.execution.IRecorderServiceFactory;7import org.cerberus.engine.execution.IRecorderService;8import org.cerberus.engine.execution.IRecorderServiceFactory;9import org.cerberus.engine.execution.IRecorderService;10import org.cerberus.engine.execution.IRecorderServiceFactory;11import org.cerberus.engine.entity.MessageEvent;12import org.cerberus.engine.entity.MessageGeneral;13import org.cerberus.engine.execution.IRecorderService;14import org.cerberus.engine.execution.IRecorderServiceFactory;15import org.cerberus.engine.execution.IRecorderServiceFactory;16import org.cerberus.engine.execution.IRecorderService;17import org.cerberus.engine.execution.IRecorderServiceFactory;18import org.cerberus.engine.execution.IRecorderService;19import org.cerberus.engine.execution.IRecorderServiceFactory;20import org.cerberus.engine.entity.MessageEvent;21import org.cerberus.engine.entity.MessageGeneral;22import org.cerberus.engine.execution.IRecorderService;23import org.cerberus.engine.execution.IRecorderServiceFactory;24import org.cerberus.engine.execution.IRecorderServiceFactory;25import org.cerberus.engine.execution.IRecorderService;26import org.cerberus.engine.execution.IRecorderServiceFactory;27import org.cerberus.engine.execution.IRecorderService;28import org.cerberus.engine.execution.IRecorderServiceFactory;29import org.cerberus.engine.entity.MessageEvent;30import org.cerberus.engine.entity.MessageGeneral;31import org.cerberus.engine.execution.IRecorderService;32import org.cerberus.engine.execution.IRecorderServiceFactory;33import org.cerberus.engine.execution.IRecorderServiceFactory;34import org.cerberus.engine.execution.IRecorderService;35import org.cerberus.engine.execution.IRecorderServiceFactory;36import org.cerberus.engine.execution.IRecorderService;37import org.cerberus.engine.execution.IRecorderServiceFactory;38import org.cerberus.engine.entity.MessageEvent;39import org.cerberus.engine.entity.MessageGeneral;40import org.cerberus.engine.execution.IRecorderService;41import org.cerberus.engine.execution.IRecorderServiceFactory;42import
recordTestDataLibProperty
Using AI Code Generation
1package org.cerberus.testcase;2import org.cerberus.engine.execution.impl.RecorderService;3import org.cerberus.engine.execution.impl.TestCaseService;4import org.cerberus.engine.execution.impl.TestService;5import org.cerberus.engine.execution.impl.TestDataService;6import org.cerberus.engine.execution.impl.TestLinkService;7import org.cerberus.engine.execution.impl.TestStepService;8import org.cerberus.engine.execution.impl.TestSuiteService;9import org.cerberus.engine.execution.impl.UserManualService;10import org.cerberus.engine.execution.impl.factory.TestCaseServiceFactory;11import org.cerberus.engine.execution.impl.factory.TestServiceFactory;12import org.cerberus.engine.execution.impl.factory.TestDataServiceFactory;13import org.cerberus.engine.execution.impl.factory.TestLinkServiceFactory;14import org.cerberus.engine.execution.impl.factory.TestStepServiceFactory;15import org.cerberus.engine.execution.impl.factory.TestSuiteServiceFactory;16import org.cerberus.engine.execution.impl.factory.UserManualServiceFactory;17import org.cerberus.engine.execution.impl.service.ServiceFactory;18import org.cerberus.engine.execution.impl.service.ServiceFactoryImpl;19import org.cerberus.engine.execution.impl.service.TestCaseServiceFactoryImpl;20import org.cerberus.engine.execution.impl.service.TestServiceFactoryImpl;21import org.cerberus.engine.execution.impl.service.TestDataServiceFactoryImpl;22import org.cerberus.engine.execution.impl.service.TestLinkServiceFactoryImpl;23import org.cerberus.engine.execution.impl.service.TestStepServiceFactoryImpl;24import org.cerberus.engine.execution.impl.service.TestSuiteServiceFactoryImpl;25import org.cerberus.engine.execution.impl.service.UserManualServiceFactoryImpl;26import org.cerberus.engine.entity.MessageEvent;27import org.cerberus.exception.CerberusException;28import org.cerberus.factory.IFactoryTestCase;29import org.cerberus.factory.IFactoryTest;30import org.cerberus.factory.IFactoryTestData;31import org.cerberus.factory.IFactoryTestLink;32import org.cerberus.factory.IFactoryTestStep;33import org.cerberus.factory.IFactoryTestSuite;34import org.cerberus.factory.IFactoryUserManual;35import org.cerberus.factory.impl.FactoryTestCase;36import org.cerberus.factory.impl.FactoryTest;37import org.cerberus
recordTestDataLibProperty
Using AI Code Generation
1import org.cerberus.engine.execution.impl.RecorderService;2import org.cerberus.engine.execution.impl.TestCaseExecutionService;3import org.cerberus.engine.execution.impl.TestDataService;4import org.cerberus.engine.execution.impl.TestService;5import org.cerberus.engine.execution.impl.TestSuiteExecutionService;6import org.cerberus.engine.execution.impl.factory.TestCaseExecutionFactory;7import org.cerberus.engine.execution.impl.factory.TestFactory;8import org.cerberus.engine.execution.impl.factory.TestSuiteExecutionFactory;9import org.cerberus.engine.execution.impl.factory.TestWithDependenciesFactory;10import org.cerberus.engine.execution.impl.ManualExecutionService;11import org.cerberus.engine.entity.MessageEvent;12import org.cerberus.engine.entity.MessageGeneral;13import org.cerberus.engine.entity.MessageEventEnum;14import org.cerberus.engine.entity.MessageGeneralEnum;15import org.cerberus.engine.entity.Session;16import org.cerberus.engine.entity.Test;17import org.cerberus.engine.entity.TestDataLib;18import org.cerberus.engine.entity.TestDataLibData;19import org.cerberus.engine.entity.TestDataLibResult;20import org.cerberus.engine.entity.TestDataLibResultData;21import org.cerberus.engine.entity.TestDataLibType;22import org.cerberus.engine.entity.TestDataLibTypeEnum;23import org.cerberus.engine.entity.TestDataLibResultTypeEnum;24import org.cerberus.engine.entity.TestCase;25import org.cerberus.engine.entity.TestCaseExecution;26import org.cerberus.engine.entity.TestCaseStep;27import org.cerberus.engine.entity.TestCaseStepAction;28import org.cerberus.engine.entity.TestCaseStepActionControl;29import org.cerberus.engine.entity.TestCaseStepActionControlExecution;30import org.cerberus.engine.entity.TestCaseStepActionControlExecutionFile;31import org.cerberus.engine.entity.TestCaseStepActionExecution;32import org.cerberus
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!