@Test(expected = DoesNotExistException.class) public void testRemoveRecordDoesNotExist() throws InternalServerErrorException, InvalidArgumentsException, DoesNotExistException, MissingArgumentsException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(404); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Does not exist!")); ra.removeRecord("recordId", RecordOptionListContainer.DELETE); }
public void removeRecord(String id, String type) throws MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + RecordOptionListContainer.RECORDS).queryParam("recordId", id).queryParam("type", type); Response response = target.request(MediaType.APPLICATION_JSON).delete(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } Result result = response.readEntity(Result.class); LOGGER.info("removeRecord(..) success! : " + result.getResult()); }
RecordsAccessor { public void removeRecord(String id, String type) throws MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + RecordOptionListContainer.RECORDS).queryParam("recordId", id).queryParam("type", type); Response response = target.request(MediaType.APPLICATION_JSON).delete(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } Result result = response.readEntity(Result.class); LOGGER.info("removeRecord(..) success! : " + result.getResult()); } }
RecordsAccessor { public void removeRecord(String id, String type) throws MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + RecordOptionListContainer.RECORDS).queryParam("recordId", id).queryParam("type", type); Response response = target.request(MediaType.APPLICATION_JSON).delete(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } Result result = response.readEntity(Result.class); LOGGER.info("removeRecord(..) success! : " + result.getResult()); } RecordsAccessor(URL restUrl, String username, String password);   RecordsAccessor(URL restUrl, String username, String password, Client client); }
RecordsAccessor { public void removeRecord(String id, String type) throws MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + RecordOptionListContainer.RECORDS).queryParam("recordId", id).queryParam("type", type); Response response = target.request(MediaType.APPLICATION_JSON).delete(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } Result result = response.readEntity(Result.class); LOGGER.info("removeRecord(..) 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); }
RecordsAccessor { public void removeRecord(String id, String type) throws MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + RecordOptionListContainer.RECORDS).queryParam("recordId", id).queryParam("type", type); Response response = target.request(MediaType.APPLICATION_JSON).delete(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("removeRecord(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } Result result = response.readEntity(Result.class); LOGGER.info("removeRecord(..) 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);  }