Skip to content
Snippets Groups Projects

feat: Add support for response body validation

2 files
+ 67
5
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -36,12 +36,24 @@ public class TestCaseHelper {
@@ -36,12 +36,24 @@ public class TestCaseHelper {
* @return the desired endpoint test case
* @return the desired endpoint test case
*/
*/
public static EndpointTestCase buildSuccessCase(String path, String[] params, String schemaLocation) {
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()
return EndpointTestCase.builder()
.setPath(path)
.setPath(path)
.setParams(Optional.of(params))
.setParams(Optional.of(params))
.setResponseContentType(ContentType.JSON)
.setResponseContentType(ContentType.JSON)
.setSchemaLocation(schemaLocation)
.setSchemaLocation(schemaLocation);
.build();
}
}
/**
/**
@@ -64,6 +76,23 @@ public class TestCaseHelper {
@@ -64,6 +76,23 @@ public class TestCaseHelper {
.build();
.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.
* 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
* Used to test a URL that doesn't exist. Status code 404 (Not Found) is
Loading