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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations