Skip to content

Commit

Permalink
PP-6085 Add accept header to test
Browse files Browse the repository at this point in the history
There are two methods within `TransactionResource` named `search` and
`streamCsv`. Both use the path `/` and http method `GET` but provide
either "application/json" or "text/csv" respectively.

According to the jax-rs specification when the client does not specify
the "accept" header then it is not garanteed as to which method will be
invoked, since both methods have the same level of specificity in what
they provide.

When
`shouldReturn400IfTransactionGatewayAccountIdIsNotProvidedForSearch`
runs locally and on Jenkins the `search` method is invoked as expected,
however on Travis `streamCsv` is called and an NPE is thrown as the test
provides a mock config with null parameters.

This shouldn't be a concern in production since the client of this
service is publicApi which provides an accept header. Therefore we feel it is
exceptable to add the header to the test and not disambiguate the
two methods any further.
  • Loading branch information
danworth committed Feb 7, 2020
1 parent 2aedc19 commit b5f39f5
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ public void shouldReturn404IfTransactionDoesNotExistWhenGettingEvents() {

@Test
public void shouldReturn400IfTransactionGatewayAccountIdIsNotProvidedForSearch() {
Response response = resources.target("/v1/transaction/").request().get();
Response response = resources.target("/v1/transaction/")
.request()
.header("Accept", "application/json")
.get();

assertThat(response.getStatus(), is(400));
}

Expand Down

0 comments on commit b5f39f5

Please sign in to comment.