@Test(expectedExceptions = ExportImportException.class) public void testCreatePartialExportError() throws Exception { when(restTemplate.postForObject(eq(PartialMdExport.URI), any(PartialMdExport.class), eq(PartialMdArtifact.class), eq(PROJECT_ID))) .thenThrow(new GoodDataRestException(400, "request", "Failed", "export", "error")); service.partialExport(project, new PartialMdExport(false, false, "uri123")); }
public FutureResult<PartialMdExportToken> partialExport(Project project, final PartialMdExport export) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(export, "export"); final PartialMdArtifact partialMdArtifact; try { partialMdArtifact = restTemplate.postForObject(PartialMdExport.URI, export, PartialMdArtifact.class, project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ExportImportException("Unable to export metadata from objects " + export.getUris() + ".", e); } return new PollResult<>(this, new AbstractPollHandler<TaskStatus, PartialMdExportToken>( notNullState(partialMdArtifact, "partial export response").getStatusUri(), TaskStatus.class, PartialMdExportToken.class) { @Override public void handlePollResult(TaskStatus pollResult) { if (!pollResult.isSuccess()) { throw new ExportImportException("Partial metadata export failed with errors: " + pollResult.getMessages()); } setResult(new PartialMdExportToken(partialMdArtifact.getToken(), export.isExportAttributeProperties())); } @Override public void handlePollException(GoodDataRestException e) { throw new ExportImportException("Unable to to export partial metadata.", e); } }); }
ExportImportService extends AbstractService { public FutureResult<PartialMdExportToken> partialExport(Project project, final PartialMdExport export) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(export, "export"); final PartialMdArtifact partialMdArtifact; try { partialMdArtifact = restTemplate.postForObject(PartialMdExport.URI, export, PartialMdArtifact.class, project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ExportImportException("Unable to export metadata from objects " + export.getUris() + ".", e); } return new PollResult<>(this, new AbstractPollHandler<TaskStatus, PartialMdExportToken>( notNullState(partialMdArtifact, "partial export response").getStatusUri(), TaskStatus.class, PartialMdExportToken.class) { @Override public void handlePollResult(TaskStatus pollResult) { if (!pollResult.isSuccess()) { throw new ExportImportException("Partial metadata export failed with errors: " + pollResult.getMessages()); } setResult(new PartialMdExportToken(partialMdArtifact.getToken(), export.isExportAttributeProperties())); } @Override public void handlePollException(GoodDataRestException e) { throw new ExportImportException("Unable to to export partial metadata.", e); } }); } }
ExportImportService extends AbstractService { public FutureResult<PartialMdExportToken> partialExport(Project project, final PartialMdExport export) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(export, "export"); final PartialMdArtifact partialMdArtifact; try { partialMdArtifact = restTemplate.postForObject(PartialMdExport.URI, export, PartialMdArtifact.class, project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ExportImportException("Unable to export metadata from objects " + export.getUris() + ".", e); } return new PollResult<>(this, new AbstractPollHandler<TaskStatus, PartialMdExportToken>( notNullState(partialMdArtifact, "partial export response").getStatusUri(), TaskStatus.class, PartialMdExportToken.class) { @Override public void handlePollResult(TaskStatus pollResult) { if (!pollResult.isSuccess()) { throw new ExportImportException("Partial metadata export failed with errors: " + pollResult.getMessages()); } setResult(new PartialMdExportToken(partialMdArtifact.getToken(), export.isExportAttributeProperties())); } @Override public void handlePollException(GoodDataRestException e) { throw new ExportImportException("Unable to to export partial metadata.", e); } }); } ExportImportService(final RestTemplate restTemplate, final GoodDataSettings settings); }
ExportImportService extends AbstractService { public FutureResult<PartialMdExportToken> partialExport(Project project, final PartialMdExport export) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(export, "export"); final PartialMdArtifact partialMdArtifact; try { partialMdArtifact = restTemplate.postForObject(PartialMdExport.URI, export, PartialMdArtifact.class, project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ExportImportException("Unable to export metadata from objects " + export.getUris() + ".", e); } return new PollResult<>(this, new AbstractPollHandler<TaskStatus, PartialMdExportToken>( notNullState(partialMdArtifact, "partial export response").getStatusUri(), TaskStatus.class, PartialMdExportToken.class) { @Override public void handlePollResult(TaskStatus pollResult) { if (!pollResult.isSuccess()) { throw new ExportImportException("Partial metadata export failed with errors: " + pollResult.getMessages()); } setResult(new PartialMdExportToken(partialMdArtifact.getToken(), export.isExportAttributeProperties())); } @Override public void handlePollException(GoodDataRestException e) { throw new ExportImportException("Unable to to export partial metadata.", e); } }); } ExportImportService(final RestTemplate restTemplate, final GoodDataSettings settings); FutureResult<PartialMdExportToken> partialExport(Project project, final PartialMdExport export); FutureResult<Void> partialImport(Project project, PartialMdExportToken mdExportToken); }
ExportImportService extends AbstractService { public FutureResult<PartialMdExportToken> partialExport(Project project, final PartialMdExport export) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(export, "export"); final PartialMdArtifact partialMdArtifact; try { partialMdArtifact = restTemplate.postForObject(PartialMdExport.URI, export, PartialMdArtifact.class, project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ExportImportException("Unable to export metadata from objects " + export.getUris() + ".", e); } return new PollResult<>(this, new AbstractPollHandler<TaskStatus, PartialMdExportToken>( notNullState(partialMdArtifact, "partial export response").getStatusUri(), TaskStatus.class, PartialMdExportToken.class) { @Override public void handlePollResult(TaskStatus pollResult) { if (!pollResult.isSuccess()) { throw new ExportImportException("Partial metadata export failed with errors: " + pollResult.getMessages()); } setResult(new PartialMdExportToken(partialMdArtifact.getToken(), export.isExportAttributeProperties())); } @Override public void handlePollException(GoodDataRestException e) { throw new ExportImportException("Unable to to export partial metadata.", e); } }); } ExportImportService(final RestTemplate restTemplate, final GoodDataSettings settings); FutureResult<PartialMdExportToken> partialExport(Project project, final PartialMdExport export); FutureResult<Void> partialImport(Project project, PartialMdExportToken mdExportToken);  }