Skip to content
Snippets Groups Projects

feat: Add support for response body validation

Files
2
@@ -36,12 +36,24 @@ public class TestCaseHelper {
* @return the desired endpoint test case
*/
public static EndpointTestCase buildSuccessCase(String path, String[] params, String schemaLocation) {
return prepareSuccessCase(path, params, schemaLocation).build();
}
/**
* Creates an EndpointTestCase.builder to allow the user to add any extra test
* parameters. As well as overwrite any of the default success case parameters.
*
* @param path the endpoint URL
* @param params the request path/query parameters
* @param schemaLocation the schema location
* @return the desired endpoint test case builder
*/
public static EndpointTestCase.Builder prepareSuccessCase(String path, String[] params, String schemaLocation) {
return EndpointTestCase.builder()
.setPath(path)
.setParams(Optional.of(params))
.setResponseContentType(ContentType.JSON)
.setSchemaLocation(schemaLocation)
.build();
.setSchemaLocation(schemaLocation);
}
/**
@@ -64,6 +76,23 @@ public class TestCaseHelper {
.build();
}
/**
* Creates a EndpointTestCase object with the desired path and params.
* Used to test an unauthorized request. Status code 403 (Unauthorized) is
* assumed.
*
* @param path the endpoint URL
* @param params the request path/query parameters
* @return the desired endpoint test case
*/
public static EndpointTestCase buildUnauthorizedCase(String path, String[] params) {
return EndpointTestCase.builder()
.setPath(path)
.setParams(Optional.of(params))
.setStatusCode(403)
.build();
}
/**
* Creates a EndpointTestCase object with the desired path and params.
* Used to test a URL that doesn't exist. Status code 404 (Not Found) is
Loading