### Question:
RecordsAccessor { public String getRecord(String id) throws InvalidArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + RecordOptionListContainer.RECORDS).queryParam("recordId", id); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 400) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getRecord(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); } else if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getRecord(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } else if (response.getStatus() == 500) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getRecord(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("getRecord(..) success!"); Result result = response.readEntity(Result.class); return result.getResult(); } RecordsAccessor(URL restUrl, String username, String password);   RecordsAccessor(URL restUrl, String username, String password, Client client); String getRecord(String id); void removeRecord(String id, String type); void createRecord(String datasetId, String recordId, String record);  }### Answer:
@Test public void testGetRecord() throws DoesNotExistException, InternalServerErrorException, InvalidArgumentsException { Mockito.when(response.getStatus()).thenReturn(200); Mockito.when(response.readEntity(Result.class)).thenReturn( new Result("<root>xml record</root>")); String record = ra.getRecord("recordId"); Assert.assertNotNull(record); }
@Test(expected = DoesNotExistException.class) public void testGetRecordDoesNotExist() throws DoesNotExistException, InternalServerErrorException, InvalidArgumentsException { Mockito.when(response.getStatus()).thenReturn(404); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Does not exist!")); ra.getRecord("recordId"); }
@Test(expected = InternalServerErrorException.class) public void testGetRecordInternalServerError() throws DoesNotExistException, InternalServerErrorException, InvalidArgumentsException { Mockito.when(response.getStatus()).thenReturn(500); Mockito.when(response.readEntity(Result.class)) .thenReturn(new Result("Internal Server Error!")); ra.getRecord("recordId"); }