use of org.pentaho.platform.plugin.services.importer.MetadataImportHandler in project data-access by pentaho.
the class DatasourceResourceIT method testMetadataImportExport.
@Test
public void testMetadataImportExport() throws PlatformInitializationException, IOException, PlatformImportException {
List<IMimeType> mimeTypeList = new ArrayList<IMimeType>();
mimeTypeList.add(new MimeType("Metadata", ".xmi"));
File metadata = new File("target/test-classes/dsw/testData/metadata.xmi");
RepositoryFile repoMetadataFile = new RepositoryFile.Builder(metadata.getName()).folder(false).hidden(false).build();
MetadataImportHandler metadataImportHandler = new MetadataImportHandler(mimeTypeList, (IPentahoMetadataDomainRepositoryImporter) PentahoSystem.get(IMetadataDomainRepository.class));
RepositoryFileImportBundle bundle1 = new RepositoryFileImportBundle.Builder().file(repoMetadataFile).charSet("UTF-8").input(new FileInputStream(metadata)).mime(".xmi").withParam("domain-id", "SalesData").build();
metadataImportHandler.importFile(bundle1);
final Response salesData = new DataSourceWizardResource().doGetDSWFilesAsDownload("SalesData");
Assert.assertEquals(salesData.getStatus(), Response.Status.OK.getStatusCode());
Assert.assertNotNull(salesData.getMetadata());
Assert.assertNotNull(salesData.getMetadata().getFirst("Content-Disposition"));
Assert.assertEquals(salesData.getMetadata().getFirst("Content-Disposition").getClass(), String.class);
Assert.assertTrue(((String) salesData.getMetadata().getFirst("Content-Disposition")).endsWith(".xmi\""));
}
Aggregations