Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.RecorderService.recordProperty
Source:PropertyService.java
...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()));...
recordProperty
Using AI Code Generation
1import org.cerberus.engine.execution.impl.RecorderService2import org.cerberus.engine.execution.impl.TestCaseExecution3import org.cerberus.engine.execution.impl.TestDataLibExecution4import org.cerberus.engine.execution.impl.TestDataLibExecutionDAO5import org.cerberus.util.answer.Answer6import org.cerberus.util.answer.AnswerItem7import org.cerberus.util.answer.AnswerList8import org.cerberus.util.answer.AnswerUtil9import org.cerberus.crud.entity.Application10import org.cerberus.crud.entity.CountryEnvironmentDatabase11import org.cerberus.crud.entity.CountryEnvironmentParameters12import org.cerberus.crud.entity.CountryEnvironmentParametersKey13import org.cerberus.crud.entity.CountryEnvironmentParametersToEnvParam14import org.cerberus.crud.entity.CountryEnvironmentParametersToEnvParamKey15import org.cerberus.crud.entity.Environment16import org.cerberus.crud.entity.EnvironmentData17import org.cerberus.crud.entity.EnvironmentDatabase18import org.cerberus.crud.entity.EnvironmentDatabaseKey19import org.cerberus.crud.entity.EnvironmentGroup20import org.cerberus.crud.entity.EnvironmentGroupCountry21import org.cerberus.crud.entity.EnvironmentGroupEnvironment22import org.cerberus.crud.entity.EnvironmentGroupEnvironmentKey23import org.cerberus.crud.entity.EnvironmentParameters24import org.cerberus.crud.entity.EnvironmentParametersKey25import org.cerberus.crud.entity.EnvironmentParametersToEnvParam26import org.cerberus.crud.entity.EnvironmentParametersToEnvParamKey27import org.cerberus.crud.entity.EnvironmentSystem28import org.cerberus.crud.entity.EnvironmentSystemKey29import org.cerberus.crud.entity.ExecutionThreadPool30import org.cerberus.crud.entity.Invariant31import org.cerberus.crud.entity.Label32import org.cerberus.crud.entity.LabelDatabase33import org.cerberus.crud.entity.LabelDatabaseKey34import org.cerberus.crud.entity.LabelEnvironment35import org.cerberus.crud.entity.LabelEnvironmentKey36import org.cerberus.crud.entity.LabelEnvironmentDatabase37import org.cerberus.crud.entity.LabelEnvironmentDatabaseKey38import org.cerberus.crud.entity.LabelEnvironmentGroup39import org.cerberus.crud
recordProperty
Using AI Code Generation
1import org.cerberus.engine.execution.impl.RecorderService2import org.cerberus.engine.execution.impl.TestContextService3import org.cerberus.engine.execution.impl.TestContextService4import org.cerberus.engine.execution.impl.TestContextService5import org.cerberus.engine.execution.impl.TestContextService6def tcs = new TestContextService()7def rs = new RecorderService()8def tc = tcs.getTestContext()9def tcid = tc.getTestContextID()10def tcname = tc.getTestContextName()11def tcdate = tc.getTestContextDate()12def tcenv = tc.getTestContextEnvironment()13def tccountry = tc.getTestContextCountry()14def tcbuild = tc.getTestContextBuild()15def tcrevision = tc.getTestContextRevision()16def tcchain = tc.getTestContextChain()17def tccontrol = tc.getTestContextControl()18def tccontrolmessage = tc.getTestContextControlMessage()19def tccontrolstatus = tc.getTestContextControlStatus()20def tccontrolproperty = tc.getTestContextControlProperty()21def tccontrolvalue1 = tc.getTestContextControlValue1()22def tccontrolvalue2 = tc.getTestContextControlValue2()23def tccontrolvalue3 = tc.getTestContextControlValue3()24def tccontrolvalue4 = tc.getTestContextControlValue4()25def tccontrolvalue5 = tc.getTestContextControlValue5()26def tccontrolvalue6 = tc.getTestContextControlValue6()27def tccontrolvalue7 = tc.getTestContextControlValue7()28def tccontrolvalue8 = tc.getTestContextControlValue8()29def tccontrolvalue9 = tc.getTestContextControlValue9()30def tccontrolvalue10 = tc.getTestContextControlValue10()31def tccontrolvalue11 = tc.getTestContextControlValue11()32def tccontrolvalue12 = tc.getTestContextControlValue12()33def tccontrolvalue13 = tc.getTestContextControlValue13()34def tccontrolvalue14 = tc.getTestContextControlValue14()35def tccontrolvalue15 = tc.getTestContextControlValue15()36def tccontrolvalue16 = tc.getTestContextControlValue16()37def tccontrolvalue17 = tc.getTestContextControlValue17()38def tccontrolvalue18 = tc.getTestContextControlValue18()39def tccontrolvalue19 = tc.getTestContextControlValue19()40def tccontrolvalue20 = tc.getTestContextControlValue20()
recordProperty
Using AI Code Generation
1import org.cerberus.engine.execution.impl.RecorderService2import org.cerberus.engine.entity.MessageEvent3import org.cerberus.engine.entity.MessageGeneral4def message = new MessageEvent(MessageGeneralEnum.TEST_FAILED, "Test failed")5def recorderService = new RecorderService()6recorderService.recordProperty("myProperty", message)7import org.cerberus.engine.execution.impl.RecorderService8import org.cerberus.engine.entity.MessageEvent9import org.cerberus.engine.entity.MessageGeneral10def message = new MessageEvent(MessageGeneralEnum.TEST_FAILED, "Test failed")11def recorderService = new RecorderService()12recorderService.recordProperty("myProperty", message)13import org.cerberus.engine.execution.impl.RecorderService14import org.cerberus.engine.entity.MessageEvent15import org.cerberus.engine.entity.MessageGeneral16def message = new MessageEvent(MessageGeneralEnum.TEST_FAILED, "Test failed")17def recorderService = new RecorderService()18recorderService.recordProperty("myProperty", message)19import org.cerberus.engine.execution.impl.RecorderService20import org.cerberus.engine.entity.MessageEvent21import org.cerberus.engine.entity.MessageGeneral22def message = new MessageEvent(MessageGeneralEnum.TEST_FAILED, "Test failed")23def recorderService = new RecorderService()24recorderService.recordProperty("myProperty", message)25import org.cerberus.engine.execution.impl.RecorderService26import org.cerberus.engine.entity.MessageEvent27import org.cerberus.engine.entity.MessageGeneral28def message = new MessageEvent(MessageGeneralEnum.TEST_FAILED, "Test failed")29def recorderService = new RecorderService()30recorderService.recordProperty("myProperty", message)
recordProperty
Using AI Code Generation
1import org.cerberus.engine.execution.impl.RecorderService2import org.cerberus.engine.execution.impl.factory.RecorderServiceFactory3def recorderService = new RecorderServiceFactory().createRecorderService()4recorderService.recordProperty("myProperty", "myValue", "myDescription")5recorderService.recordProperty("myProperty", "myValue", "myDescription", "myType", "myDatabase")6recorderService.recordProperty("myProperty", "myValue", "myDescription", "myType", "myDatabase", "myApplication", "myCountry")7recorderService.recordProperty("myProperty", "myValue", "myDescription", "myType", "myDatabase", "myApplication", "myCountry", "myEnvironment", "myBuild")8recorderService.recordProperty("myProperty", "myValue", "myDescription", "myType", "myDatabase", "myApplication", "myCountry", "myEnvironment", "myBuild", "myRevision", "myChain")9recorderService.recordProperty("myProperty", "myValue", "myDescription", "myType", "myDatabase", "myApplication", "myCountry", "myEnvironment", "myBuild", "myRevision", "myChain", "myRobot", "myRobotDecli")
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!!