use of org.pentaho.metaverse.api.IDocument in project pentaho-metaverse by pentaho.
the class JobRuntimeExtensionPointTest method testJobMetaVariablesAreCombinedWithExistingJobVariables.
@Test
public void testJobMetaVariablesAreCombinedWithExistingJobVariables() throws Exception {
JobLineageHolderMap originalHolderMap = mockBuilder();
JobRuntimeExtensionPoint extensionPoint = new JobRuntimeExtensionPoint();
IDocumentAnalyzer documentAnalyzer = Mockito.mock(IDocumentAnalyzer.class);
extensionPoint.setDocumentAnalyzer(documentAnalyzer);
final IMetaverseObjectFactory objectFactory = mock(IMetaverseObjectFactory.class);
when(mockBuilder.getMetaverseObjectFactory()).thenReturn(objectFactory);
final IDocument document = mock(IDocument.class);
when(objectFactory.createDocumentObject()).thenReturn(document);
job.setVariable("dontloseme", "okipromise");
extensionPoint.callExtensionPoint(null, job);
assertEquals("okipromise", job.getVariable("dontloseme"));
// Restore original JobLineageHolderMap for use by others
JobLineageHolderMap.setInstance(originalHolderMap);
}
use of org.pentaho.metaverse.api.IDocument in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testCreateMetaverseDocument.
@Test
public void testCreateMetaverseDocument() {
IDocument doc = builder.createDocumentObject();
assertNotNull(doc);
}
use of org.pentaho.metaverse.api.IDocument in project pentaho-metaverse by pentaho.
the class LocatorRunnerTest method testProcessFileTransformationExtension.
@Test
public void testProcessFileTransformationExtension() throws Exception {
doAnswer(new Answer() {
/**
* @param invocation the invocation on the mock.
* @return the value to be returned
* @throws Throwable the throwable to be thrown
*/
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
IDocumentEvent event = (IDocumentEvent) invocation.getArguments()[0];
IDocument doc = event.getDocument();
assertNotNull(doc);
assertNull(doc.getMimeType());
assertEquals(doc.getName(), "test.ktr");
assertEquals(doc.getStringID(), "myKTR");
return null;
}
}).when(baseLocator).notifyListeners(any(IDocumentEvent.class));
stringLocatorRunner.setLocator(baseLocator);
File file = new File("test.ktr");
File spyFile = spy(file);
stringLocatorRunner.processFile(namespace, "test.ktr", "myKTR", spyFile);
when(baseLocator.getContents(any(Object.class))).thenThrow(MetaverseException.class);
stringLocatorRunner.processFile(namespace, "test.ktr", "myKTR", spyFile);
}
use of org.pentaho.metaverse.api.IDocument in project pentaho-metaverse by pentaho.
the class MetaverseUtilTest method testCreateDocument.
@Test
public void testCreateDocument() throws Exception {
Object content = new Object();
INamespace namespace = mock(INamespace.class);
IDocument document = MetaverseUtil.createDocument(namespace, content, "myID", "myName", "myExtension", "application/text");
assertEquals(document.getNamespace(), namespace);
assertEquals(document.getContent(), content);
assertEquals(document.getStringID(), "myID");
assertEquals(document.getName(), "myName");
assertEquals(document.getMimeType(), "application/text");
}
Aggregations