Search in sources :

Example 11 with IDocument

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);
}
Also used : IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) IDocumentAnalyzer(org.pentaho.metaverse.api.IDocumentAnalyzer) IDocument(org.pentaho.metaverse.api.IDocument) Test(org.junit.Test)

Example 12 with IDocument

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);
}
Also used : IDocument(org.pentaho.metaverse.api.IDocument) Test(org.junit.Test)

Example 13 with IDocument

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);
}
Also used : Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) IDocumentEvent(org.pentaho.metaverse.api.IDocumentEvent) File(java.io.File) IDocument(org.pentaho.metaverse.api.IDocument) Test(org.junit.Test)

Example 14 with IDocument

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");
}
Also used : INamespace(org.pentaho.metaverse.api.INamespace) IDocument(org.pentaho.metaverse.api.IDocument) Test(org.junit.Test)

Aggregations

IDocument (org.pentaho.metaverse.api.IDocument)14 Test (org.junit.Test)8 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)4 INamespace (org.pentaho.metaverse.api.INamespace)4 Namespace (org.pentaho.metaverse.api.Namespace)4 Graph (com.tinkerpop.blueprints.Graph)3 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)3 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)3 MetaverseException (org.pentaho.metaverse.api.MetaverseException)3 TransMeta (org.pentaho.di.trans.TransMeta)2 AnalysisContext (org.pentaho.metaverse.api.AnalysisContext)2 IDocumentAnalyzer (org.pentaho.metaverse.api.IDocumentAnalyzer)2 IMetaverseObjectFactory (org.pentaho.metaverse.api.IMetaverseObjectFactory)2 IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)2 LineageHolder (org.pentaho.metaverse.api.model.LineageHolder)2 ExecutionProfile (org.pentaho.metaverse.impl.model.ExecutionProfile)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1