private static ImmutableCustomAction createPressEnter() { return createPressCustomAction( "${SAP_ACTIVE_SESSION}/${SAP_ACTIVE_WINDOW}", "${SAP_ACTIVE_WINDOW}", "GuiMainWindow", "Enter" ); }
public LoadRunnerReader(final EventListener eventListener, final String folder, final String projectName, final String additionalCustomActionMappingContent) { super(folder); this.eventListener = eventListener; this.projectName = projectName; this.lrSupportedMethods = new LoadRunnerSupportedMethods(additionalCustomActionMappingContent); }
public ImmutableMappingMethod getCustomActionMappingMethod(String methodName) { return lrSupportedMethods.getCustomActionMappingMethod(methodName); } }
private final LoadRunnerMethod internalLoadMethod(final String methodName) { if (methodName == null) { return null; } if (customActionMappingLoader.getMethod(methodName)!=null) { return new CustomActionMethod(); } final String lowerCaseMethodName = methodName.replaceAll("_", "").toLowerCase(); if (lowerCaseMethodName.length() < 2) { return null; } final String fullQualifiedMethodName = "com.neotys.neoload.model.readers.loadrunner.method." + lowerCaseMethodName.substring(0, 1).toUpperCase() + lowerCaseMethodName.substring(1) + "Method"; try { return (LoadRunnerMethod) Class.forName(fullQualifiedMethodName).getConstructor().newInstance(); } catch (Exception e) { } if("lr_start_sub_transaction".equals(methodName)) return new LrstarttransactionMethod(); if("lr_end_sub_transaction".equals(methodName)) return new LrendtransactionMethod(); if("lr_param_sprintf".equals(methodName)) return new SprintfMethod(); return null; }
final ContinuationOption continuationOption = ContinuationOption.valueOf(continuationOptionString); final ExitStatus exitStatus = ExitStatus.valueOf(exitStatusString); return buildStopElements(method, exitStatus); case LR_EXIT_ITERATION_AND_CONTINUE: case LR_EXIT_MAIN_ITERATION_AND_CONTINUE: return buildGoToNextIterations(method, exitStatus); default:
public LoadRunnerMethod get(final String methodName) { if(supportedMethods.containsKey(methodName)){ return supportedMethods.get(methodName); } final LoadRunnerMethod method = internalLoadMethod(methodName); if (containerInFileMethod != null && containerInFileMethod.containsContainer(methodName)) { return containerInFileMethod; } supportedMethods.put(methodName, method); return method; }
private static ImmutableCustomAction createLanguage(final MethodCall method) { return createSetTextCustomAction( "language", "${SAP_ACTIVE_SESSION}/${SAP_ACTIVE_WINDOW}/usr/txtRSYST-LANGU", "RSYST-LANGU", GUI_TEXT_FIELD, method.getParameters().get(3), Type.TEXT ); }
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 List<Element> buildGoToNextIterations(final MethodCall method, final ExitStatus exitStatus) { ImmutableList.Builder<Element> builder = ImmutableList.builder(); buildJavaScriptIfNeeded(exitStatus).ifPresent(builder::add); builder.add(ImmutableGoToNextIteration.builder() .name(MethodUtils.unquote(method.getName())) .build()); return builder.build(); }
public LoadRunnerMethod getLrSupportedMethod(final String methodName) { return lrSupportedMethods.get(methodName); }
private Optional<Element> buildJavaScriptIfNeeded(final ExitStatus exitStatus) { switch (exitStatus) { case LR_PASS: return Optional.empty(); case LR_AUTO: return Optional.of(buildJavaScript("context.fail();")); case LR_FAIL: return Optional.of(buildJavaScript("context.fail('Exit with failure status');")); default: throw new IllegalArgumentException("Do not support the status exit: " + exitStatus); } }
@Override public List<Element> getElement(final LoadRunnerVUVisitor visitor, final MethodCall method, final MethodcallContext ctx) { Preconditions.checkNotNull(method); Preconditions.checkNotNull(method.getParameters(), method.getName() + " method must have a parameter"); Preconditions.checkArgument(!method.getParameters().isEmpty(), method.getName() + " method must have a parameter"); final String delayInS = method.getParameters().get(0); final String delayInMs = parseDelay(visitor, method, ctx, delayInS); return ImmutableList.of(ImmutableDelay.builder().name("delay").delay(delayInMs).isThinkTime(true).build()); }
private void handleLBRB(final LoadRunnerVUVisitor visitor, final MethodCall method, final Builder extractBuilder) { if (supportLBRB()) { final String startExpression = MethodUtils.getValueAndVerifyRestrictionForBoundary(visitor.getLeftBrace(), visitor.getRightBrace(), method, MethodUtils.getParameterStartingWith(method, ATTRIBUTE_LB)); final String endExpression = MethodUtils.getValueAndVerifyRestrictionForBoundary(visitor.getLeftBrace(), visitor.getRightBrace(), method, MethodUtils.getParameterStartingWith(method, ATTRIBUTE_RB)); extractBuilder.startExpression(startExpression).endExpression(endExpression); } }
private static ImmutableCustomAction createClientNum(final MethodCall method) { return createSetTextCustomAction( "clientnum", "${SAP_ACTIVE_SESSION}/${SAP_ACTIVE_WINDOW}/usr/txtRSYST-MANDT", "RSYST-MANDT", GUI_TEXT_FIELD, method.getParameters().get(2), Type.TEXT ); }
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 ImmutableList<Element> buildStopElements(final MethodCall method, final ExitStatus exitStatus) { ImmutableList.Builder<Element> builder = ImmutableList.builder(); buildJavaScriptIfNeeded(exitStatus).ifPresent(builder::add); builder.add(ImmutableStop.builder() .name(MethodUtils.unquote(method.getName())) .startNewVirtualUser(true) .build()); return builder.build(); }
private static ImmutableCustomAction createUsername(final MethodCall method) { return createSetTextCustomAction( "username", "${SAP_ACTIVE_SESSION}/${SAP_ACTIVE_WINDOW}/usr/txtRSYST-BNAME", "RSYST-BNAME", GUI_TEXT_FIELD, method.getParameters().get(0), Type.TEXT ); }
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 static ImmutableCustomAction createPassword(final MethodCall method) { return createSetTextCustomAction( "password", "${SAP_ACTIVE_SESSION}/${SAP_ACTIVE_WINDOW}/usr/pwdRSYST-BCODE", "RSYST-BCODE", GUI_TEXT_FIELD, method.getParameters().get(1), Type.PASSWORD ); }
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); } }