@Override public List<Element> getElement(final LoadRunnerVUVisitor visitor, final MethodCall method, final MethodcallContext ctx) { final ImmutableMappingMethod methodMapping = visitor.getCustomActionMappingMethod(method.getName()); if (methodMapping == null) { visitor.readSupportedFunctionWithWarn(method.getName(), ctx, "Cannot find mapping for method " + method.getName()); return Collections.emptyList(); } final Set<Integer> readIndex = new HashSet<>(); final Builder builder = ImmutableCustomAction.builder(); builder.type(methodMapping.getType()); builder.isHit(methodMapping.isHit()); builder.name(MappingValueUtil.parseMappingValue(visitor, method.getParameters(), methodMapping.getName(), method.getName(), counter, readIndex)); methodMapping.getParameters().forEach(p -> { final ImmutableCustomActionParameter.Builder paramBuilder = ImmutableCustomActionParameter.builder(); paramBuilder.name(p.getName()); paramBuilder.value(MappingValueUtil.parseMappingValue(visitor, method.getParameters(), p.getValue(), method.getName(), counter, readIndex)); paramBuilder.type(p.getType()); builder.addParameters(paramBuilder.build()); }); final CustomAction customAction = builder.build(); readIndex.addAll(methodMapping.getIgnoreArgs()); final Set<String> unreadParameters = getUnreadParameters(method.getParameters(), readIndex); if(unreadParameters.isEmpty()){ visitor.readSupportedFunction(method.getName(), ctx); } else { visitor.readSupportedFunctionWithWarn(method.getName(), ctx, "Unread parameter: " + unreadParameters.toString()); } return ImmutableList.of(customAction); }
/** * Fill a builder with attribute values from the provided {@code CustomActionParameter} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(CustomActionParameter instance) { Objects.requireNonNull(instance, "instance"); name(instance.getName()); value(instance.getValue()); type(instance.getType()); return this; }
private static ImmutableCustomAction createPressCustomAction(final String objectId, final String objectName, final String objectType, final String key) { return ImmutableCustomAction.builder() .name("Press GuiMainWindow (SAP)") .type("SapPress") .isHit(true) .parameters( ImmutableList.of(ImmutableCustomActionParameter.builder() .name("objectId").value(objectId).type(Type.TEXT).build(), ImmutableCustomActionParameter.builder() .name("objectName").value(objectName).type(Type.TEXT).build(), ImmutableCustomActionParameter.builder() .name("objectType").value(objectType).type(Type.TEXT).build(), ImmutableCustomActionParameter.builder() .name("key").value(key).type(Type.TEXT).build() )) .build(); }
private static ImmutableCustomAction createSetTextCustomAction(final String name, final String objectId, final String objectName, final String objectType, final String value, final Type valueType) { return ImmutableCustomAction.builder() .name("SetText GuiTextField (" + name + ")") .type("SapSetText") .isHit(false) .parameters( ImmutableList.of(ImmutableCustomActionParameter.builder() .name("objectId").value(objectId).type(Type.TEXT).build(), ImmutableCustomActionParameter.builder() .name("objectName").value(objectName).type(Type.TEXT).build(), ImmutableCustomActionParameter.builder() .name("objectType").value(objectType).type(Type.TEXT).build(), ImmutableCustomActionParameter.builder() .name("value").value(MethodUtils.unquote(value)).type(valueType).build() )) .build(); }