Skip to content

Instantly share code, notes, and snippets.

@hakansander
Created April 24, 2020 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakansander/6bb2bac220a7291ffcbc839ab9ae3466 to your computer and use it in GitHub Desktop.
Save hakansander/6bb2bac220a7291ffcbc839ab9ae3466 to your computer and use it in GitHub Desktop.
@Test
public void testWhenInternalServerError_thenReturnHttp500() throws Exception {
String mockPhoneNum = "542*******";
this.mockServer.expect(ExpectedCount.once(), requestTo(invoiceUrl
+ mockPhoneNum))
.andExpect(MockRestRequestMatchers.method(HttpMethod.GET))
.andRespond((response) -> { throw new RuntimeException(); });
responseInvoiceResponseEntity = mockService.getInvoiceInfo(mockPhoneNum);
mockServer.verify();
Assert.assertEquals("500", responseInvoiceResponseEntity.
getStatusCode());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment