-
Notifications
You must be signed in to change notification settings - Fork 2
User Guide
- Java 8 or greater
- Maven
First of all we need to import the idl.jar and the reasoner.jar, available soon at the repository's releases. Then we need to add these dependencies to our pom.xml:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.xtext</groupId>
<artifactId>org.eclipse.xtext</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>1.0.47</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.15</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-compat-spec-parser</artifactId>
<version>1.0.47</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.dropbox.core</groupId>
<artifactId>dropbox-core-sdk</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>2.2</version>
</dependency>
Then, we need to create a folder with this directory ./src/test/resources in the project. There will be the .idl files, then we can change this directory. The OAS can be given by a .yaml or .json file or just a url, this is an example of a Reasoner instance:
Analyzer analyzer = new Analyzer("oas","no_deps.idl", "./src/test/resources/OAS_test_suite.yaml", "/oneParamBoolean", "get");
Where the:
- 1º Parameter is the specification type
- 2º Parameter is the idl file name
- 3º Parameter is the API specification path or url
- 4º Parameter is the path name
- 5º Parameter is the request type (Get, Post, Put or Delete)
This method will return a random valid requests for the IDL and OAS given, it will return a Map<String, String>, where the key is the parameter and the value is the parameter's value:
analyzer.randomRequest();
Returns a list of all the posible request, this method can take a long time if there are many possible solutions
analyzer.getAllRequest();
Returns the total number of possible requests to the operation.
analyzer.numberOfRequest()
This method will say if a parameter is or is not a dead parameter with a boolean. A parameter is dead if it cannot be included in any valid call to the API.
analyzer.isDeadParameter("p1");
You can see examples of this method in our Examples section
This method will say if a parameter, that assumes that the parameter is optional in the Api Specification, is or not a false optional with a boolean. A parameter is false optional if it is required (it must be included in all API calls to satisfy inter-parameter dependencies) despite being defined as optional.
analyzer.isFalseOptional("p1");
You can see examples of this method in our Examples section
This operation will return a boolean indicating whether the API specification is valid or not. An IDL specification is valid if it does not contain dead or false optional parameters.
analyzer.isValidIDL();
You can see examples of this method in our Examples section
This method uses a HashMap<String, String>, where the key is the parameter and the value the parameter's value to indicate if the request is valid or not with a boolean. A request is valid if it satisfies all the dependencies of the IDL specification.
Map<String, String> request = new HashMap<>();
request.put("p1", "false");
analyzer.validRequest(request)
You can see examples of this method in our Examples section
This operation is analogous to the previous one but the input request is partial or incomplete, meaning that some other parameters should still be included to make it a full valid request. This operation returns a boolean indicating whether the partial request is valid
Map<String, String> partialRequest = new HashMap<>();
partialRequest.put("p1", "not boolean");
analyzer.validPartialRequest(partialRequest);
You can see examples of this method in our Examples section
After the first execution, IDLReasoner will auto-generate a configuration file in .src/main/resources called "idl-resources.properties"
compiler=Minizinc
solver=Chuffed
fileRoute=src/test/resources
maxResults=100
- Compiler: Is the resolutor, currently IDLReasoner only supports Miniznc
- Solver: The compiler is the Minizinc solver, currently Chuffed and CoinBC are the solvers that works
- fileRoute: Is the file route where the IDL files are located
- maxResults: This property is for limit the results for all methods, if you don't want to limit the results, you can leave it blank