private SearchAttribute handleSearch(final MethodCall method, final WarningCallbBack warningCallback, final String leftBrace, final String rightBrace) { final SearchAttribute searchAttribute = SearchAttribute.from( MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, ATTRIBUTE_SEARCH).orElse(MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, ATTRIBUTE_SCOPE).orElse(ATTRIBUTE_VALUE_ALL))); if (searchAttribute == SearchAttribute.COOKIES) { logWarn("The option \"Search=Cookies\" is not supported in NeoLoad. The extractor type has been set to \"Headers\".", warningCallback); } else if (searchAttribute == SearchAttribute.NORESOURCE) { logWarn("The option \"Search=Noresource\" is not supported in NeoLoad. The extractor type has been set to \"Body\".", warningCallback); } return searchAttribute; }
private void handleOrd(final MethodCall method, final WarningCallbBack warningCallback, final String leftBrace, final String rightBrace, final Builder extractBuilder) { MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, ATTRIBUTE_ORD).ifPresent(value -> { int nbOccur = 1; try { nbOccur = Integer.parseInt(value); } catch (NumberFormatException e) { logWarn("The variable extractor contains an occurrence number that is not an integer. Fallback to extract first occurrence.", warningCallback); } extractBuilder.nbOccur(nbOccur); }); }
private void logUnsupportedAttributes(final MethodCall method, final WarningCallbBack warningCallback, final String leftBrace, final String rightBrace) { for (final String unsupportedAttribute : UNSUPPORTED_ATTRIBUTE) { MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, unsupportedAttribute).ifPresent(value -> logWarn( "The option \"" + unsupportedAttribute + "\" has not been taken under account for the LR function with name : " + method.getName(), warningCallback)); } } }
private void handleNotFound(final MethodCall method, final WarningCallbBack warningCallback, final String leftBrace, final String rightBrace, final Builder extractBuilder) { String strError = MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, ATTRIBUTE_NOTFOUND).orElse(ATTRIBUTE_VALUE_ERROR); if (ATTRIBUTE_VALUE_ERROR.equalsIgnoreCase(strError)) { extractBuilder.exitOnError(true); } else { if (!ATTRIBUTE_VALUE_EMPTY.equalsIgnoreCase(strError)) { logWarn("The value \"" + strError + "\" has not been taken under account. The value will be set to \"" + ATTRIBUTE_VALUE_EMPTY + "\". The LR function was : " + method.getName(), warningCallback); } extractBuilder.exitOnError(false); } }
private void handleJsonPath(final LoadRunnerVUVisitor visitor, final MethodCall method, final WarningCallbBack warningCallback, final Builder extractBuilder, final SearchAttribute searchAttribute) { if (supportJsonPath()) { final Optional<String> jsonPath = MethodUtils.getParameterValueWithName(visitor.getLeftBrace(), visitor.getRightBrace(), method, ATTRIBUTE_QUERYSTRING); if (jsonPath.isPresent()) { extractBuilder.jsonPath(jsonPath.get()); extractBuilder.extractType(ExtractType.JSON); if(searchAttribute != SearchAttribute.BODY){ logWarn(LOG_THE_ATTRIBUTE + ATTRIBUTE_QUERYSTRING + "\" requires to have a Search attribute with " + SearchAttribute.BODY + " instead of " + searchAttribute.toString(), warningCallback); } } else { logWarn(LOG_THE_ATTRIBUTE + ATTRIBUTE_QUERYSTRING + LOG_IS_MANDATORY + method.getName(), warningCallback); extractBuilder.jsonPath(""); } } }
private void handleXPath(final LoadRunnerVUVisitor visitor, final MethodCall method, final WarningCallbBack warningCallback, final Builder extractBuilder, final SearchAttribute searchAttribute) { if (supportXPath()) { final Optional<String> xpath = MethodUtils.getParameterValueWithName(visitor.getLeftBrace(), visitor.getRightBrace(), method, ATTRIBUTE_QUERYSTRING); if (xpath.isPresent()) { extractBuilder.xPath(xpath.get()); extractBuilder.extractType(ExtractType.XPATH); if(searchAttribute != SearchAttribute.BODY){ logWarn(LOG_THE_ATTRIBUTE + ATTRIBUTE_QUERYSTRING + "\" requires to have a Search attribute with " + SearchAttribute.BODY + " instead of " + searchAttribute.toString(), warningCallback); } } else { logWarn(LOG_THE_ATTRIBUTE + ATTRIBUTE_QUERYSTRING + LOG_IS_MANDATORY + method.getName(), warningCallback); extractBuilder.xPath(""); } } }
private void handleRegExp(final LoadRunnerVUVisitor visitor, final MethodCall method, final WarningCallbBack warningCallback, final Builder extractBuilder) { if (supportRegExp()) { final Optional<String> regExp = MethodUtils.getParameterValueWithName(visitor.getLeftBrace(), visitor.getRightBrace(), method, ATTRIBUTE_REGEXP); if (regExp.isPresent()) { extractBuilder.regExp(regExp.get()); } else { logWarn(LOG_THE_ATTRIBUTE + ATTRIBUTE_REGEXP + LOG_IS_MANDATORY + method.getName(), warningCallback); extractBuilder.regExp(DEFAULT_REGEXP_VALUE); } final Optional<String> group = MethodUtils.getParameterValueWithName(visitor.getLeftBrace(), visitor.getRightBrace(), method, ATTRIBUTE_GROUP); if (group.isPresent()) { extractBuilder.group(group.get()); } } }