Search in sources :

Example 6 with IStepAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer in project pentaho-metaverse by pentaho.

the class StepAnalyzerProviderTest method testLoadAnalyzerTypeMap.

@Test
public void testLoadAnalyzerTypeMap() throws Exception {
    IStepAnalyzer baseStepAnalyzer = mock(IStepAnalyzer.class);
    when(baseStepAnalyzer.getSupportedSteps()).thenReturn(Sets.newSet(BaseStepMeta.class));
    IStepAnalyzer tableOutputStepAnalyzer = mock(IStepAnalyzer.class);
    when(tableOutputStepAnalyzer.getSupportedSteps()).thenReturn(Sets.newSet(TableOutputMeta.class));
    IStepAnalyzer tableOutputStepAnalyzer2 = mock(IStepAnalyzer.class);
    when(tableOutputStepAnalyzer2.getSupportedSteps()).thenReturn(Sets.newSet(TableOutputMeta.class));
    provider.stepAnalyzers = Lists.newArrayList(baseStepAnalyzer, tableOutputStepAnalyzer, tableOutputStepAnalyzer2);
    // Method under test
    provider.loadAnalyzerTypeMap();
    Set<IStepAnalyzer> baseStepAnalyzers = provider.analyzerTypeMap.get(BaseStepMeta.class);
    assertNotNull(baseStepAnalyzers);
    assertEquals(baseStepAnalyzers.size(), 1);
    Set<IStepAnalyzer> tableOutputStepAnalyzers = provider.analyzerTypeMap.get(TableOutputMeta.class);
    assertNotNull(tableOutputStepAnalyzers);
    assertEquals(tableOutputStepAnalyzers.size(), 2);
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) TableOutputMeta(org.pentaho.di.trans.steps.tableoutput.TableOutputMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 7 with IStepAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer in project pentaho-metaverse by pentaho.

the class StepAnalyzerProviderTest method testGetAnalyzersForClass.

@Test
public void testGetAnalyzersForClass() throws Exception {
    Set<IStepAnalyzer> baseStepAnalyzerSet = Sets.newSet(mock(IStepAnalyzer.class));
    Set<IStepAnalyzer> tableOutputStepAnalyzerSet = Sets.newSet(mock(IStepAnalyzer.class));
    // Return the baseStepAnalyzer set if BaseStepMeta analyzers are requested
    provider.analyzerTypeMap.put(BaseStepMeta.class, baseStepAnalyzerSet);
    // Return the tableOutputStepAnalyzerSet set if TableOutputMeta analyzers are requested
    provider.analyzerTypeMap.put(TableOutputMeta.class, tableOutputStepAnalyzerSet);
    List<IStepAnalyzer> analyzers = provider.getAnalyzers(new ArrayList() {

        {
            add(BaseStepMeta.class);
            add(TableOutputMeta.class);
        }
    });
    assertEquals(analyzers.size(), 2);
    analyzers = provider.getAnalyzers(new HashSet() {

        {
            add(TableOutputMeta.class);
        }
    });
    assertEquals(analyzers.size(), 1);
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) ArrayList(java.util.ArrayList) TableOutputMeta(org.pentaho.di.trans.steps.tableoutput.TableOutputMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with IStepAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer in project pentaho-metaverse by pentaho.

the class StepAnalyzerProviderTest method testRemoveAnalyzer.

@Test
public void testRemoveAnalyzer() throws Exception {
    IStepAnalyzer baseStepAnalyzer = mock(IStepAnalyzer.class);
    when(baseStepAnalyzer.getSupportedSteps()).thenReturn(Sets.newSet(BaseStepMeta.class));
    IStepAnalyzer tableOutputStepAnalyzer = mock(IStepAnalyzer.class);
    when(tableOutputStepAnalyzer.getSupportedSteps()).thenReturn(Sets.newSet(TableOutputMeta.class));
    provider.setStepAnalyzers(Lists.newArrayList(baseStepAnalyzer, tableOutputStepAnalyzer));
    Set<IStepAnalyzer> tableOutputStepAnalyzers = provider.analyzerTypeMap.get(TableOutputMeta.class);
    assertNotNull(tableOutputStepAnalyzers);
    assertEquals(tableOutputStepAnalyzers.size(), 1);
    provider.removeAnalyzer(tableOutputStepAnalyzer);
    tableOutputStepAnalyzers = provider.analyzerTypeMap.get(TableOutputMeta.class);
    assertNull(tableOutputStepAnalyzers);
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) TableOutputMeta(org.pentaho.di.trans.steps.tableoutput.TableOutputMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 9 with IStepAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer in project pentaho-metaverse by pentaho.

the class StepAnalyzerProviderTest method testRemoveAnalyzer_multipleWithTheSameType.

@Test
public void testRemoveAnalyzer_multipleWithTheSameType() throws Exception {
    IStepAnalyzer baseStepAnalyzer = mock(IStepAnalyzer.class);
    when(baseStepAnalyzer.getSupportedSteps()).thenReturn(Sets.newSet(BaseStepMeta.class));
    IStepAnalyzer tableOutputStepAnalyzer = mock(IStepAnalyzer.class);
    when(tableOutputStepAnalyzer.getSupportedSteps()).thenReturn(Sets.newSet(TableOutputMeta.class));
    IStepAnalyzer tableOutputStepAnalyzer2 = mock(IStepAnalyzer.class);
    when(tableOutputStepAnalyzer2.getSupportedSteps()).thenReturn(Sets.newSet(TableOutputMeta.class));
    provider.setStepAnalyzers(Lists.newArrayList(baseStepAnalyzer, tableOutputStepAnalyzer, tableOutputStepAnalyzer2));
    Set<IStepAnalyzer> tableOutputStepAnalyzers = provider.analyzerTypeMap.get(TableOutputMeta.class);
    assertNotNull(tableOutputStepAnalyzers);
    assertEquals(tableOutputStepAnalyzers.size(), 2);
    provider.removeAnalyzer(tableOutputStepAnalyzer2);
    tableOutputStepAnalyzers = provider.analyzerTypeMap.get(TableOutputMeta.class);
    assertNotNull(tableOutputStepAnalyzers);
    assertEquals(tableOutputStepAnalyzers.size(), 1);
    assertEquals(tableOutputStepAnalyzer, tableOutputStepAnalyzers.iterator().next());
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) TableOutputMeta(org.pentaho.di.trans.steps.tableoutput.TableOutputMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 10 with IStepAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer in project pentaho-metaverse by pentaho.

the class AnalyzerInfoServiceTest method testGetSupportedSteps.

@Test
public void testGetSupportedSteps() throws Exception {
    List<IStepAnalyzer> analyzers = new ArrayList<>();
    final StringsCutStepAnalyzer stringsCutStepAnalyzer = new StringsCutStepAnalyzer();
    final MergeJoinStepAnalyzer mergeJoinStepAnalyzer = new MergeJoinStepAnalyzer();
    analyzers.add(stringsCutStepAnalyzer);
    analyzers.add(mergeJoinStepAnalyzer);
    when(stepAnalyzerProvider.getAnalyzers()).thenReturn(analyzers);
    Response supportedSteps = service.getSupportedSteps();
    assertEquals(Response.Status.OK.getStatusCode(), supportedSteps.getStatus());
    assertNotNull(supportedSteps.getEntity());
    assertTrue(supportedSteps.getEntity() instanceof List);
    List<AnalyzerInfo> responseList = (List<AnalyzerInfo>) supportedSteps.getEntity();
    assertEquals(analyzers.size(), responseList.size());
    // should be sorted based on meta name
    assertEquals(mergeJoinStepAnalyzer.getSupportedSteps().iterator().next().getSimpleName(), responseList.get(0).getMeta());
    assertEquals(stringsCutStepAnalyzer.getSupportedSteps().iterator().next().getSimpleName(), responseList.get(1).getMeta());
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) Response(javax.ws.rs.core.Response) StringsCutStepAnalyzer(org.pentaho.metaverse.analyzer.kettle.step.stringscut.StringsCutStepAnalyzer) MergeJoinStepAnalyzer(org.pentaho.metaverse.analyzer.kettle.step.mergejoin.MergeJoinStepAnalyzer) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

IStepAnalyzer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer)10 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 TableOutputMeta (org.pentaho.di.trans.steps.tableoutput.TableOutputMeta)4 GenericStepMetaAnalyzer (org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer)4 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)2 IFieldLineageMetadataProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider)2 IStepAnalyzerProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzerProvider)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Date (java.util.Date)1 List (java.util.List)1 Set (java.util.Set)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)1 KettleException (org.pentaho.di.core.exception.KettleException)1