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 bafe122
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import java.util.Optional;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
Expand Down Expand Up @@ -92,7 +93,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 bafe122

Please sign in to comment.