Search in sources :

Example 11 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory in project pentaho-metaverse by pentaho.

the class TransformationAnalyzerTest method setUp.

/**
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    IMetaverseObjectFactory factory = MetaverseTestUtils.getMetaverseObjectFactory();
    when(mockBuilder.getMetaverseObjectFactory()).thenReturn(factory);
    analyzer = new TransformationAnalyzer();
    analyzer.setMetaverseBuilder(mockBuilder);
    when(namespace.getParentNamespace()).thenReturn(namespace);
    when(mockTransDoc.getType()).thenReturn(DictionaryConst.NODE_TYPE_TRANS);
    when(mockTransDoc.getContent()).thenReturn(mockContent);
    when(mockTransDoc.getNamespace()).thenReturn(namespace);
    when(mockGenRowsStepMeta.getParentStepMeta()).thenReturn(mockStepMeta);
    when(mockSelectValuesStepMeta.getParentStepMeta()).thenReturn(mockStepMeta);
    when(mockStepMeta.getStepMetaInterface()).thenReturn(mockGenRowsStepMeta);
    when(mockStepMeta.getParentTransMeta()).thenReturn(mockContent);
    when(mockContent.listVariables()).thenReturn(new String[] {});
    final String PARAM = "param1";
    when(mockContent.listParameters()).thenReturn(new String[] { PARAM });
    when(mockContent.nrSteps()).thenReturn(1);
    when(mockContent.getStep(0)).thenReturn(mockStepMeta);
    when(mockContent.getParameterDefault(PARAM)).thenReturn("default");
    when(mockContent.getNextStepNames(mockStepMeta)).thenReturn(new String[] { "previousStepName" });
    descriptor = new MetaverseComponentDescriptor("name", DictionaryConst.NODE_TYPE_TRANS, namespace);
}
Also used : IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) Matchers.anyString(org.mockito.Matchers.anyString) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

Example 12 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory 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 13 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory in project pentaho-metaverse by pentaho.

the class MongoDbInputStepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    IMetaverseObjectFactory factory = MetaverseTestUtils.getMetaverseObjectFactory();
    when(mockBuilder.getMetaverseObjectFactory()).thenReturn(factory);
    analyzer = spy(new MongoDbInputStepAnalyzer());
    analyzer.setConnectionAnalyzer(mock(IConnectionAnalyzer.class));
    analyzer.setMetaverseBuilder(mockBuilder);
    analyzer.setBaseStepMeta(meta);
    analyzer.setRootNode(node);
    analyzer.setParentTransMeta(mockTransMeta);
    analyzer.setParentStepMeta(parentStepMeta);
    when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace);
    descriptor = new MetaverseComponentDescriptor("test", DictionaryConst.NODE_TYPE_TRANS_STEP, mockNamespace);
    analyzer.setDescriptor(descriptor);
    when(meta.getParentStepMeta()).thenReturn(parentStepMeta);
    when(parentStepMeta.getParentTransMeta()).thenReturn(mockTransMeta);
    when(parentStepMeta.getName()).thenReturn("test");
    when(parentStepMeta.getStepID()).thenReturn("MongoDbInput");
}
Also used : IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) IConnectionAnalyzer(org.pentaho.metaverse.api.IConnectionAnalyzer) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

Example 14 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory in project pentaho-metaverse by pentaho.

the class DocumentControllerTest method testSetMetaverseObjectFactory_nullBuilder.

@Test
public void testSetMetaverseObjectFactory_nullBuilder() throws Exception {
    DocumentController dc = new DocumentController(null);
    IMetaverseObjectFactory factory = mock(IMetaverseObjectFactory.class);
    dc.setMetaverseObjectFactory(factory);
    verify(mockBuilder, never()).setMetaverseObjectFactory(any(IMetaverseObjectFactory.class));
}
Also used : IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) Test(org.junit.Test)

Example 15 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory in project pentaho-metaverse by pentaho.

the class DocumentControllerTest method testGetMetaverseObjectFactory.

@Test
public void testGetMetaverseObjectFactory() throws Exception {
    docController.setMetaverseBuilder(mockBuilder);
    IMetaverseObjectFactory objectFactory = mock(IMetaverseObjectFactory.class);
    when(mockBuilder.getMetaverseObjectFactory()).thenReturn(objectFactory);
    assertNotNull(docController.getMetaverseObjectFactory());
    verify(mockBuilder).getMetaverseObjectFactory();
}
Also used : IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) Test(org.junit.Test)

Aggregations

IMetaverseObjectFactory (org.pentaho.metaverse.api.IMetaverseObjectFactory)18 Before (org.junit.Before)10 Test (org.junit.Test)7 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)6 IDocument (org.pentaho.metaverse.api.IDocument)3 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)3 INamespace (org.pentaho.metaverse.api.INamespace)3 Matchers.anyString (org.mockito.Matchers.anyString)2 IConnectionAnalyzer (org.pentaho.metaverse.api.IConnectionAnalyzer)2 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)2 Graph (com.tinkerpop.blueprints.Graph)1 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)1 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)1 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)1 IDocumentAnalyzer (org.pentaho.metaverse.api.IDocumentAnalyzer)1 IDocumentController (org.pentaho.metaverse.api.IDocumentController)1 MetaverseException (org.pentaho.metaverse.api.MetaverseException)1