### Question:
RecordsAccessor { public void createRecord(String datasetId, String recordId, String record) throws DoesNotExistException, MissingArgumentsException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + RecordOptionListContainer.RECORDS).queryParam("datasetId", datasetId).queryParam("recordId", recordId); Response response = target.request(MediaType.APPLICATION_JSON).post(Entity.entity(record, MediaType.APPLICATION_XML), Response.class); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("createRecord(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("createRecord(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("createRecord(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } Result result = response.readEntity(Result.class); LOGGER.info("createRecord(..) success! : " + 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 testCreateRecord() throws InternalServerErrorException, DoesNotExistException, MissingArgumentsException { Mockito.when(response.getStatus()).thenReturn(201); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Success!")); ra.createRecord("ds0", "rd0", "<root>example</root>"); }
@Test(expected = DoesNotExistException.class) public void testCreateRecordDoesNotExist() throws InternalServerErrorException, DoesNotExistException, MissingArgumentsException { Mockito.when(response.getStatus()).thenReturn(404); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Does not exist!")); ra.createRecord("ds0", "rd0", "<root>example</root>"); }
@Test(expected = MissingArgumentsException.class) public void testCreateRecordMissingArguments() throws InternalServerErrorException, DoesNotExistException, MissingArgumentsException { Mockito.when(response.getStatus()).thenReturn(406); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Missing argument!")); ra.createRecord("ds0", "rd0", "<root>example</root>"); }
@Test(expected = InternalServerErrorException.class) public void testCreateRecordInternalServerError() throws InternalServerErrorException, DoesNotExistException, MissingArgumentsException { Mockito.when(response.getStatus()).thenReturn(500); Mockito.when(response.readEntity(Result.class)) .thenReturn(new Result("Internal Server Error!")); ra.createRecord("ds0", "rd0", "<root>example</root>"); }