use of org.pentaho.platform.plugin.services.importexport.Exporter in project pentaho-platform by pentaho.
the class ExporterTest method setUp.
public void setUp() throws Exception {
super.setUp();
// set up mock repository
unifiedRepository = mock(IUnifiedRepository.class);
repositoryFile = mock(RepositoryFile.class);
// handle method calls
when(unifiedRepository.getFile(REPO_PATH)).thenReturn(repositoryFile);
// instantiate exporter here to reuse for each test
exporter = new Exporter(unifiedRepository);
exporter.setRepoPath(REPO_PATH);
exporter.setFilePath(FILE_PATH);
}
use of org.pentaho.platform.plugin.services.importexport.Exporter in project pentaho-platform by pentaho.
the class ExporterTest method setUp.
public void setUp() throws Exception {
super.setUp();
// set up mock repository
unifiedRepository = mock(IUnifiedRepository.class);
repositoryFile = mock(RepositoryFile.class);
// handle method calls
when(unifiedRepository.getFile(REPO_PATH)).thenReturn(repositoryFile);
// instantiate exporter here to reuse for each test
exporter = new Exporter(unifiedRepository);
exporter.setRepoPath(REPO_PATH);
exporter.setFilePath(FILE_PATH);
}
use of org.pentaho.platform.plugin.services.importexport.Exporter in project pentaho-platform by pentaho.
the class FileResource method doGetDirAsZip.
/**
* @param repositoryFile
* @return
*/
public Response doGetDirAsZip(RepositoryFile repositoryFile) {
String path = repositoryFile.getPath();
final InputStream is;
try {
Exporter exporter = getExporter();
exporter.setRepoPath(path);
exporter.setRepoWs(repoWs);
File zipFile = exporter.doExportAsZip(repositoryFile);
is = getFileInputStream(zipFile);
} catch (Exception e) {
return buildServerErrorResponse(e.toString());
}
StreamingOutput streamingOutput = getStreamingOutput(is);
return buildOkResponse(streamingOutput, APPLICATION_ZIP);
}
use of org.pentaho.platform.plugin.services.importexport.Exporter in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetDirAsZipWithFile.
@Test
public void testDoGetDirAsZipWithFile() throws Exception {
RepositoryFile mockRepositoryFile = mock(RepositoryFile.class);
String path = "path";
doReturn(path).when(mockRepositoryFile).getPath();
Exporter mockExporter = mock(Exporter.class);
doReturn(mockExporter).when(fileResource).getExporter();
File mockFile = mock(File.class);
doReturn(mockFile).when(mockExporter).doExportAsZip(mockRepositoryFile);
InputStream mockInputStream = mock(FileInputStream.class);
doReturn(mockInputStream).when(fileResource).getFileInputStream(mockFile);
StreamingOutput mockOutput = mock(StreamingOutput.class);
doReturn(mockOutput).when(fileResource).getStreamingOutput(mockInputStream);
Response mockResponse = mock(Response.class);
doReturn(mockResponse).when(fileResource).buildOkResponse(mockOutput, FileResource.APPLICATION_ZIP);
Response testResponse = fileResource.doGetDirAsZip(mockRepositoryFile);
assertEquals(mockResponse, testResponse);
verify(mockRepositoryFile, times(1)).getPath();
verify(fileResource, times(1)).getExporter();
verify(mockExporter, times(1)).setRepoPath(path);
verify(mockExporter, times(1)).setRepoWs(fileResource.repoWs);
verify(mockExporter, times(1)).doExportAsZip(mockRepositoryFile);
verify(fileResource, times(1)).getFileInputStream(mockFile);
verify(fileResource, times(1)).getStreamingOutput(mockInputStream);
verify(fileResource, times(1)).buildOkResponse(mockOutput, FileResource.APPLICATION_ZIP);
}
Aggregations