@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"); }
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 { 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 { 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); }
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); }
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);  }