Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.ConditionService.defaultIsSensitiveValue
Source:ConditionService.java
...162 LOG.debug("Checking ifTextInElement on " + path + " element against value: " + expected);163 }164 AnswerItem<Boolean> ans = new AnswerItem<>();165 MessageEvent resultControlMes = new MessageEvent(MessageEventEnum.ACTION_SUCCESS);166 isCaseSensitive = defaultIsSensitiveValue(isCaseSensitive);167 resultControlMes = controlService.verifyTextInElement(tCExecution, path, expected, isCaseSensitive);168 if ("OK".equals(resultControlMes.getCodeString())) {169 MessageEvent resultCondMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_TEXTINELEMENT);170 ans.setItem(true);171 ans.setResultMessage(resultCondMes);172 return ans;173 } else {174 MessageEvent resultCondMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_TEXTINELEMENT);175 resultCondMes.setDescription(resultCondMes.getDescription().replace("%ERRORMESS%", resultControlMes.getDescription()));176 ans.setItem(false);177 ans.setResultMessage(resultCondMes);178 return ans;179 }180 }181 private AnswerItem<Boolean> evaluateCondition_ifTextNotInElement(TestCaseExecution tCExecution, String path, String expected, String conditionOper, String isCaseSensitive) {182 if (LOG.isDebugEnabled()) {183 LOG.debug("Checking ifTextInElement on " + path + " element against value: " + expected);184 }185 AnswerItem<Boolean> ans = new AnswerItem<>();186 MessageEvent resultMes = new MessageEvent(MessageEventEnum.ACTION_SUCCESS);187 isCaseSensitive = defaultIsSensitiveValue(isCaseSensitive);188 resultMes = controlService.verifyTextNotInElement(tCExecution, path, expected, isCaseSensitive);189 if ("OK".equals(resultMes.getCodeString())) {190 MessageEvent resultCondMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_TEXTNOTINELEMENT);191 ans.setItem(true);192 ans.setResultMessage(resultCondMes);193 return ans;194 } else {195 MessageEvent resultCondMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_TEXTNOTINELEMENT);196 resultCondMes.setDescription(resultCondMes.getDescription().replace("%ERRORMESS%", resultMes.getDescription()));197 ans.setItem(false);198 ans.setResultMessage(resultCondMes);199 return ans;200 }201 }202 private AnswerItem<Boolean> evaluateCondition_ifPropertyExist(String conditionOper, String conditionValue1, TestCaseExecution tCExecution) {203 if (LOG.isDebugEnabled()) {204 LOG.debug("Checking if property Exist");205 }206 AnswerItem<Boolean> ans = new AnswerItem<>();207 MessageEvent mes;208 if (StringUtil.isNullOrEmpty(conditionValue1)) {209 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFPROPERTYEXIST_MISSINGPARAMETER);210 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));211 } else {212 String myCountry = tCExecution.getCountry();213 String myProperty = conditionValue1;214 boolean execute_Action = false;215 for (TestCaseCountryProperties prop : tCExecution.getTestCaseCountryPropertyList()) {216 LOG.debug(prop.getCountry() + " - " + myCountry + " - " + prop.getProperty() + " - " + myProperty);217 if ((prop.getCountry().equals(myCountry)) && (prop.getProperty().equals(myProperty))) {218 execute_Action = true;219 }220 }221 if (execute_Action == false) {222 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFPROPERTYEXIST);223 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));224 mes.setDescription(mes.getDescription().replace("%PROP%", conditionValue1));225 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));226 } else {227 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFPROPERTYEXIST);228 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));229 mes.setDescription(mes.getDescription().replace("%PROP%", conditionValue1));230 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));231 }232 }233 ans.setResultMessage(mes);234 return ans;235 }236 private AnswerItem<Boolean> evaluateCondition_ifPropertyNotExist(String conditionOper, String conditionValue1, TestCaseExecution tCExecution) {237 if (LOG.isDebugEnabled()) {238 LOG.debug("Checking if property Does not Exist");239 }240 AnswerItem<Boolean> ans = new AnswerItem<>();241 MessageEvent mes;242 if (StringUtil.isNullOrEmpty(conditionValue1)) {243 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFPROPERTYNOTEXIST_MISSINGPARAMETER);244 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));245 } else {246 String myCountry = tCExecution.getCountry();247 String myProperty = conditionValue1;248 boolean execute_Action = true;249 for (TestCaseCountryProperties prop : tCExecution.getTestCaseCountryPropertyList()) {250 LOG.debug(prop.getCountry() + " - " + myCountry + " - " + prop.getProperty() + " - " + myProperty);251 if ((prop.getCountry().equals(myCountry)) && (prop.getProperty().equals(myProperty))) {252 execute_Action = false;253 }254 }255 if (execute_Action == false) {256 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFPROPERTYNOTEXIST);257 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));258 mes.setDescription(mes.getDescription().replace("%PROP%", conditionValue1));259 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));260 } else {261 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFPROPERTYNOTEXIST);262 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));263 mes.setDescription(mes.getDescription().replace("%PROP%", conditionValue1));264 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));265 }266 }267 ans.setResultMessage(mes);268 return ans;269 }270 private AnswerItem<Boolean> evaluateCondition_ifElementPresent(String conditionOper, String conditionValue1, TestCaseExecution tCExecution) {271 if (LOG.isDebugEnabled()) {272 LOG.debug("Checking if Element Present");273 }274 AnswerItem<Boolean> ans = new AnswerItem<>();275 MessageEvent mes;276 if (tCExecution.getManualExecution().equals("Y")) {277 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_NOTPOSSIBLE);278 } else if (StringUtil.isNullOrEmpty(conditionValue1)) {279 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFELEMENTPRESENT_MISSINGPARAMETER);280 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));281 } else {282 boolean condition_result = false;283 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)284 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)285 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {286 Identifier identifier = identifierService.convertStringToIdentifier(conditionValue1);287 try {288 if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {289 condition_result = true;290 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTPRESENT);291 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));292 } else {293 condition_result = false;294 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTPRESENT);295 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));296 }297 } catch (WebDriverException exception) {298 condition_result = false;299 mes = parseWebDriverException(exception);300 }301 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {302 if (tCExecution.getLastServiceCalled() != null) {303 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();304 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {305 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:306 if (LOG.isDebugEnabled()) {307 LOG.debug("Checking if Element Present - XML");308 }309 if (xmlUnitService.isElementPresent(responseBody, conditionValue1)) {310 condition_result = true;311 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTPRESENT);312 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));313 } else {314 condition_result = false;315 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTPRESENT);316 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));317 }318 break;319 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON:320 if (LOG.isDebugEnabled()) {321 LOG.debug("Checking if Element Present - JSON");322 }323 try {324 if (jsonService.getFromJson(responseBody, null, conditionValue1) != null) {325 condition_result = true;326 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTPRESENT);327 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));328 } else {329 condition_result = false;330 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTPRESENT);331 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));332 }333 } catch (Exception ex) {334 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_GENERIC);335 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));336 }337 break;338 default:339 condition_result = false;340 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_MESSAGETYPE);341 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));342 mes.setDescription(mes.getDescription().replace("%CONDITION%", conditionOper));343 }344 } else {345 condition_result = false;346 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOOBJECTINMEMORY);347 }348 } else {349 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_APPLICATION);350 mes.setDescription(mes.getDescription().replace("%CONDITION%", conditionOper));351 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));352 }353 }354 ans.setResultMessage(mes);355 return ans;356 }357 private AnswerItem<Boolean> evaluateCondition_ifElementNotPresent(String conditionOper, String conditionValue1, TestCaseExecution tCExecution) {358 if (LOG.isDebugEnabled()) {359 LOG.debug("Checking if Element is Not Present");360 }361 AnswerItem<Boolean> ans = new AnswerItem<>();362 MessageEvent mes;363 if (tCExecution.getManualExecution().equals("Y")) {364 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_NOTPOSSIBLE);365 } else if (StringUtil.isNullOrEmpty(conditionValue1)) {366 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFELEMENTNOTPRESENT_MISSINGPARAMETER);367 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));368 } else {369 boolean condition_result = false;370 Identifier identifier = identifierService.convertStringToIdentifier(conditionValue1);371 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)372 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)373 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {374 try {375 if (identifier.getIdentifier().equals("picture")) {376 mes = sikuliService.doSikuliVerifyElementNotPresent(tCExecution.getSession(), identifier.getLocator());377 if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT))) {378 condition_result = true;379 } else {380 condition_result = false;381 }382 } else if (!this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {383 condition_result = true;384 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTPRESENT);385 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));386 } else {387 condition_result = false;388 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT);389 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));390 }391 } catch (WebDriverException exception) {392 condition_result = false;393 mes = parseWebDriverException(exception);394 }395 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {396 if (tCExecution.getLastServiceCalled() != null) {397 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();398 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {399 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:400 if (!xmlUnitService.isElementPresent(responseBody, conditionValue1)) {401 condition_result = true;402 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTPRESENT);403 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));404 } else {405 condition_result = false;406 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT);407 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));408 }409 break;410 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON:411 try {412 if (jsonService.getFromJson(responseBody, null, conditionValue1) == null) {413 condition_result = true;414 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTPRESENT);415 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));416 } else {417 condition_result = false;418 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT);419 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));420 }421 } catch (Exception ex) {422 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_GENERIC);423 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));424 }425 break;426 default:427 condition_result = false;428 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_MESSAGETYPE);429 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));430 mes.setDescription(mes.getDescription().replace("%CONDITION%", conditionOper));431 }432 } else {433 condition_result = false;434 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOOBJECTINMEMORY);435 }436 } else {437 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_APPLICATION);438 mes.setDescription(mes.getDescription().replace("%CONDITION%", conditionOper));439 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));440 }441 }442 ans.setResultMessage(mes);443 return ans;444 }445 private AnswerItem<Boolean> evaluateCondition_ifStringEqual(String conditionOper, String conditionValue1, String conditionValue2, String isCaseSensitive) {446 if (LOG.isDebugEnabled()) {447 LOG.debug("Checking if String Equal");448 }449 AnswerItem<Boolean> ans = new AnswerItem<>();450 MessageEvent mes;451 isCaseSensitive = defaultIsSensitiveValue(isCaseSensitive);452 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? conditionValue1.equals(conditionValue2) : conditionValue1.equalsIgnoreCase(conditionValue2)) {453 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STRINGEQUAL);454 mes.setDescription(mes.getDescription()455 .replace("%COND%", conditionOper)456 .replace("%STR1%", conditionValue1)457 .replace("%STR2%", conditionValue2)458 .replace("%STRING3%", caseSensitiveMessageValue(isCaseSensitive))459 );460 } else {461 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STRINGEQUAL);462 mes.setDescription(mes.getDescription()463 .replace("%COND%", conditionOper)464 .replace("%STR1%", conditionValue1)465 .replace("%STR2%", conditionValue2)466 .replace("%STRING3%", caseSensitiveMessageValue(isCaseSensitive))467 );468 }469 ans.setResultMessage(mes);470 return ans;471 }472 private AnswerItem<Boolean> evaluateCondition_ifStringDifferent(String conditionOper, String conditionValue1, String conditionValue2, String isCaseSensitive) {473 if (LOG.isDebugEnabled()) {474 LOG.debug("Checking if String Different");475 }476 AnswerItem<Boolean> ans = new AnswerItem<>();477 MessageEvent mes;478 isCaseSensitive = defaultIsSensitiveValue(isCaseSensitive);479 boolean execute_Action = true;480 if (!(ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? conditionValue1.equals(conditionValue2) : conditionValue1.equalsIgnoreCase(conditionValue2))) {481 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STRINGDIFFERENT);482 mes.setDescription(mes.getDescription()483 .replace("%COND%", conditionOper)484 .replace("%STR1%", conditionValue1)485 .replace("%STR2%", conditionValue2)486 .replace("%STRING3%", caseSensitiveMessageValue(isCaseSensitive))487 );488 } else {489 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STRINGDIFFERENT);490 mes.setDescription(mes.getDescription()491 .replace("%COND%", conditionOper)492 .replace("%STR1%", conditionValue1)493 .replace("%STR2%", conditionValue2)494 .replace("%STRING3%", caseSensitiveMessageValue(isCaseSensitive))495 );496 }497 ans.setItem(execute_Action);498 ans.setResultMessage(mes);499 return ans;500 }501 private AnswerItem<Boolean> evaluateCondition_ifStringGreater(String conditionOper, String conditionValue1, String conditionValue2) {502 if (LOG.isDebugEnabled()) {503 LOG.debug("Checking if String Greater");504 }505 AnswerItem<Boolean> ans = new AnswerItem<>();506 MessageEvent mes;507 boolean execute_Action = true;508 if ((conditionValue1.compareToIgnoreCase(conditionValue2) > 0)) {509 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STRINGGREATER);510 mes.setDescription(mes.getDescription()511 .replace("%COND%", conditionOper)512 .replace("%STR1%", conditionValue1).replace("%STR2%", conditionValue2)513 );514 } else {515 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STRINGGREATER);516 mes.setDescription(mes.getDescription()517 .replace("%COND%", conditionOper)518 .replace("%STR1%", conditionValue1).replace("%STR2%", conditionValue2)519 );520 }521 ans.setItem(execute_Action);522 ans.setResultMessage(mes);523 return ans;524 }525 private AnswerItem<Boolean> evaluateCondition_ifStringMinor(String conditionOper, String conditionValue1, String conditionValue2) {526 if (LOG.isDebugEnabled()) {527 LOG.debug("Checking if String Minor");528 }529 AnswerItem<Boolean> ans = new AnswerItem<>();530 MessageEvent mes;531 boolean execute_Action = true;532 if ((conditionValue1.compareToIgnoreCase(conditionValue2) < 0)) {533 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STRINGMINOR);534 mes.setDescription(mes.getDescription()535 .replace("%COND%", conditionOper)536 .replace("%STR1%", conditionValue1).replace("%STR2%", conditionValue2)537 );538 } else {539 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STRINGMINOR);540 mes.setDescription(mes.getDescription()541 .replace("%COND%", conditionOper)542 .replace("%STR1%", conditionValue1).replace("%STR2%", conditionValue2)543 );544 }545 ans.setItem(execute_Action);546 ans.setResultMessage(mes);547 return ans;548 }549 private AnswerItem<Boolean> evaluateCondition_ifStringContains(String conditionOper, String conditionValue1, String conditionValue2, String isCaseSensitive) {550 if (LOG.isDebugEnabled()) {551 LOG.debug("Checking if String Contains");552 }553 AnswerItem<Boolean> ans = new AnswerItem<>();554 MessageEvent mes;555 isCaseSensitive = defaultIsSensitiveValue(isCaseSensitive);556 boolean execute_Action = true;557 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? conditionValue1.contains(conditionValue2) : conditionValue1.toLowerCase().contains(conditionValue2.toLowerCase())) {558 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STRINGCONTAINS);559 mes.setDescription(mes.getDescription()560 .replace("%COND%", conditionOper)561 .replace("%STR1%", conditionValue1)562 .replace("%STR2%", conditionValue2)563 .replace("%STRING3%", caseSensitiveMessageValue(isCaseSensitive))564 );565// execute_Action = true;566 } else {567 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STRINGCONTAINS);568 mes.setDescription(mes.getDescription()569 .replace("%COND%", conditionOper)570 .replace("%STR1%", conditionValue1)571 .replace("%STR2%", conditionValue2)572 .replace("%STRING3%", caseSensitiveMessageValue(isCaseSensitive))573 );574// execute_Action = false;575 }576 ans.setItem(execute_Action);577 ans.setResultMessage(mes);578 return ans;579 }580 private AnswerItem<Boolean> evaluateCondition_ifStringNotContains(String conditionOper, String conditionValue1, String conditionValue2, String isCaseSensitive) {581 if (LOG.isDebugEnabled()) {582 LOG.debug("Checking if String Does Not Contains");583 }584 AnswerItem<Boolean> ans = new AnswerItem<>();585 MessageEvent mes;586 isCaseSensitive = defaultIsSensitiveValue(isCaseSensitive);587 boolean execute_Action = true;588 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? conditionValue1.contains(conditionValue2) : conditionValue1.toLowerCase().contains(conditionValue2.toLowerCase())) {589 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STRINGCONTAINS);590 mes.setDescription(mes.getDescription()591 .replace("%COND%", conditionOper)592 .replace("%STR1%", conditionValue1)593 .replace("%STR2%", conditionValue2)594 .replace("%STRING3%", caseSensitiveMessageValue(isCaseSensitive))595 );596// execute_Action = true;597 } else {598 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STRINGCONTAINS);599 mes.setDescription(mes.getDescription()600 .replace("%COND%", conditionOper)601 .replace("%STR1%", conditionValue1)602 .replace("%STR2%", conditionValue2)603 .replace("%STRING3%", caseSensitiveMessageValue(isCaseSensitive))604 );605// execute_Action = false;606 }607 ans.setItem(execute_Action);608 ans.setResultMessage(mes);609 return ans;610 }611 private AnswerItem<Boolean> evaluateCondition_ifNumericXXX(String conditionOper, String conditionValue1, String conditionValue2) {612 if (LOG.isDebugEnabled()) {613 LOG.debug("Checking if Numeric Equals");614 }615 AnswerItem<Boolean> ans = new AnswerItem<>();616 MessageEvent mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_PENDING);617 // We first prepare the string for nueric conversion to replace , by .618 String newConditionValue1 = StringUtil.prepareToNumeric(conditionValue1);619 String newConditionValue2 = StringUtil.prepareToNumeric(conditionValue2);620 // We try to convert the strings value1 to numeric.621 Double value1 = 0.0;622 try {623 value1 = Double.valueOf(newConditionValue1);624 } catch (NumberFormatException nfe) {625 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFNUMERIC_GENERICCONVERSIONERROR);626 mes.setDescription(mes.getDescription()627 .replace("%COND%", conditionOper)628 .replace("%STRINGVALUE%", newConditionValue1));629 ans.setItem(false);630 ans.setResultMessage(mes);631 return ans;632 }633 // We try to convert the strings value2 to numeric.634 Double value2 = 0.0;635 try {636 value2 = Double.valueOf(newConditionValue2);637 } catch (NumberFormatException nfe) {638 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFNUMERIC_GENERICCONVERSIONERROR);639 mes.setDescription(mes.getDescription()640 .replace("%COND%", conditionOper)641 .replace("%STRINGVALUE%", newConditionValue2));642 ans.setItem(false);643 ans.setResultMessage(mes);644 return ans;645 }646 // Now that both values are converted to double we ceck the operator here.647 boolean execute_Action = true;648 switch (conditionOper) {649 case TestCaseStepAction.CONDITIONOPER_IFNUMERICEQUAL:650 if (Objects.equals(value1, value2)) {651 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_NUMERICEQUAL);652 mes.setDescription(mes.getDescription()653 .replace("%COND%", conditionOper)654 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())655 );656 } else {657 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_NUMERICEQUAL);658 mes.setDescription(mes.getDescription()659 .replace("%COND%", conditionOper)660 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())661 );662 }663 break;664 case TestCaseStepAction.CONDITIONOPER_IFNUMERICDIFFERENT:665 if (!(Objects.equals(value1, value2))) {666 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_NUMERICDIFFERENT);667 mes.setDescription(mes.getDescription()668 .replace("%COND%", conditionOper)669 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())670 );671 } else {672 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_NUMERICDIFFERENT);673 mes.setDescription(mes.getDescription()674 .replace("%COND%", conditionOper)675 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())676 );677 }678 break;679 case TestCaseStepAction.CONDITIONOPER_IFNUMERICGREATER:680 if (value1 > value2) {681 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_NUMERICGREATER);682 mes.setDescription(mes.getDescription()683 .replace("%COND%", conditionOper)684 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())685 );686 } else {687 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_NUMERICGREATER);688 mes.setDescription(mes.getDescription()689 .replace("%COND%", conditionOper)690 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())691 );692 }693 break;694 case TestCaseStepAction.CONDITIONOPER_IFNUMERICGREATEROREQUAL:695 if (value1 >= value2) {696 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_NUMERICGREATEROREQUAL);697 mes.setDescription(mes.getDescription()698 .replace("%COND%", conditionOper)699 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())700 );701 } else {702 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_NUMERICGREATEROREQUAL);703 mes.setDescription(mes.getDescription()704 .replace("%COND%", conditionOper)705 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())706 );707 }708 break;709 case TestCaseStepAction.CONDITIONOPER_IFNUMERICMINOR:710 if (value1 < value2) {711 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_NUMERICMINOR);712 mes.setDescription(mes.getDescription()713 .replace("%COND%", conditionOper)714 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())715 );716 } else {717 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_NUMERICMINOR);718 mes.setDescription(mes.getDescription()719 .replace("%COND%", conditionOper)720 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())721 );722 }723 break;724 case TestCaseStepAction.CONDITIONOPER_IFNUMERICMINOROREQUAL:725 if (value1 <= value2) {726 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_NUMERICMINOROREQUAL);727 mes.setDescription(mes.getDescription()728 .replace("%COND%", conditionOper)729 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())730 );731 } else {732 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_NUMERICMINOROREQUAL);733 mes.setDescription(mes.getDescription()734 .replace("%COND%", conditionOper)735 .replace("%STR1%", value1.toString()).replace("%STR2%", value2.toString())736 );737 }738 break;739 }740 ans.setItem(execute_Action);741 ans.setResultMessage(mes);742 return ans;743 }744 private String caseSensitiveMessageValue(String isCaseSensitive) {745 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)) {746 return "case sensitive";747 } else {748 return "case insensitive";749 }750 }751 /**752 * @author memiks753 * @param exception the exception need to be parsed by Cerberus754 * @return A new Event Message with selenium related description755 */756 private MessageEvent parseWebDriverException(WebDriverException exception) {757 MessageEvent mes;758 LOG.fatal(exception.toString());759 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_SELENIUM_CONNECTIVITY);760 mes.setDescription(mes.getDescription().replace("%ERROR%", exception.getMessage().split("\n")[0]));761 return mes;762 }763 private String defaultIsSensitiveValue(String isCaseSensitive) {764 if (StringUtil.isNullOrEmpty(isCaseSensitive)) {765 isCaseSensitive = "N";766 }767 return isCaseSensitive;768 }769}...
defaultIsSensitiveValue
Using AI Code Generation
1import org.cerberus.engine.execution.impl.ConditionService;2import org.cerberus.engine.execution.impl.TestService;3import org.cerberus.engine.execution.impl.TestCaseService;4import org.cerberus.engine.execution.impl.TestCaseExecutionService;5import org.cerberus.engine.execution.impl.TestCaseStepService;6import org.cerberus.engine.execution.impl.TestCaseStepActionService;7import org.cerberus.engine.execution.impl.TestCaseStepActionControlService;8import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecutionService;9import org.cerberus.engine.execution.impl.TestCaseStepActionExecutionService;10import org.cerberus.engine.execution.impl.TestCaseStepActionExecutionFileService;11import org.cerberus.engine.execution.impl.TestCaseStepActionExecutionService;12import org.cerberus.engine.execution.impl.TestCaseStepActionExecutionStatService;13import org.cerberus.engine.execution.impl.TestCaseStepExecutionService;14import org.cerberus.engine.execution.impl.TestBatteryService;15import org.cerberus.engine.execution.impl.TestBatteryContentService;16import org.cerberus.engine.execution.impl.TestBatteryExecutionService;17import org.cerberus.engine.execution.impl.TestBatteryExecutionContentService;18import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailService;19import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionService;20import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStatService;21import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepService;22import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepActionService;23import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepActionControlService;24import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepActionControlExecutionService;25import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepActionExecutionService;26import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepActionExecutionFileService;27import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepActionExecutionStatService;28import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepExecutionService;29import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailExecutionStepExecutionStatService;30import org.cerberus.engine.execution.impl.TestBatteryExecutionContentDetailService;31import org.cerberus.engine.execution.impl.TestBatteryExecutionContent
defaultIsSensitiveValue
Using AI Code Generation
1import org.cerberus.engine.execution.impl.ConditionService;2import org.cerberus.engine.execution.impl.TestService;3import org.cerberus.engine.execution.impl.TestCaseExecution;4import org.cerberus.engine.execution.impl.TestCaseStepActionExecution;5import org.cerberus.engine.execution.impl.TestCaseStepExecution;6import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;7import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;8import org.cerberus.engine.execution.impl.TestService;9import org.cerberus.engine.execution.impl.TestCaseExecution;10import org.cerberus.engine.execution.impl.TestCaseStepActionExecution;11import org.cerberus.engine.execution.impl.TestCaseStepExecution;12import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;13import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;14import org.cerberus.engine.execution.impl.TestService;15import org.cerberus.engine.execution.impl.TestCaseExecution;16import org.cerberus.engine.execution.impl.TestCaseStepActionExecution;17import org.cerberus.engine.execution.impl.TestCaseStepExecution;18import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;19import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;20import org.cerberus.engine.execution.impl.TestService;21import org.cerberus.engine.execution.impl.TestCaseExecution;22import org.cerberus.engine.execution.impl.TestCaseStepActionExecution;23import org.cerberus.engine.execution.impl.TestCaseStepExecution;24import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;25import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;26import org.cerberus.engine.execution.impl.TestService;27import org.cerberus.engine.execution.impl.TestCaseExecution;28import org.cerberus.engine.execution.impl.TestCaseStepActionExecution;29import org.cerberus.engine.execution.impl.TestCaseStepExecution;30import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;31import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;32import org.cerberus.engine.execution.impl.TestService;33import org.cerberus.engine.execution.impl.TestCaseExecution;34import org.cerberus.engine.execution.impl.TestCaseStepActionExecution;35import org.cerberus.engine.execution.impl.TestCaseStepExecution;36import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;37import org.cerberus.engine.execution.impl.TestCaseStepActionControlExecution;
defaultIsSensitiveValue
Using AI Code Generation
1import org.cerberus.engine.execution.impl.ConditionService;2def conditionService = new ConditionService();3def defaultIsSensitiveValue = conditionService.defaultIsSensitiveValue("sensitiveValue");4log.debug("defaultIsSensitiveValue: " + defaultIsSensitiveValue);5if (defaultIsSensitiveValue) {6 log.debug("defaultIsSensitiveValue is sensitive");7} else {8 log.debug("defaultIsSensitiveValue is not sensitive");9}10import org.cerberus.engine.execution.impl.ConditionService;11def conditionService = new ConditionService();12def defaultIsSensitiveValue = conditionService.defaultIsSensitiveValue("sensitiveValue");13log.debug("defaultIsSensitiveValue: " + defaultIsSensitiveValue);14if (defaultIsSensitiveValue) {15 log.debug("defaultIsSensitiveValue is sensitive");16} else {17 log.debug("defaultIsSensitiveValue is not sensitive");18}19import org.cerberus.engine.execution.impl.ConditionService;20def conditionService = new ConditionService();21def defaultIsSensitiveValue = conditionService.defaultIsSensitiveValue("sensitiveValue");22log.debug("defaultIsSensitiveValue: " + defaultIsSensitiveValue);23if (defaultIsSensitiveValue) {24 log.debug("defaultIsSensitiveValue is sensitive");25} else {26 log.debug("defaultIsSensitiveValue is not sensitive");27}28import org.cerberus.engine.execution.impl.ConditionService;29def conditionService = new ConditionService();30def defaultIsSensitiveValue = conditionService.defaultIsSensitiveValue("sensitiveValue");31log.debug("defaultIsSensitiveValue: " + defaultIsSensitiveValue);32if (defaultIsSensitiveValue) {33 log.debug("defaultIsSensitiveValue is sensitive");34} else {35 log.debug("defaultIsSensitiveValue is not sensitive");36}37import org.cerberus.engine.execution.impl.ConditionService;38def conditionService = new ConditionService();39def defaultIsSensitiveValue = conditionService.defaultIsSensitiveValue("sensitiveValue");40log.debug("defaultIsSensitiveValue: " + defaultIsSensitiveValue);41if (defaultIsSensitiveValue) {
defaultIsSensitiveValue
Using AI Code Generation
1public boolean defaultIsSensitiveValue(String value) {2 if (value != null) {3 if (value.contains("password") || value.contains("pwd") || value.contains("passwd")) {4 return true;5 }6 }7 return false;8}9public boolean isSensitiveValue(String value) {10 if (defaultIsSensitiveValue(value)) {11 return true;12 }13 if (sensitiveDataList != null) {14 for (String sensitiveData : sensitiveDataList) {15 if (value.contains(sensitiveData)) {16 return true;17 }18 }19 }20 return false;21}22public AnswerItem readDataLibFromNameByCriteria(String dataLibName, String system, String country, String environment, String robot, String robotDecli, String application, String testCase, String testCaseCountry, String testCaseCountryProperty, String controlStatus, String controlMessage, String controlProperty) {23 AnswerItem answer = new AnswerItem();24 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);25 msg.setDescription(msg.getDescription().replace("%ITEM%", "DataLib").replace("%OPERATION%", "Read"));26 answer.setResultMessage(msg);27 try {28 List<DataLib> dataList = dataLibService.convert(dataLibService.readByNameByCriteria(dataLibName, system, country, environment, robot, robotDecli, application, testCase, testCaseCountry, testCaseCountryProperty, controlStatus, controlMessage, controlProperty));29 if (dataList == null || dataList.isEmpty()) {30 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);31 msg.setDescription(msg.getDescription().replace("%ITEM%", "DataLib").replace("%OPERATION%", "Read"));32 answer.setResultMessage(msg);33 answer.setItem(null);34 } else {35 DataLib dataLib = dataList.get(0);36 String value = dataLib.getValue();
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!!