public static class ApiCommand.Options extends Object
[option...] [apiDef]
where each option is one of the following:
-C | -S | -D
If -C is given, produce test models for an API client, i.e. API response tests.
If -S is given, produce test models for an API server, i.e. API request tests.
If -D is given, produce request test cases for an API server, i.e. API request tests.
If none of these is given, the default is -S.
-X
If specified, test models are generated based on the examples specified in the apiDef.
Otherwise, by default, test models are created by generating random input values.
-I
Produce an input definition file
for either an API client (-C) or an API server (-S).
If omitted, produce either the corresponding test definition file
or list of request test cases
(-D).
-c M[,R]
Defines how input modelling and request case resolution conditions are reported. Both M
(for modelling conditions) and R
(for
resolution conditions) must be one of log
, fail
, or ignore
.
If log
is specified, conditions are reported using log messages.
If fail
is specified, any condition will cause an exception. If ignore
is specified, all conditions
are silently ignored. If R
is omitted, the default is log
. If -c is omitted, the default is log,log
.
-f outFile
If -f is defined, output is written to the specified outFile, relative to the given outDir.
If omitted, the default outFile is derived from the apiDef.
-o outDir
If -o is defined, output is written to the specified directory.
If omitted, the default outDir is the directory containing the apiDef or,
if reading from standard input, the current working directory. If an output path cannot be
derived, output is written to standard output.
-R
If specified, tests will be generated assuming that the API will strictly enforce exclusion of "readOnly"
properties from request parameters. If omitted, no strict enforcement is assumed.
-W
If specified, tests will be generated assuming that the API will strictly enforce exclusion of "writeOnly"
properties from responses. If omitted, no strict enforcement is assumed.
-J
If -J is defined, test definition output is transformed into Java source code for a JUnit
test class. The resulting Java source file is written to the specified outDir.
Ignored if -I is specified.
-H
If -H is defined, test definition output is transformed into an HTML report. The resulting HTML file is written to the specified outDir.
Ignored if -I is specified.
-x transformDef
If -x is defined, test definition output is transformed according to the XSLT transform defined
by the transformDef file. If relative, the transformDef path is assumed to be relative to the
directory containing the apiDef.
-p name=value
Defines the value of a transform parameter. Any number of -p options may be specified.
This option is meaningful only if the -x or -J option is given.
-r seed
When -D is specified, use the given random number seed to generate request test case input values.
If omitted, the default random number seed is derived from the apiDef name.
-m maxTries
When -D is specified, defines the maximum attempts made to resolve a request test case input value before reporting failure.
If omitted, the default value is 10000.
-T contentType
Defines the content type of the OpenApi definition. The contentType must be one of "json", "yaml", or "yml".
If omitted, the default content type is derived from the apiDef name. If the apiDef is read from standard
input or does not have a recognized extension, the default content type is "json".
-v
Prints the current command version identifier to standard output.
apiDef
An OpenAPI v3 API definition is read from the given apiDef file. If omitted, the API definition is
read from standard input. If no outFile is specified, output is written to a default file
derived from the apiDef or, if no apiDef is given, to standard output.
Suppose that the base name of apiDef (less any extension) is B. Then, assuming
defaults for all options, output will be a test definition for API requests written to a file
named "B-Requests-Test.json". If -C is specified, output will be a test
definition for API responses written to a file named "B-Responses-Test.json".
If -D is specified, output will be a list of request test cases written to a file named "B-Request-Cases.json".
If -I is specified, output will be the corresponding input definition, written to either
"B-Requests-Input.json" or "B-Responses-Input.json", respectively.
Modifier and Type | Class and Description |
---|---|
static class |
ApiCommand.Options.Builder |
static class |
ApiCommand.Options.TransformType |
Constructor and Description |
---|
Options()
Creates a new Options object.
|
Options(String[] args)
Creates a new Options object.
|
Modifier and Type | Method and Description |
---|---|
static ApiCommand.Options.Builder |
builder()
Returns a new Options builder.
|
File |
getApiDef()
Returns the Open API v3 API definition file
|
String |
getContentType()
Returns the OpenApi definition file content type.
|
Long |
getDefaultRandomSeed()
Returns the default random number generator seed for request case resolution.
|
int |
getMaxTries()
Returns the maximum attempts made to resolve a request test case input value before reporting failure..
|
ModelOptions |
getModelOptions()
Returns the input modelling options.
|
File |
getOutDir()
Returns the output directory for command output.
|
File |
getOutFile()
Returns the output file for command output.
|
Long |
getRandomSeed()
Returns the random number generator seed for request case resolution.
|
ResolverContext |
getResolverContext()
Returns the request case resolution options.
|
ModelOptions.Source |
getSource()
Returns the source of API input definitions.
|
File |
getTransformDef()
Returns the transform file.
|
Map<String,Object> |
getTransformParams()
Returns the transform parameter bindings.
|
ApiCommand.Options.TransformType |
getTransformType()
Returns the output transform type.
|
File |
getWorkingDir()
Returns the current working directory used to complete relative path names.
|
protected void |
handleArgs(String[] args,
int i)
Handles the non-option arguments i, i+1, ...
|
protected int |
handleOption(String[] args,
int i)
Handles the i'th option and return the index of the next argument.
|
boolean |
isRequestCases()
Returns if test case output consists of a list of request test cases (true) or a test definition (false).
|
boolean |
isServerTest()
Return if output if for testing an API server (true) or an API client (false).
|
boolean |
isTests()
Returns if output consists of a test definition (true) or an input definition (false).
|
protected void |
printUsage()
Prints usage information to standard error.
|
void |
setApiDef(File apiDef)
Changes the Open API v3 API definition file
|
void |
setConditionNotifiers(String notifierList)
Changes condition notifiers for input modelling and request case resolution conditions.
|
void |
setContentType(String option)
Changes the OpenApi definition file content type.
|
void |
setMaxTries(int maxTries)
Changes the maximum attempts made to resolve a request test case input value before reporting failure..
|
void |
setModelOptions(ModelOptions modelOptions)
Changes the input modelling options.
|
void |
setOnCondition(String notifier)
Deprecated.
Replace using
setOnModellingCondition() . |
void |
setOnModellingCondition(String notifier)
Changes the input modelling condition notifier.
|
void |
setOnResolverCondition(String notifier)
Changes the request case resolution condition notifier.
|
void |
setOutDir(File outDir)
Changes the output directory for command output.
|
void |
setOutFile(File outFile)
Changes the output file for command output.
|
void |
setRandomSeed(Long seed)
Changes the random number generator seed for request case resolution.
|
void |
setReadOnlyEnforced(boolean enforced)
Changes if "readOnly" properties are strictly enforced.
|
void |
setRequestCases(boolean requestCases)
Changes if test case output consists of a list of request test cases (true) or a test definition (false).
|
void |
setResolverContext(ResolverContext resolverContext)
Changes the request case resolution options.
|
void |
setServerTest(boolean serverTest)
Changes if output if for testing an API server (true) or an API client (false).
|
void |
setShowVersion(boolean showVersion)
Changes if the current version should be shown.
|
void |
setSource(ModelOptions.Source source)
Changes the source of API input definitions.
|
void |
setSource(String source)
Changes the source of API input definitions.
|
void |
setTests(boolean tests)
Changes if output consists of a test definition (true) or an input definition (false).
|
void |
setTransformDef(File transformDef)
Changes the transform file.
|
void |
setTransformParams(Map<String,Object> params)
Changes the transform parameter bindings.
|
void |
setTransformType(ApiCommand.Options.TransformType transformType)
Changes the output transform type.
|
void |
setWorkingDir(File workingDir)
Changes the current working directory used to complete relative path names.
|
void |
setWriteOnlyEnforced(boolean enforced)
Changes if "writeOnly" properties are strictly enforced.
|
boolean |
showVersion()
Returns if the current version should be shown.
|
protected void |
throwHelpException()
Throws a HelpException after printing usage information to standard error.
|
String |
toString() |
public Options()
public Options(String[] args)
protected int handleOption(String[] args, int i)
protected void handleArgs(String[] args, int i)
protected void throwHelpException()
protected void printUsage()
public void setOutDir(File outDir)
public File getOutDir()
public void setOutFile(File outFile)
public File getOutFile()
public void setServerTest(boolean serverTest)
public boolean isServerTest()
public void setTests(boolean tests)
public boolean isTests()
public void setRequestCases(boolean requestCases)
public boolean isRequestCases()
public void setSource(ModelOptions.Source source)
public void setSource(String source)
public ModelOptions.Source getSource()
public void setTransformDef(File transformDef)
public File getTransformDef()
public void setTransformType(ApiCommand.Options.TransformType transformType)
public ApiCommand.Options.TransformType getTransformType()
public void setTransformParams(Map<String,Object> params)
public Map<String,Object> getTransformParams()
public void setContentType(String option)
public String getContentType()
public void setModelOptions(ModelOptions modelOptions)
public ModelOptions getModelOptions()
public void setResolverContext(ResolverContext resolverContext)
public ResolverContext getResolverContext()
public void setRandomSeed(Long seed)
public Long getRandomSeed()
public Long getDefaultRandomSeed()
public void setMaxTries(int maxTries)
public int getMaxTries()
public void setConditionNotifiers(String notifierList)
public void setOnModellingCondition(String notifier)
public void setOnResolverCondition(String notifier)
@Deprecated public void setOnCondition(String notifier)
setOnModellingCondition()
.public void setReadOnlyEnforced(boolean enforced)
public void setWriteOnlyEnforced(boolean enforced)
public void setApiDef(File apiDef)
public File getApiDef()
public void setWorkingDir(File workingDir)
public File getWorkingDir()
public void setShowVersion(boolean showVersion)
public boolean showVersion()
public static ApiCommand.Options.Builder builder()
Copyright © 2024 The Cornutum Project. All rights reserved.