public abstract class MethodCallBuilder extends Object
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.CodeBuilder for an example.
| Modifier and Type | Field and Description |
|---|---|
protected List<Method> |
builderMethods |
| Modifier | Constructor and Description |
|---|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract MethodCall |
buildMethodCall(MethodCallContext context)
Generates the method call instance for the particular DSL test element.
|
protected MethodCall |
buildMethodCall(MethodParam... params)
Builds a method call for the given set of parameters using one of registered builder methods.
|
protected static String |
getBuilderOptionName(Class<?> builderClass,
String optionName) |
abstract boolean |
matches(MethodCallContext context)
Allows checking if this builder can build method calls for the given context.
|
int |
order()
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) |
protected MethodCallBuilder(List<Method> builderMethods)
builderMethods - the list of builder methods found in the DSL classes associated to this
MethodCallBuilder parent DSL test elementpublic abstract boolean matches(MethodCallContext context)
This method is invoked in every registered MethodCallBuilder, until one is found that matches.
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.protected abstract MethodCall buildMethodCall(MethodCallContext context)
You can check DslTestPlan.CodeBuilder to get an idea
of how a general implementation of this method looks like
If 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.
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.protected MethodCall buildMethodCall(MethodParam... params)
This method is the starting point for creating the MethodCall returned by
buildMethodCall(MethodCallContext).
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 for ChildrenParam (eg:
new ChildrenParam<>(TestPlanChild[].class)).UnsupportedOperationException - if no builder method is found for the given parameters.public int order()
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).
protected static Stream<org.apache.jmeter.testelement.property.JMeterProperty> propertyIterator2Stream(org.apache.jmeter.testelement.property.PropertyIterator iter)
Copyright © 2024. All rights reserved.