I have a karate get test that is failing with a 400, but if I copy everything to postman it works. Also if I change the get to a post in the code and test and add an empty request body in the test it works. What am I doing wrong?
Here's the code to endpoint to be tested:
@Log
@Named
@Profile
@RestController
@Singleton
@Path("/commercial/deposits/accounts")
@Api(value = "/commercial/deposits/accounts")
@Produces({"application/vnd.com.capitalone.api+v3+json", "application/vnd.com.capitalone.api+v3+xml",
"application/vnd.com.capitalone.api+v3+javascript", "application/javascript", MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML})
@Consumes({"application/vnd.com.capitalone.api+v3+json", "application/vnd.com.capitalone.api+v3+xml",
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class CommercialAccountsRSResource {
@Inject
private CommercialAccountsRSService commercialAccountsRSService;
/**
* Account Summary - retrieves current bank account balances for accounts specified
*
* @param entityRequest Standard {@link EntityRequest} fields
*
* @return A BankThing
*/
@GET
@JSONP(queryParam = JSONP.DEFAULT_QUERY)
@ApiOperation(value = "Get account balances for accountIds specified.", notes = "Get account balances for accountIds specified.", response = AccountSummaryResponse.class)
@ApiResponses({
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = ChassisHTTPStatusMessageConstants.SUCCESS_MESSAGE),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_AUTHORITATIVE, message = ChassisHTTPStatusMessageConstants.PARTIAL_SUCCESS_MESSAGE),
@ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = ChassisHTTPStatusMessageConstants.BAD_REQUEST_MESSAGE),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = ChassisHTTPStatusMessageConstants.UNAUTHORIZED_MESSAGE),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = ChassisHTTPStatusMessageConstants.FORBIDDEN_MESSAGE),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = ChassisHTTPStatusMessageConstants.NOT_FOUND_MESSAGE),
@ApiResponse(code = HttpURLConnection.HTTP_BAD_METHOD, message = ChassisHTTPStatusMessageConstants.METHOD_NOT_ALLOWED_MESSAGE),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = ChassisHTTPStatusMessageConstants.NOT_ACCEPTABLE_MESSAGE),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = ChassisHTTPStatusMessageConstants.INTERNAL_SERVER_ERROR_MESSAGE)})
public AccountSummaryResponse accountSummaryResponse(@BeanParam EntityRequest entityRequest,
@ApiParam(value = "Customer Account number", name = "accountReferenceId", required = true, allowMultiple = true) @QueryParam("accountReferenceId") String accountReferenceId,
@ApiParam(value = "Bank number", name = "bankNumber", required = true, allowMultiple = true) @QueryParam("bankNumber") String bankNumber)
{
CommercialAccountsRSResourceUtil.validateInput(accountReferenceId, bankNumber);
return commercialAccountsRSService.accountSummaryResponse(accountReferenceId, bankNumber);
}
Here is the karate scenario:
Feature: Test DDA Account Summary
Background:
* url baseURL
And headers { Api-Key: 'CMIX', Accept: 'application/json;v=3', Content-Type: 'application/json;v-3',Authorization: '#(bearerToken)' }
@local
Scenario: Get single account successfully
Given path '/dda-account-summary-web/commercial/deposits/accounts'
And param accountReferenceId = '0000030651'
And param bankNumber = '0030'
When method GET
Then status 200
And match response == read('AccountSummarySingleSuccess.json')
And this is the result:
08:36:16.316 [ForkJoinPool-1-worker-1] INFO com.intuit.karate - << lock released, cached callSingle: classpath:oAuthToken.feature
08:36:16.324 [ForkJoinPool-1-worker-1] INFO com.intuit.karate - baseURL: http://localhost:11400
08:36:16.338 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - request:
1 > GET http://localhost:11400/dda-account-summary-web/commercial/deposits/accounts?accountReferenceId=0000030651&bankNumber=0030
1 > Accept: application/json;v=3
1 > Accept-Encoding: gzip,deflate
1 > Api-Key: CMIX
1 > Authorization: Bearer xxx
1 > Connection: Keep-Alive
1 > Content-Type: application/json;v-3
1 > Host: localhost:11400
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_271)
08:36:16.390 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - response time in milliseconds: 50.62
1 < 400
1 < Cache-Control: no-cache, no-store, max-age=0, must-revalidate
1 < Connection: close
1 < Content-Type: application/json; v=3
1 < Date: Thu, 04 Feb 2021 13:36:16 GMT
1 < Expires: 0
1 < Pragma: no-cache
1 < Set-Cookie: JSESSIONID=09DC5825407678630098BCD5087425DA; Path=/dda-account-summary-web; HttpOnly
1 < Transfer-Encoding: chunked
1 < X-Content-Type-Options: nosniff
1 < X-Frame-Options: DENY
1 < X-XSS-Protection: 1; mode=block
{
"timestamp": "2021-02-04T13:36:16.385+00:00",
"status": 400,
"error": "Bad Request",
"message": "",
"path": "/dda-account-summary-web/commercial/deposits/accounts"
}