@Test(expected = ClientErrorException.class) public void testPutReturns412() throws Exception { // Arrange Mockito.when(response.getStatus()).thenReturn(412); Mockito.when(response.getStatusInfo().getFamily()) .thenReturn(Response.Status.Family.CLIENT_ERROR); Mockito.when(builder.put(entity, Response.class)).thenReturn(response); // Act classUnderTest.putOne(builder, entity); // Assert fail("Should have thrown an Exception"); }
@Test @SuppressWarnings("unchecked") public void testPutReturns204() throws Exception { // Arrange Mockito.when(response.getStatus()).thenReturn(204); Mockito.when(response.readEntity(Mockito.any(Class.class))).thenReturn(entity); Mockito.when(response.getStatusInfo().getFamily()) .thenReturn(Response.Status.Family.SUCCESSFUL); Mockito.when(builder.put(entity, Response.class)).thenReturn(response); // Act Issue putOne = classUnderTest.putOne(builder, entity); // Assert assertEquals(null, putOne); }