@Test public void testGetDatasetScheduledTasks() throws DoesNotExistException { Mockito.when(response.getStatus()).thenReturn(200); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Success!")); ha.getDatasetScheduledTasks("ds0"); }
public List<ScheduledTask> getDatasetScheduledTasks(String id) throws DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + HarvestOptionListContainer.HARVEST + "/" + HarvestOptionListContainer.SCHEDULES); Response response = target.request(MediaType.APPLICATION_JSON).get(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } List<ScheduledTask> scheduleTasksList = response.readEntity(new GenericType<List<ScheduledTask>>() {}); LOGGER.info("getDatasetScheduledTasks(..) success!"); return scheduleTasksList; }
HarvestAccessor { public List<ScheduledTask> getDatasetScheduledTasks(String id) throws DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + HarvestOptionListContainer.HARVEST + "/" + HarvestOptionListContainer.SCHEDULES); Response response = target.request(MediaType.APPLICATION_JSON).get(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } List<ScheduledTask> scheduleTasksList = response.readEntity(new GenericType<List<ScheduledTask>>() {}); LOGGER.info("getDatasetScheduledTasks(..) success!"); return scheduleTasksList; } }
HarvestAccessor { public List<ScheduledTask> getDatasetScheduledTasks(String id) throws DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + HarvestOptionListContainer.HARVEST + "/" + HarvestOptionListContainer.SCHEDULES); Response response = target.request(MediaType.APPLICATION_JSON).get(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } List<ScheduledTask> scheduleTasksList = response.readEntity(new GenericType<List<ScheduledTask>>() {}); LOGGER.info("getDatasetScheduledTasks(..) success!"); return scheduleTasksList; } HarvestAccessor(URL restUrl, String username, String password);   HarvestAccessor(URL restUrl, String username, String password, Client client); }
HarvestAccessor { public List<ScheduledTask> getDatasetScheduledTasks(String id) throws DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + HarvestOptionListContainer.HARVEST + "/" + HarvestOptionListContainer.SCHEDULES); Response response = target.request(MediaType.APPLICATION_JSON).get(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } List<ScheduledTask> scheduleTasksList = response.readEntity(new GenericType<List<ScheduledTask>>() {}); LOGGER.info("getDatasetScheduledTasks(..) success!"); return scheduleTasksList; } HarvestAccessor(URL restUrl, String username, String password);   HarvestAccessor(URL restUrl, String username, String password, Client client); void startHarvest(String id, String type); void cancelHarvest(String id); void scheduleHarvest(String id, Calendar firstDateTime, Frequency frequency, int xmonths,
      boolean incremental); void deleteScheduledTask(String id, String taskId); List<ScheduledTask> getDatasetScheduledTasks(String id); String getDatasetHarvestingStatus(String id); String getDatasetLastIngestLog(String id); List<Task> getCurrentHarvestsList(); }
HarvestAccessor { public List<ScheduledTask> getDatasetScheduledTasks(String id) throws DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + HarvestOptionListContainer.HARVEST + "/" + HarvestOptionListContainer.SCHEDULES); Response response = target.request(MediaType.APPLICATION_JSON).get(); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("getDatasetScheduledTasks(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } List<ScheduledTask> scheduleTasksList = response.readEntity(new GenericType<List<ScheduledTask>>() {}); LOGGER.info("getDatasetScheduledTasks(..) success!"); return scheduleTasksList; } HarvestAccessor(URL restUrl, String username, String password);   HarvestAccessor(URL restUrl, String username, String password, Client client); void startHarvest(String id, String type); void cancelHarvest(String id); void scheduleHarvest(String id, Calendar firstDateTime, Frequency frequency, int xmonths,
      boolean incremental); void deleteScheduledTask(String id, String taskId); List<ScheduledTask> getDatasetScheduledTasks(String id); String getDatasetHarvestingStatus(String id); String getDatasetLastIngestLog(String id); List<Task> getCurrentHarvestsList();  }