use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class SolutionFileImportHelper method isInHiddenList.
public boolean isInHiddenList(String fileName) {
boolean isInTheHiddenList = false;
IMimeType mimeType = getMimeType(fileName);
if (mimeType != null) {
isInTheHiddenList = mimeType.isHidden();
}
return isInTheHiddenList;
}
use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class LocaleFilesProcessorTest method testProcessLocaleFilesTwoLocaleFiles.
@Test
public void testProcessLocaleFilesTwoLocaleFiles() throws Exception {
IRepositoryContentConverterHandler converterHandler = new DefaultRepositoryContentConverterHandler(new HashMap<String, Converter>());
List<IMimeType> localeMimeList = new ArrayList<IMimeType>();
localeMimeList.add(new MimeType("text/locale", "locale"));
LocaleImportHandler localeImportHandler = new LocaleImportHandler(localeMimeList, null);
LocaleImportHandler localeImportHandlerSpy = spy(localeImportHandler);
Log log = mock(Log.class);
doReturn(log).when(localeImportHandlerSpy).getLogger();
String localeFileName = "SampleTransformationWithParameters";
List<IPlatformImportHandler> handlers = new ArrayList<IPlatformImportHandler>();
handlers.add(localeImportHandlerSpy);
importer = new PentahoPlatformImporter(handlers, converterHandler);
importer.setRepositoryImportLogger(new Log4JRepositoryImportLogger());
localeFilesProcessor = new LocaleFilesProcessor();
StringBuffer localePropertiesContent = new StringBuffer();
localePropertiesContent.append("description=This runs a simple Kettle transformation filtering records from the Quandrant_Actuals sample data " + "table, and sending a Hello message to each position.\n");
localePropertiesContent.append("name=1. Hello ETL");
assertTrue(processIsLocalFile("SampleTransformation.properties", localePropertiesContent));
StringBuffer localeContent = new StringBuffer();
localeContent.append("file.title=" + localeFileName + "\n");
localeContent.append("title=SampleTransformation\n");
localeContent.append("file.description=");
assertTrue(processIsLocalFile("SampleTransformation.xaction.locale", localeContent));
localeFilesProcessor.processLocaleFiles(importer);
// verify that in case of both .properties and .locale files are at input the only one proceeded is .locale
Mockito.verify(localeImportHandlerSpy, times(1)).importFile(any(IPlatformImportBundle.class));
ArgumentCaptor<IPlatformImportBundle> argument = ArgumentCaptor.forClass(IPlatformImportBundle.class);
Mockito.verify(localeImportHandlerSpy).importFile(argument.capture());
assertEquals(localeFileName, argument.getValue().getName());
}
use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class MetadataImportHandlerTest method setUp.
@Before
public void setUp() throws Exception {
context = new Mockery();
metadataImporter = context.mock(IPentahoMetadataDomainRepositoryImporter.class);
List<IMimeType> mimeList = new ArrayList<IMimeType>();
mimeList.add(new MimeType("text/xmi+xml", "xmi"));
metadataHandler = new MetadataImportHandler(mimeList, metadataImporter);
}
use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class NameBaseMimeResolverTest method testResolveMimeTypeForFileName.
@Test
public void testResolveMimeTypeForFileName() {
MimeType expectedMimeType = new MimeType("othertest/other-test-mime", "smt");
IMimeType actualMimeType = resolver.resolveMimeTypeForFileName("test.smt");
assertEquals(actualMimeType, expectedMimeType);
}
use of org.pentaho.platform.api.mimetype.IMimeType in project pentaho-platform by pentaho.
the class PRPTImportHandlerTest method setUp.
@Before
public void setUp() throws ObjectFactoryException, IOException {
final IPlatformMimeResolver resolver = mock(IPlatformMimeResolver.class);
pentahoObjectFactory = mock(IPentahoObjectFactory.class);
when(pentahoObjectFactory.objectDefined(anyString())).thenReturn(true);
when(pentahoObjectFactory.get(eq(IPlatformMimeResolver.class), anyString(), any(IPentahoSession.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return resolver;
}
});
when(pentahoObjectFactory.get(eq(IPlatformImporter.class), anyString(), any(IPentahoSession.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return importer;
}
});
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
InputStream stream = new ByteArrayInputStream(SAMPLE_STREAM.getBytes());
bundle = mock(RepositoryFileImportBundle.class);
when(bundle.getName()).thenReturn(SAMPLE_NAME);
when(bundle.getInputStream()).thenReturn(stream);
Log logger = mock(Log.class);
ImportSession session = mock(ImportSession.class);
doReturn(logger).when(session).getLogger();
IUnifiedRepository repository = mock(IUnifiedRepository.class);
List<IMimeType> mimeTypes = Arrays.asList(mock(IMimeType.class));
handler = spy(new PRPTImportHandler(mimeTypes));
doReturn(session).when(handler).getImportSession();
handler.setRepository(repository);
}
Aggregations