com.neotys.neoload.model.readers.loadrunner.method.LrgetattribstringMethod Maven / Gradle / Ivy
package com.neotys.neoload.model.readers.loadrunner.method;
import java.util.Collections;
import java.util.List;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.neotys.neoload.model.core.Element;
import com.neotys.neoload.model.parsers.CPP14Parser.MethodcallContext;
import com.neotys.neoload.model.readers.loadrunner.LoadRunnerVUVisitor;
import com.neotys.neoload.model.readers.loadrunner.MethodCall;
import com.neotys.neoload.model.readers.loadrunner.MethodUtils;
import com.neotys.neoload.model.repository.ImmutableEvalString;
public class LrgetattribstringMethod implements LoadRunnerMethod {
public LrgetattribstringMethod() {
super();
}
@Override
public List getElement(final LoadRunnerVUVisitor visitor, final MethodCall method, final MethodcallContext ctx) {
Preconditions.checkNotNull(method);
Preconditions.checkNotNull(method.getParameters(), method.getName() + " method must have a parameter");
if(method.getParameters().isEmpty()){
visitor.readSupportedFunctionWithWarn(method.getName(), ctx, method.getName() + " method must have a parameter");
return Collections.emptyList();
}
visitor.readSupportedFunction(method.getName(), ctx);
final String returnValue = MethodUtils.normalizeString(visitor.getLeftBrace(), visitor.getRightBrace(), method.getParameters().get(0));
return ImmutableList.of(ImmutableEvalString.builder().name(MethodUtils.unquote(method.getName())).returnValue(returnValue).build());
}
}