@Test(expected = ClientErrorException.class) public void testDeleteReturns404() throws Exception { // Arrange Mockito.when(response.getStatus()).thenReturn(400); Mockito.when(response.getStatusInfo().getFamily()) .thenReturn(Response.Status.Family.CLIENT_ERROR); Mockito.when(builder.delete(Response.class)).thenReturn(response); // Act classUnderTest.deleteOne(builder); // Assert fail("Should have thrown an Exception"); }
@Test @SuppressWarnings("unchecked") public void testDeleteReturns200() throws Exception { // Arrange Mockito.when(response.getStatus()).thenReturn(200); Mockito.when(response.readEntity(Mockito.any(Class.class))).thenReturn(null); Mockito.when(response.getStatusInfo().getFamily()) .thenReturn(Response.Status.Family.SUCCESSFUL); Mockito.when(builder.delete(Response.class)).thenReturn(response); // Act Issue deleteOne = classUnderTest.deleteOne(builder); // Assert assertEquals(null, deleteOne); }