Class DslCodeGenerator
- java.lang.Object
-
- us.abstracta.jmeter.javadsl.codegeneration.DslCodeGenerator
-
- All Implemented Interfaces:
MethodCallBuilderRegistry
public class DslCodeGenerator extends Object implements MethodCallBuilderRegistry
Generates DSL code from JMX files.Take into account that code generation is a continuous improving process, so please report any unexpected or missing conversions as issues in repository, so we keep improving it.
Check
MethodCallBuilderfor instructions on how to implement DSL code generation for new DSL test elements.- Since:
- 0.45
- See Also:
MethodCallBuilder
-
-
Constructor Summary
Constructors Constructor Description DslCodeGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DslCodeGeneratoraddBuilders(MethodCallBuilder... builders)Allows registering MethodCallBuilders that are not associated to a DSL builder method.DslCodeGeneratoraddBuildersFrom(Class<?>... dslClasses)Allows registering DSL classes containing builder methods, which can be used to generate DSL code for.DslCodeGeneratoraddDependency(Class<?> dependencyClass, String dependencyLocator)Allows registering libraries required to use a specific class.MethodCallbuildMethodCallFromJmxFile(File file)<T extends MethodCallBuilder>
TfindBuilderByClass(Class<T> builderClass)Optional<MethodCallBuilder>findBuilderMatchingContext(MethodCallContext context)StringgenerateCodeFromJmx(File file)Generates DSL code from JMX file.DslCodeGeneratorsetBuilderOption(String optionName, Object optionValue)
-
-
-
Method Detail
-
addBuildersFrom
public DslCodeGenerator addBuildersFrom(Class<?>... dslClasses)
Allows registering DSL classes containing builder methods, which can be used to generate DSL code for.This method allows you to register DSL classes from none core modules or your own custom DSL classes. This is the way DslGenerators can discover new DSL test elements, and their associated MethodCallBuilder instances, to generate code for.
- Parameters:
dslClasses- are the classes containing builder methods.- Returns:
- the DslCodeGenerator instance for further configuration or usage.
-
addBuilders
public DslCodeGenerator addBuilders(MethodCallBuilder... builders)
Allows registering MethodCallBuilders that are not associated to a DSL builder method.This is helpful when some element has no DSL builder method counterpart, but still there is a way to convert the element (eg: ignoring it all together, only converting children, etc).
- Parameters:
builders- list of MethodCallBuilders to register into the generator.- Returns:
- the DslCodeGenerator instance for further configuration or usage.
- Since:
- 0.50
-
addDependency
public DslCodeGenerator addDependency(Class<?> dependencyClass, String dependencyLocator)
Allows registering libraries required to use a specific class.- Parameters:
dependencyClass- is the class to register a library for.dependencyLocator- the jbang library locator for the library containing the class.- Returns:
- the DslCodeGenerator instance for further configuration or usage.
- Since:
- 0.62
-
generateCodeFromJmx
public String generateCodeFromJmx(File file) throws IOException
Generates DSL code from JMX file.- Parameters:
file- is the JMX file from which DSL code will be generated.- Returns:
- the generated DSL MethodCall used to generate code from.
- Throws:
IOException- when there is some problem reading the file.
-
buildMethodCallFromJmxFile
public MethodCall buildMethodCallFromJmxFile(File file) throws IOException
- Throws:
IOException
-
findBuilderMatchingContext
public Optional<MethodCallBuilder> findBuilderMatchingContext(MethodCallContext context)
- Specified by:
findBuilderMatchingContextin interfaceMethodCallBuilderRegistry
-
findBuilderByClass
public <T extends MethodCallBuilder> T findBuilderByClass(Class<T> builderClass)
- Specified by:
findBuilderByClassin interfaceMethodCallBuilderRegistry
-
setBuilderOption
public DslCodeGenerator setBuilderOption(String optionName, Object optionValue)
-
-