Class MethodCallBuilder
- java.lang.Object
-
- us.abstracta.jmeter.javadsl.codegeneration.MethodCallBuilder
-
- Direct Known Subclasses:
DslBackendListener.BackendListenerCodeBuilder,DslCsvDataSet.CodeBuilder,DslDefaultThreadGroup.CodeBuilder,DslJsonAssertion.CodeBuilder,DslJsonExtractor.CodeBuilder,DslTestFragmentController.CodeBuilder,PercentController.CodeBuilder,SimpleThreadGroupHelper.CodeBuilder,SingleGuiClassCallBuilder,SingleTestElementCallBuilder,UltimateThreadGroupHelper.CodeBuilder
public abstract class MethodCallBuilder extends Object
Builds a method call for a particular DSL test element.Almost (there might be some exceptions) every DSL test element should have an associated MethodCallBuilder (as inner class) which is in charge to generate the DSL code (in fact an instance of MethodCall used to generate the code) for that test element when proper tree node is found in a JMeter test plan.
Whenever you implement a new DSL test element remember creating a nested class named CodeBuilder extending MethodCallBuilder with the proper logic for generating its DSL code. Check
DslTestPlan.CodeBuilderfor an example.- Since:
- 0.45
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Method>builderMethods
-
Constructor Summary
Constructors Modifier Constructor Description protectedMethodCallBuilder(List<Method> builderMethods)This constructor is used by the DslCodeGenerator to instantiate MethodCallBuilders providing them their associated builder methods found in DSL classes registered on the DslCodeGenerator.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract MethodCallbuildMethodCall(MethodCallContext context)Generates the method call instance for the particular DSL test element.protected MethodCallbuildMethodCall(MethodParam... params)Builds a method call for the given set of parameters using one of registered builder methods.protected static StringgetBuilderOptionName(Class<?> builderClass, String optionName)abstract booleanmatches(MethodCallContext context)Allows checking if this builder can build method calls for the given context.intorder()This method allows specifying an order over builders.protected static Stream<org.apache.jmeter.testelement.property.JMeterProperty>propertyIterator2Stream(org.apache.jmeter.testelement.property.PropertyIterator iter)
-
-
-
Constructor Detail
-
MethodCallBuilder
protected MethodCallBuilder(List<Method> builderMethods)
This constructor is used by the DslCodeGenerator to instantiate MethodCallBuilders providing them their associated builder methods found in DSL classes registered on the DslCodeGenerator.- Parameters:
builderMethods- the list of builder methods found in the DSL classes associated to this MethodCallBuilder parent DSL test element
-
-
Method Detail
-
matches
public abstract boolean matches(MethodCallContext context)
Allows checking if this builder can build method calls for the given context.This method is invoked in every registered MethodCallBuilder, until one is found that matches.
- Parameters:
context- provides information used to determine if a method call might be created by this builder. For example: JMeter test plan tree node test element, parent context, a map of entries to host custom information, etc.- Returns:
- true if this builder knows how to build a method call for the context, false otherwise.
- Since:
- 0.52
-
buildMethodCall
protected abstract MethodCall buildMethodCall(MethodCallContext context)
Generates the method call instance for the particular DSL test element.You can check
DslTestPlan.CodeBuilderto get an idea of how a general implementation of this method looks likeIf you find a scenario where your MethodCallBuilder applies to the given context, but no code has to be generated for it, then use
MethodCall.emptyCall()to return a call that generates no code.- Parameters:
context- provides all information that might be required to generate the method call. For example: JMeter test plan tree node test element, parent context, a map of entries to host custom information, etc.- Returns:
- generated method call for the DSL test element.
-
buildMethodCall
protected MethodCall buildMethodCall(MethodParam... params)
Builds a method call for the given set of parameters using one of registered builder methods.This method is the starting point for creating the MethodCall returned by
buildMethodCall(MethodCallContext).- Parameters:
params- contains the list of parameters to find the proper builder method and associate to the method call. If the MethodCall accepts as parameter children DSL test elements, then remember adding an array class forChildrenParam(eg:new ChildrenParam<>(TestPlanChild[].class)).- Returns:
- generated method call.
- Throws:
UnsupportedOperationException- if no builder method is found for the given parameters.
-
order
public int order()
This method allows specifying an order over builders.Low values for order will make builders execute first than higher values.
This is handy when the order is relevant, for instance if a builder is more generic than others and should be used as fallback when others don't match.
No need for specifying an order for each builder. In most of the cases using the default value is ok. Only overwrite when you need a specific order between builders (implementing fallback of builders).
- Returns:
- a number used to order this builder among other existing values.
- Since:
- 0.60
-
propertyIterator2Stream
protected static Stream<org.apache.jmeter.testelement.property.JMeterProperty> propertyIterator2Stream(org.apache.jmeter.testelement.property.PropertyIterator iter)
-
-