use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class FilterRowsStepAnalyzerTest method testGetUsedFields.
@Test
public void testGetUsedFields() throws Exception {
StepNodes inputNodes = new StepNodes();
inputNodes.addNode("input", "height", node);
inputNodes.addNode("input", "width", node);
inputNodes.addNode("input", "radius", node);
inputNodes.addNode("input", "pi", node);
inputNodes.addNode("input", "two", node);
when(analyzer.getInputs()).thenReturn(inputNodes);
Set<StepField> usedFields = analyzer.getUsedFields(meta);
assertNotNull(usedFields);
assertEquals(conditionFields.length, usedFields.size());
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class GroupByStepAnalyzerTest method testGetUsedFields.
@Test
public void testGetUsedFields() throws Exception {
Set<StepField> fields = new HashSet<>();
fields.add(new StepField("prev", "member"));
fields.add(new StepField("prev", "donation"));
fields.add(new StepField("prev", "state"));
fields.add(new StepField("prev", "country"));
doReturn(fields).when(analyzer).createStepFields(anyString(), any(StepNodes.class));
Set<StepField> usedFields = analyzer.getUsedFields(meta);
int expectedUsedFieldCount = mockAggregateFields.length + mockSubjectFields.length;
assertEquals(expectedUsedFieldCount, usedFields.size());
verify(analyzer, times(expectedUsedFieldCount)).createStepFields(anyString(), any(StepNodes.class));
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class NumberRangeStepAnalyzerTest method testGetUsedFields.
@Test
public void testGetUsedFields() throws Exception {
Set<StepField> fields = new HashSet<>();
fields.add(new StepField("prev", "inField"));
doReturn(fields).when(analyzer).createStepFields(anyString(), any(StepNodes.class));
Set<StepField> usedFields = analyzer.getUsedFields(meta);
int expectedUsedFieldCount = 1;
assertEquals(expectedUsedFieldCount, usedFields.size());
verify(analyzer, times(expectedUsedFieldCount)).createStepFields(anyString(), any(StepNodes.class));
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class SelectValuesStepAnalyzerTest method testIsPassthrough.
@Test
public void testIsPassthrough() throws Exception {
String[] deleted = new String[] { "first, last" };
String[] selected = new String[] { "age" };
SelectMetadataChange[] changed = new SelectMetadataChange[] { testChange1, testChange2 };
when(selectValuesMeta.getDeleteName()).thenReturn(deleted);
when(selectValuesMeta.getSelectName()).thenReturn(selected);
when(selectValuesMeta.getMeta()).thenReturn(changed);
StepField stepField = new StepField("previousStep", "first");
assertFalse(analyzer.isPassthrough(stepField));
stepField.setFieldName("last");
assertFalse(analyzer.isPassthrough(stepField));
stepField.setFieldName("age");
assertFalse(analyzer.isPassthrough(stepField));
// birthday should not be a passthrough, there are fields "selected"
stepField.setFieldName("birthday");
assertFalse(analyzer.isPassthrough(stepField));
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class SelectValuesStepAnalyzerTest method testIsPassthrough_deleteAndMeta.
@Test
public void testIsPassthrough_deleteAndMeta() throws Exception {
String[] deleted = new String[] { "first", "age" };
String[] selected = new String[0];
SelectMetadataChange[] changed = new SelectMetadataChange[] { testChange1, testChange2 };
when(selectValuesMeta.getDeleteName()).thenReturn(deleted);
when(selectValuesMeta.getSelectName()).thenReturn(selected);
when(selectValuesMeta.getMeta()).thenReturn(changed);
StepField stepField = new StepField("previousStep", "first");
// first was deleted, not a passthrough
assertFalse(analyzer.isPassthrough(stepField));
stepField.setFieldName("last");
// last not deleted but it is meta-modified, not a passthrough
assertFalse(analyzer.isPassthrough(stepField));
stepField.setFieldName("age");
// age was deleted, it is NOT passthrough
assertFalse(analyzer.isPassthrough(stepField));
stepField.setFieldName("birthday");
// birthday was NOT deleted and not meta-modified, it is a passthrough
assertTrue(analyzer.isPassthrough(stepField));
}
Aggregations