Skip to content
Snippets Groups Projects

feat: Add schema location support for error test cases

1 file
+ 21
18
Compare changes
  • Side-by-side
  • Inline
@@ -57,22 +57,19 @@ public class TestCaseHelper {
@@ -57,22 +57,19 @@ public class TestCaseHelper {
}
}
/**
/**
* Creates a EndpointTestCase object with the desired path, params, and request
* Creates a EndpointTestCase object with the desired path and params.
* format.
* Used to test a bad request. Status code 400 (Bad Request) is assumed.
* Used to test an invalid request body format. Status code
* 500 (Internal Error) is assumed.
*
*
* @param path the endpoint URL
* @param path the endpoint URL
* @param params the request path/query parameters
* @param params the request path/query parameters
* @param invalidFormat the invalid request format
* @return the desired endpoint test case
* @return the desired endpoint test case
*/
*/
public static EndpointTestCase buildInvalidFormatCase(String path, String[] params, ContentType invalidFormat) {
public static EndpointTestCase buildBadRequestCase(String path, String[] params, String schemaLocation) {
return EndpointTestCase.builder()
return EndpointTestCase.builder()
.setPath(path)
.setPath(path)
.setParams(Optional.of(params))
.setParams(Optional.of(params))
.setRequestContentType(invalidFormat)
.setSchemaLocation(schemaLocation)
.setStatusCode(500)
.setStatusCode(400)
.build();
.build();
}
}
@@ -85,10 +82,11 @@ public class TestCaseHelper {
@@ -85,10 +82,11 @@ public class TestCaseHelper {
* @param params the request path/query parameters
* @param params the request path/query parameters
* @return the desired endpoint test case
* @return the desired endpoint test case
*/
*/
public static EndpointTestCase buildForbiddenCase(String path, String[] params) {
public static EndpointTestCase buildForbiddenCase(String path, String[] params, String schemaLocation) {
return EndpointTestCase.builder()
return EndpointTestCase.builder()
.setPath(path)
.setPath(path)
.setParams(Optional.of(params))
.setParams(Optional.of(params))
 
.setSchemaLocation(schemaLocation)
.setStatusCode(403)
.setStatusCode(403)
.build();
.build();
}
}
@@ -102,27 +100,32 @@ public class TestCaseHelper {
@@ -102,27 +100,32 @@ public class TestCaseHelper {
* @param params the request path/query parameters
* @param params the request path/query parameters
* @return the desired endpoint test case
* @return the desired endpoint test case
*/
*/
public static EndpointTestCase buildNotFoundCase(String path, String[] params) {
public static EndpointTestCase buildNotFoundCase(String path, String[] params, String schemaLocation) {
return EndpointTestCase.builder()
return EndpointTestCase.builder()
.setPath(path)
.setPath(path)
.setParams(Optional.of(params))
.setParams(Optional.of(params))
 
.setSchemaLocation(schemaLocation)
.setStatusCode(404)
.setStatusCode(404)
.build();
.build();
}
}
/**
/**
* Creates a EndpointTestCase object with the desired path and params.
* Creates a EndpointTestCase object with the desired path, params, and request
* Used to test a bad request. Status code 400 (Bad Request) is assumed.
* format.
 
* Used to test an invalid request body format. Status code
 
* 500 (Internal Error) is assumed.
*
*
* @param path the endpoint URL
* @param path the endpoint URL
* @param params the request path/query parameters
* @param params the request path/query parameters
 
* @param invalidFormat the invalid request format
* @return the desired endpoint test case
* @return the desired endpoint test case
*/
*/
public static EndpointTestCase buildBadRequestCase(String path, String[] params) {
public static EndpointTestCase buildInvalidFormatCase(String path, String[] params, ContentType invalidFormat) {
return EndpointTestCase.builder()
return EndpointTestCase.builder()
.setPath(path)
.setPath(path)
.setParams(Optional.of(params))
.setParams(Optional.of(params))
.setStatusCode(400)
.setRequestContentType(invalidFormat)
 
.setStatusCode(500)
.build();
.build();
}
}
Loading