use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class DefaultRepositoryVersioningManagerTest method setUp.
@Before
public void setUp() {
IPlatformMimeResolver platformMimeResolver = mock(IPlatformMimeResolver.class);
IMimeType mimeTypeMockFullTrue = mock(IMimeType.class);
IMimeType mimeTypeMockPartialTrue = mock(IMimeType.class);
IMimeType mimeTypeMockFalse = mock(IMimeType.class);
when(mimeTypeMockFullTrue.isVersionEnabled()).thenReturn(true);
when(mimeTypeMockFullTrue.isVersionCommentEnabled()).thenReturn(true);
when(mimeTypeMockPartialTrue.isVersionEnabled()).thenReturn(true);
when(mimeTypeMockPartialTrue.isVersionCommentEnabled()).thenReturn(false);
when(mimeTypeMockFalse.isVersionEnabled()).thenReturn(false);
when(mimeTypeMockFalse.isVersionCommentEnabled()).thenReturn(true);
when(platformMimeResolver.resolveMimeTypeForFileName(FULL_VERSIONING_PATH)).thenReturn(mimeTypeMockFullTrue);
when(platformMimeResolver.resolveMimeTypeForFileName(PART_VERSIONING_PATH)).thenReturn(mimeTypeMockPartialTrue);
when(platformMimeResolver.resolveMimeTypeForFileName(NO_VERSIONING_PATH)).thenReturn(mimeTypeMockFalse);
defaultRepositoryVersionManagerFullTrue.setMasterVersioning(true);
defaultRepositoryVersionManagerFullTrue.setMasterVersionComments(true);
defaultRepositoryVersionManagerFullTrue.setPlatformMimeResolver(platformMimeResolver);
defaultRepositoryVersionManagerPartialTrue.setMasterVersioning(true);
defaultRepositoryVersionManagerPartialTrue.setMasterVersionComments(false);
defaultRepositoryVersionManagerPartialTrue.setPlatformMimeResolver(platformMimeResolver);
defaultRepositoryVersionManagerFalse.setMasterVersioning(false);
defaultRepositoryVersionManagerFalse.setMasterVersionComments(true);
defaultRepositoryVersionManagerFalse.setPlatformMimeResolver(platformMimeResolver);
}
use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class PlatformImporterTest method testMatchingMimeAndHandler.
@Test
public void testMatchingMimeAndHandler() throws Exception {
List<IMimeType> mimeList = Collections.singletonList((IMimeType) new MimeType("text/xmi+xml", "xmi"));
IPlatformImportHandler mockImportHandler = mock(IPlatformImportHandler.class);
when(mockImportHandler.getMimeTypes()).thenReturn(mimeList);
List<IPlatformImportHandler> handlers = Collections.singletonList(mockImportHandler);
NameBaseMimeResolver nameResolver = new NameBaseMimeResolver();
PentahoSystem.registerObject(nameResolver);
// mock logger to prevent npe
IRepositoryImportLogger importLogger = new Log4JRepositoryImportLogger();
PentahoPlatformImporter importer = new PentahoPlatformImporter(handlers, new DefaultRepositoryContentConverterHandler(new HashMap<String, Converter>()));
importer.setRepositoryImportLogger(importLogger);
FileInputStream in = new FileInputStream(new File(TestResourceLocation.TEST_RESOURCES + "/ImportTest/steel-wheels.xmi"));
// With custom domain id
final IPlatformImportBundle bundle1 = (new RepositoryFileImportBundle.Builder().input(in).charSet("UTF-8").hidden(false).mime("text/xmi+xml").name("steel-wheels.xmi").comment("Test Metadata Import").withParam("domain-id", "parameterized-domain-id")).build();
importer.importFile(bundle1);
verify(mockImportHandler, times(1)).importFile(bundle1);
}
use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class RepositoryFileImportFileHandlerTest method setup.
private void setup(String mimeTypeName, String extension, String path, String fileName, boolean folder) {
List<String> extensions = Arrays.asList(extension);
IMimeType mimeType = new MimeType(mimeTypeName, extensions);
mimeType.setConverter(mock(Converter.class));
List<IMimeType> mimeTypeList = Arrays.asList(mimeType);
NameBaseMimeResolver mimeResolver = new NameBaseMimeResolver();
mimeResolver.addMimeType(mimeType);
SolutionFileImportHelper.testMimeResolver = mimeResolver;
userProvider = new UserProvider();
mockRepository = new MockUnifiedRepository(userProvider);
fileHandler = new RepositoryFileImportFileHandler(mimeTypeList);
fileHandler.setRepository(mockRepository);
fileHandler.setDefaultAclHandler(new DefaultAclHandler());
fileHandler.setKnownExtensions(Arrays.asList("prpt"));
IPlatformImporter mockPlatformImporter = mock(IPlatformImporter.class);
when(mockPlatformImporter.getRepositoryImportLogger()).thenReturn(new Log4JRepositoryImportLogger());
ImportSession.iPlatformImporter = mockPlatformImporter;
importSession = fileHandler.getImportSession();
importSession.initialize();
mockBundle = mock(RepositoryFileImportBundle.class);
when(mockBundle.getPath()).thenReturn(path);
when(mockBundle.getName()).thenReturn(fileName);
when(mockBundle.getMimeType()).thenReturn(mimeTypeName);
when(mockBundle.isFolder()).thenReturn(folder);
}
use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class LocaleImportHandlerTest method setUp.
@Before
public void setUp() throws Exception {
NameBaseMimeResolver nameResolver = new NameBaseMimeResolver();
PentahoSystem.registerObject(nameResolver);
IRepositoryContentConverterHandler converterHandler = new DefaultRepositoryContentConverterHandler(new HashMap<String, Converter>());
List<IMimeType> localeMimeList = new ArrayList<IMimeType>();
localeMimeList.add(new MimeType("text/locale", "locale"));
nameResolver.addMimeType(new MimeType("text/prptMimeType", "prpt"));
nameResolver.addMimeType(new MimeType("text/xactionMimeType", "xaction"));
MimeType mimeType = new MimeType("text/xml", "xml");
mimeType.setHidden(true);
nameResolver.addMimeType(mimeType);
mimeType = new MimeType("image/png", "png");
mimeType.setHidden(true);
nameResolver.addMimeType(mimeType);
List<String> allowedArtifacts = new ArrayList<String>();
allowedArtifacts.add("xaction");
allowedArtifacts.add("url");
LocaleImportHandler localeImportHandler = new LocaleImportHandler(localeMimeList, allowedArtifacts);
LocaleImportHandler spylocaleImportHandler = spy(localeImportHandler);
Log log = mock(Log.class);
doReturn(log).when(spylocaleImportHandler).getLogger();
List<IPlatformImportHandler> handlers = new ArrayList<IPlatformImportHandler>();
handlers.add(spylocaleImportHandler);
importer = new PentahoPlatformImporter(handlers, converterHandler);
importer.setRepositoryImportLogger(new Log4JRepositoryImportLogger());
localeFilesProcessor = new LocaleFilesProcessor();
}
use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class MetadataImportHandlerIT method setUp.
@Before
public void setUp() throws Exception {
// mock logger to prevent npe
importLogger = new Log4JRepositoryImportLogger();
context = new Mockery();
metadataImporter = context.mock(IPentahoMetadataDomainRepositoryImporter.class);
MicroPlatform microPlatform = new MicroPlatform();
NameBaseMimeResolver nameResolver = new NameBaseMimeResolver();
microPlatform.defineInstance(IPlatformMimeResolver.class, nameResolver);
List<IMimeType> mimeList = new ArrayList<IMimeType>();
mimeList.add(new MimeType("text/xmi+xml", "xmi"));
metadataHandler = new MetadataImportHandler(mimeList, metadataImporter);
handlers.add(metadataHandler);
importer = new PentahoPlatformImporter(handlers, new DefaultRepositoryContentConverterHandler(new HashMap<String, Converter>()));
importer.setRepositoryImportLogger(importLogger);
}
Aggregations