@Test(expected = DoesNotExistException.class) public void testExportDatasetDoesNotExist() throws DoesNotExistException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(404); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Does not exist!")); da.exportDataset("ds0", null); }
public void exportDataset(String id, String format) throws DoesNotExistException, AlreadyExistsException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + DatasetOptionListContainer.EXPORT).queryParam(DatasetOptionListContainer.FORMAT, format); Response response = target.request(MediaType.APPLICATION_JSON).post(null, Response.class); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("exportDataset(..) success!"); }
DatasetsAccessor { public void exportDataset(String id, String format) throws DoesNotExistException, AlreadyExistsException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + DatasetOptionListContainer.EXPORT).queryParam(DatasetOptionListContainer.FORMAT, format); Response response = target.request(MediaType.APPLICATION_JSON).post(null, Response.class); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("exportDataset(..) success!"); } }
DatasetsAccessor { public void exportDataset(String id, String format) throws DoesNotExistException, AlreadyExistsException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + DatasetOptionListContainer.EXPORT).queryParam(DatasetOptionListContainer.FORMAT, format); Response response = target.request(MediaType.APPLICATION_JSON).post(null, Response.class); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("exportDataset(..) success!"); } DatasetsAccessor(URL restUrl, String username, String password);   DatasetsAccessor(URL restUrl, String username, String password, Client client); }
DatasetsAccessor { public void exportDataset(String id, String format) throws DoesNotExistException, AlreadyExistsException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + DatasetOptionListContainer.EXPORT).queryParam(DatasetOptionListContainer.FORMAT, format); Response response = target.request(MediaType.APPLICATION_JSON).post(null, Response.class); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("exportDataset(..) success!"); } DatasetsAccessor(URL restUrl, String username, String password);   DatasetsAccessor(URL restUrl, String username, String password, Client client); DataSourceContainer getDataset(String datasetId); void deleteDataset(String datasetId); List<DataSourceContainer> getDatasetList(String providerId, int offset, int number); String createDatasetOai(String providerId, String id, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String oaiUrl, String oaiSet, String exportDir,
      RecordIdPolicy recordIdPolicy, Map<String, MetadataTransformation> metadataTransformations); String createDatasetFile(String providerId, String id, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy,
      FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy,
      CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory,
      String recordXPath, Map<String, MetadataTransformation> metadataTransformations); void updateDatasetOai(String id, String newId, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String oaiUrl, String oaiSet, String exportDir,
      RecordIdPolicy recordIdPolicy, Map<String, MetadataTransformation> metadataTransformations); void updateDatasetFile(String id, String newId, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy,
      FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy,
      CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory,
      String recordXPath, Map<String, MetadataTransformation> metadataTransformations); void copyDataset(String id, String newId); String getDatasetLastIngestionDate(String id); int getDatasetRecordCount(String id); void exportDataset(String id, String format); }
DatasetsAccessor { public void exportDataset(String id, String format) throws DoesNotExistException, AlreadyExistsException { WebTarget target = client.target(restUrl + "/" + DatasetOptionListContainer.DATASETS + "/" + id + "/" + DatasetOptionListContainer.EXPORT).queryParam(DatasetOptionListContainer.FORMAT, format); Response response = target.request(MediaType.APPLICATION_JSON).post(null, Response.class); switch (response.getStatus()) { case 404: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("exportDataset(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("exportDataset(..) success!"); } DatasetsAccessor(URL restUrl, String username, String password);   DatasetsAccessor(URL restUrl, String username, String password, Client client); DataSourceContainer getDataset(String datasetId); void deleteDataset(String datasetId); List<DataSourceContainer> getDatasetList(String providerId, int offset, int number); String createDatasetOai(String providerId, String id, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String oaiUrl, String oaiSet, String exportDir,
      RecordIdPolicy recordIdPolicy, Map<String, MetadataTransformation> metadataTransformations); String createDatasetFile(String providerId, String id, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy,
      FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy,
      CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory,
      String recordXPath, Map<String, MetadataTransformation> metadataTransformations); void updateDatasetOai(String id, String newId, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String oaiUrl, String oaiSet, String exportDir,
      RecordIdPolicy recordIdPolicy, Map<String, MetadataTransformation> metadataTransformations); void updateDatasetFile(String id, String newId, String name, String nameCode,
      boolean isSample, String schema, String description, String namespace, String metadataFormat,
      String marcFormat, String exportDir, RecordIdPolicy recordIdPolicy,
      FileExtractStrategy extractStrategy, FileRetrieveStrategy retrieveStrategy,
      CharacterEncoding characterEncoding, Iso2709Variant isoVariant, String sourceDirectory,
      String recordXPath, Map<String, MetadataTransformation> metadataTransformations); void copyDataset(String id, String newId); String getDatasetLastIngestionDate(String id); int getDatasetRecordCount(String id); void exportDataset(String id, String format);  }