use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class XMLOutputMetaTest method testExportResources.
@Test
public void testExportResources() throws Exception {
XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
xmlOutputMeta.setDefault();
ResourceNamingInterface resourceNamingInterface = mock(ResourceNamingInterface.class);
Variables space = new Variables();
when(resourceNamingInterface.nameResource(any(FileObject.class), eq(space), eq(true))).thenReturn("exportFile");
xmlOutputMeta.exportResources(space, null, resourceNamingInterface, null, null);
assertEquals("exportFile", xmlOutputMeta.getFileName());
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class XMLOutputMetaTest method testCheck.
@Test
public void testCheck() throws Exception {
XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
xmlOutputMeta.setDefault();
TransMeta transMeta = mock(TransMeta.class);
StepMeta stepInfo = mock(StepMeta.class);
RowMetaInterface prev = mock(RowMetaInterface.class);
Repository repos = mock(Repository.class);
IMetaStore metastore = mock(IMetaStore.class);
RowMetaInterface info = mock(RowMetaInterface.class);
ArrayList<CheckResultInterface> remarks = new ArrayList<>();
xmlOutputMeta.check(remarks, transMeta, stepInfo, prev, new String[] { "input" }, new String[] { "output" }, info, new Variables(), repos, metastore);
assertEquals(2, remarks.size());
assertEquals("Step is receiving info from other steps.", remarks.get(0).getText());
assertEquals("File specifications are not checked.", remarks.get(1).getText());
XMLField xmlField = new XMLField();
xmlField.setFieldName("aField");
xmlField.setType(1);
xmlField.setLength(10);
xmlField.setPrecision(3);
xmlOutputMeta.setOutputFields(new XMLField[] { xmlField });
when(prev.size()).thenReturn(1);
remarks.clear();
xmlOutputMeta.check(remarks, transMeta, stepInfo, prev, new String[] { "input" }, new String[] { "output" }, info, new Variables(), repos, metastore);
assertEquals(4, remarks.size());
assertEquals("Step is connected to previous one, receiving 1 fields", remarks.get(0).getText());
assertEquals("All output fields are found in the input stream.", remarks.get(1).getText());
assertEquals("Step is receiving info from other steps.", remarks.get(2).getText());
assertEquals("File specifications are not checked.", remarks.get(3).getText());
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class XMLOutputMetaTest method testGetFiles.
@Test
public void testGetFiles() throws Exception {
XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
xmlOutputMeta.setDefault();
xmlOutputMeta.setStepNrInFilename(true);
xmlOutputMeta.setSplitEvery(100);
xmlOutputMeta.setSpecifyFormat(true);
xmlOutputMeta.setDateTimeFormat("99");
String[] files = xmlOutputMeta.getFiles(new Variables());
assertEquals(10, files.length);
assertArrayEquals(new String[] { "file99_0_00001.xml", "file99_0_00002.xml", "file99_0_00003.xml", "file99_1_00001.xml", "file99_1_00002.xml", "file99_1_00003.xml", "file99_2_00001.xml", "file99_2_00002.xml", "file99_2_00003.xml", "..." }, files);
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class XMLOutputMetaTest method testGetRequiredFields.
@Test
public void testGetRequiredFields() throws Exception {
XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
xmlOutputMeta.setDefault();
XMLField xmlField = new XMLField();
xmlField.setFieldName("aField");
xmlField.setType(1);
xmlField.setLength(10);
xmlField.setPrecision(3);
XMLField xmlField2 = new XMLField();
xmlField2.setFieldName("bField");
xmlField2.setType(3);
xmlField2.setLength(4);
xmlField2.setPrecision(5);
xmlOutputMeta.setOutputFields(new XMLField[] { xmlField, xmlField2 });
RowMetaInterface requiredFields = xmlOutputMeta.getRequiredFields(new Variables());
List<ValueMetaInterface> valueMetaList = requiredFields.getValueMetaList();
assertEquals(2, valueMetaList.size());
assertEquals("aField", valueMetaList.get(0).getName());
assertEquals(1, valueMetaList.get(0).getType());
assertEquals(10, valueMetaList.get(0).getLength());
assertEquals(3, valueMetaList.get(0).getPrecision());
assertEquals("bField", valueMetaList.get(1).getName());
assertEquals(3, valueMetaList.get(1).getType());
assertEquals(4, valueMetaList.get(1).getLength());
assertEquals(5, valueMetaList.get(1).getPrecision());
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class EditRowsDialog method addFields.
private boolean addFields() {
// int middle = props.getMiddlePct();
int margin = Const.MARGIN;
if (wlMessage == null) {
wlMessage = new Label(shell, SWT.LEFT);
wlMessage.setText(message);
props.setLook(wlMessage);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.right = new FormAttachment(100, 0);
fdlFields.top = new FormAttachment(0, margin);
wlMessage.setLayoutData(fdlFields);
} else {
wFields.dispose();
}
// Mmm, if we don't get any row metadata: show a dialog box.
if (rowMeta == null || rowMeta.size() == 0) {
ShowMessageDialog dialog = new ShowMessageDialog(shell, SWT.OK | SWT.ICON_WARNING, BaseMessages.getString(PKG, "EditRowsDialog.NoRowMeta.Text"), BaseMessages.getString(PKG, "EditRowsDialog.NoRowMeta.Message"));
dialog.open();
shell.dispose();
return true;
}
// ColumnInfo[] colinf = new ColumnInfo[rowMeta==null ? 0 : rowMeta.size()];
ColumnInfo[] colinf = new ColumnInfo[rowMeta.size()];
for (int i = 0; i < rowMeta.size(); i++) {
ValueMetaInterface v = rowMeta.getValueMeta(i);
colinf[i] = new ColumnInfo(v.getName(), ColumnInfo.COLUMN_TYPE_TEXT, v.isNumeric());
colinf[i].setToolTip(v.toStringMeta());
colinf[i].setValueMeta(v);
}
wFields = new TableView(new Variables(), shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, rowBuffer.size(), null, props);
wFields.setShowingBlueNullValues(true);
fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlMessage, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(100, -50);
wFields.setLayoutData(fdFields);
shell.layout(true, true);
return false;
}
Aggregations