This document provides a comprehensive reference for all classes, methods, and annotations available in the current API Automation Framework.
Note: For future enhancements and roadmap, see Framework Analysis & Enhancement Roadmap and Technical Enhancements Guide.
Package: org.aditi.api_automation.config
Singleton class that provides access to the configuration factory.
public static ConfigFactory getConfig()
Returns an instance of the configuration factory.
Returns: ConfigFactory
- The configuration factory instance
Example:
ConfigFactory config = AppConfig.getConfig();
String baseUrl = config.getBaseUrl();
Package: org.aditi.api_automation.config
Interface defining configuration properties and methods for retrieving them.
String getProperty(String key)
Retrieves a configuration property by its key.
Parameters:
key
(String) - The property keyReturns: String
- The property value
Example:
String value = config.getProperty("CUSTOM_PROPERTY");
@ConfigProperty("BASE_URL")
String getBaseUrl()
@ConfigProperty("BASE_API_PATH")
String getBaseApiPath()
@ConfigProperty("REQRES_BASE_URL")
String getReqResBaseUrl()
@ConfigProperty("REQRES_BASE_API_PATH")
String getReqResBaseApiPath()
@ConfigProperty("REGISTER_PATH")
String getRegistrationPath()
@ConfigProperty("LOGIN_PATH")
String getLoginPath()
@ConfigProperty("LOGOUT_PATH")
String getLogoutPath()
Package: org.aditi.api_automation.config
Singleton class for loading and managing configuration properties.
public static CustomConfigManager getInstance()
Returns the singleton instance of CustomConfigManager.
Returns: CustomConfigManager
- The singleton instance
public static String getProperty(String key)
Retrieves a property value by key.
Parameters:
key
(String) - The property keyReturns: String
- The property value, or null if not found
Package: org.aditi.api_automation.api
Example API class demonstrating user-related API operations.
public static Response userLogin(UserLoginRequest userLoginRequest)
Performs user login operation.
Parameters:
userLoginRequest
(UserLoginRequest) - The login request objectReturns: Response
- The REST Assured response
Example:
UserLoginRequest request = new UserLoginRequest("username", "password");
Response response = User.userLogin(request);
Package: org.aditi.api_automation.requests
Interface for creating request specifications using JSON templates.
@RequestTemplateFile("requests/login.json")
RequestSpecBuilder loginRequest(String username, String password)
Creates a login request specification using the login.json template.
Parameters:
username
(String) - The usernamepassword
(String) - The passwordReturns: RequestSpecBuilder
- The REST Assured request specification builder
Example:
RequestSpecBuilder spec = requestFactory.loginRequest("user", "pass");
Package: org.aditi.api_automation.requests
Utility class for accessing the request factory.
public static RequestFactory getRequestFactory()
Returns the request factory instance.
Returns: RequestFactory
- The request factory instance
Example:
RequestFactory factory = AppRequests.getRequestFactory();
Package: org.aditi.api_automation.asserts
Abstract base class for response validation with fluent API.
public SELF_TYPE httpStatusCodeIs(int statusCode)
Validates that the response has the specified HTTP status code.
Parameters:
statusCode
(int) - The expected HTTP status codeReturns: SELF_TYPE
- Self reference for method chaining
Example:
ValidateGenericResponse.assertThat(response)
.httpStatusCodeIs(200);
public SELF_TYPE containsValue(String value)
Validates that the response body contains the specified value.
Parameters:
value
(String) - The value to search for in the response bodyReturns: SELF_TYPE
- Self reference for method chaining
Example:
ValidateGenericResponse.assertThat(response)
.containsValue("success");
public SELF_TYPE matchesSchema(String fileClassPath)
Validates that the response matches the specified JSON schema.
Parameters:
fileClassPath
(String) - The classpath path to the JSON schema fileReturns: SELF_TYPE
- Self reference for method chaining
Example:
ValidateGenericResponse.assertThat(response)
.matchesSchema("response/schemas/user-schema.json");
public SELF_TYPE validateJsonPathData(String jsonPath, Object expectedValue)
Validates that the JSON path expression returns the expected value.
Parameters:
jsonPath
(String) - The JSON path expressionexpectedValue
(Object) - The expected valueReturns: SELF_TYPE
- Self reference for method chaining
Example:
ValidateGenericResponse.assertThat(response)
.validateJsonPathData("data.id", 1)
.validateJsonPathData("data.name", "John Doe");
public void assertAll()
Executes all soft assertions and reports any failures.
Example:
ValidateGenericResponse.assertThat(response)
.httpStatusCodeIs(200)
.containsValue("success")
.assertAll();
Package: org.aditi.api_automation.asserts
Concrete implementation of ValidateResponse for generic response validation.
public static ValidateGenericResponse assertThat(Response response)
Creates a new ValidateGenericResponse instance for the given response.
Parameters:
response
(Response) - The REST Assured response to validateReturns: ValidateGenericResponse
- A new validation instance
Example:
ValidateGenericResponse.assertThat(response)
.httpStatusCodeIs(200)
.containsValue("success");
Package: org.aditi.api_automation.annotations
Annotation for marking configuration property methods.
@ConfigProperty("PROPERTY_KEY")
String getPropertyMethod();
Parameters:
value
(String) - The configuration property keyExample:
@ConfigProperty("BASE_URL")
String getBaseUrl();
Package: org.aditi.api_automation.annotations
Annotation for marking request template methods.
@RequestTemplateFile("requests/template.json")
RequestSpecBuilder methodName();
Parameters:
value
(String) - The path to the JSON template fileExample:
@RequestTemplateFile("requests/login.json")
RequestSpecBuilder loginRequest(String username, String password);
Package: org.aditi.api_automation.dto
Data transfer object for user login requests.
username
(String) - The usernamepassword
(String) - The passwordpublic UserLoginRequest()
Default constructor.
public UserLoginRequest(String username, String password)
Parameterized constructor.
Parameters:
username
(String) - The usernamepassword
(String) - The passwordpublic String getUsername()
Gets the username.
Returns: String
- The username
public void setUsername(String username)
Sets the username.
Parameters:
username
(String) - The usernamepublic String getPassword()
Gets the password.
Returns: String
- The password
public void setPassword(String password)
Sets the password.
Parameters:
password
(String) - The passwordExample:
UserLoginRequest request = new UserLoginRequest("john.doe", "password123");
Package: org.aditi.api_automation.exception
Exception thrown when a configuration property is not found.
public PropertyNotFoundException(String message)
Creates a new PropertyNotFoundException with the specified message.
Parameters:
message
(String) - The error messageExample:
throw new PropertyNotFoundException("Property not found for key: " + key);
Package: org.aditi.api_automation.handlers
Dynamic proxy implementation for the ConfigFactory interface.
public static ConfigFactory newInstance(CustomConfigManager configManager)
Creates a new ConfigFactory proxy instance.
Parameters:
configManager
(CustomConfigManager) - The configuration managerReturns: ConfigFactory
- A new proxy instance
Example:
ConfigFactory proxy = ConfigFactoryProxy.newInstance(configManager);
Package: org.aditi.api_automation.handlers
Invocation handler for RequestFactory dynamic proxy.
public static RequestFactory newInstance()
Creates a new RequestFactory proxy instance.
Returns: RequestFactory
- A new proxy instance
Example:
RequestFactory factory = RequestFactoryInvocationHandler.newInstance();
Package: org.aditi.api_automation.constants
Constants used throughout the framework.
public static final String CONFIG_FILE_NAME = "config.properties"
The default configuration file name.
public static final String ENVIRONMENT_PROPERTY = "faasos_env"
The system property for specifying the environment.
public static final String DEFAULT_ENVIRONMENT = "dev"
The default environment if none is specified.
package org.aditi.api_automation.steps;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.restassured.response.Response;
import org.aditi.api_automation.api.User;
import org.aditi.api_automation.asserts.ValidateGenericResponse;
import org.aditi.api_automation.dto.UserLoginRequest;
public class UserSteps {
private Response response;
private UserLoginRequest loginRequest;
@Given("I have valid user credentials")
public void i_have_valid_user_credentials() {
loginRequest = new UserLoginRequest("testuser", "testpass");
}
@When("I attempt to login")
public void i_attempt_to_login() {
response = User.userLogin(loginRequest);
}
@Then("I should receive a successful login response")
public void i_should_receive_a_successful_login_response() {
ValidateGenericResponse.assertThat(response)
.httpStatusCodeIs(200)
.matchesSchema("response/schemas/login-schema.json")
.validateJsonPathData("token", "QpwL5tke4Pnpja7X4")
.containsValue("success");
}
}
// ConfigFactory.java
@ConfigProperty("API_BASE_URL")
String getApiBaseUrl();
@ConfigProperty("AUTH_TOKEN")
String getAuthToken();
// api.properties
API_BASE_URL=https://api.example.com
AUTH_TOKEN=your-auth-token
// Usage
String baseUrl = AppConfig.getConfig().getApiBaseUrl();
String token = AppConfig.getConfig().getAuthToken();
// RequestFactory.java
@RequestTemplateFile("requests/user-create.json")
RequestSpecBuilder createUserRequest(String name, String email);
// requests/user-create.json
{
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer "
},
"body": {
"name": "",
"email": ""
}
}
// Usage
RequestSpecBuilder spec = AppRequests.getRequestFactory()
.createUserRequest("John Doe", "john@example.com");
This API reference provides comprehensive information about all the classes, methods, and annotations available in the current framework. For future enhancements and roadmap, refer to the Framework Analysis and Technical Enhancements documents.