### Question:
HarvestAccessor { public void startHarvest(String id, String type) throws AlreadyExistsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target( restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + HarvestOptionListContainer.HARVEST + "/" + HarvestOptionListContainer.START) .queryParam(HarvestOptionListContainer.TYPE, type); Response response = target.request(MediaType.APPLICATION_JSON).post( Entity.entity(null, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("startHarvest(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("startHarvest(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("startHarvest(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } Result errorMessage = response.readEntity(Result.class); LOGGER.info("startHarvest(..) success! : " + errorMessage.getResult()); } 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();  }### Answer:
@Test public void testStartHarvest() throws AlreadyExistsException, DoesNotExistException { Mockito.when(response.getStatus()).thenReturn(200); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Success!")); ha.startHarvest("ds0", HarvestOptionListContainer.SAMPLE); }
@Test(expected = DoesNotExistException.class) public void testStartHarvestDoesNotExist() throws DoesNotExistException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(404); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Does not exist!")); ha.startHarvest("ds0", HarvestOptionListContainer.SAMPLE); }
@Test(expected = AlreadyExistsException.class) public void testStartHarvestAlreadyExists() throws AlreadyExistsException, DoesNotExistException { Mockito.when(response.getStatus()).thenReturn(409); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Already exist!")); ha.startHarvest("ds0", HarvestOptionListContainer.SAMPLE); }
@Test(expected = InternalServerErrorException.class) public void testStartHarvestInternalServerError() throws AlreadyExistsException, DoesNotExistException { Mockito.when(response.getStatus()).thenReturn(500); Mockito.when(response.readEntity(Result.class)) .thenReturn(new Result("Internal Server Error!")); ha.startHarvest("ds0", HarvestOptionListContainer.SAMPLE); }