use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class LoadFileInputMetaTest method testLoadXML.
@Test
public void testLoadXML() throws Exception {
LoadFileInputMeta origMeta = createMeta();
LoadFileInputMeta testMeta = new LoadFileInputMeta();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(new StringReader("<step>" + xmlOrig + "</step>")));
IMetaStore metaStore = null;
testMeta.loadXML(doc.getFirstChild(), null, metaStore);
assertEquals(origMeta, testMeta);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class TransMetaTest method testDatabaseNotOverridden.
@Test
public void testDatabaseNotOverridden() throws Exception {
final String name = "db meta";
DatabaseMeta dbMetaShared = new DatabaseMeta();
dbMetaShared.setName(name);
dbMetaShared.setHostname("host");
DatabaseMeta dbMetaStore = new DatabaseMeta();
dbMetaStore.setName(name);
dbMetaStore.setHostname("anotherhost");
IMetaStore mstore = new MemoryMetaStore();
DatabaseMetaStoreUtil.createDatabaseElement(mstore, dbMetaStore);
TransMeta trans = new TransMeta();
trans.addOrReplaceDatabase(dbMetaShared);
trans.setMetaStore(mstore);
trans.importFromMetaStore();
DatabaseMeta dbMeta = trans.findDatabase(name);
assertEquals(dbMetaShared.getHostname(), dbMeta.getHostname());
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class DimensionLookupMetaTest method testUseDefaultSchemaName.
@Test
public void testUseDefaultSchemaName() throws Exception {
String schemaName = "";
String tableName = "tableName";
String schemaTable = "default.tableName";
String keyField = "keyField";
DatabaseMeta databaseMeta = spy(new DatabaseMeta(databaseXML) {
@Override
public String getFieldDefinition(ValueMetaInterface v, String tk, String pk, boolean use_autoinc) {
return "someValue";
}
});
when(databaseMeta.getQuotedSchemaTableCombination(schemaName, tableName)).thenReturn(schemaTable);
DimensionLookupMeta dlm = new DimensionLookupMeta();
dlm.setUpdate(true);
dlm.setDatabaseMeta(databaseMeta);
dlm.setTableName(tableName);
dlm.setSchemaName(schemaName);
dlm.setKeyLookup(new String[] { "keyLookup1", "keyLookup2" });
dlm.setKeyStream(new String[] { "keyStream1", "keyStream2" });
dlm.setFieldLookup(new String[] { "fieldLookup1", "fieldLookup2" });
dlm.setFieldStream(new String[] { "FieldStream1", "FieldStream2" });
dlm.setFieldUpdate(new int[] { 1, 2 });
dlm.setKeyField(keyField);
StepMeta stepMeta = mock(StepMeta.class);
RowMetaInterface rowMetaInterface = mock(RowMetaInterface.class);
when(rowMetaInterface.size()).thenReturn(1);
Repository repository = mock(Repository.class);
IMetaStore metaStore = mock(IMetaStore.class);
SQLStatement sqlStatement = dlm.getSQLStatements(new TransMeta(), stepMeta, rowMetaInterface, repository, metaStore);
String sql = sqlStatement.getSQL();
assertEquals(3, StringUtils.countMatches(sql, schemaTable));
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class UnivariateStatsMetaTest method testLegacyLoadXml.
@Test
public void testLegacyLoadXml() throws IOException, KettleXMLException {
String legacyXml = IOUtils.toString(UnivariateStatsMetaTest.class.getClassLoader().getResourceAsStream("org/pentaho/di/trans/steps/univariatestats/legacyUnivariateStatsMetaTest.xml"));
IMetaStore mockMetaStore = mock(IMetaStore.class);
UnivariateStatsMeta meta = new UnivariateStatsMeta();
meta.loadXML(XMLHandler.loadXMLString(legacyXml).getFirstChild(), new ArrayList<DatabaseMeta>(), mockMetaStore);
assertEquals(2, meta.getNumFieldsToProcess());
UnivariateStatsMetaFunction first = meta.getInputFieldMetaFunctions()[0];
assertEquals("a", first.getSourceFieldName());
assertEquals(true, first.getCalcN());
assertEquals(true, first.getCalcMean());
assertEquals(true, first.getCalcStdDev());
assertEquals(true, first.getCalcMin());
assertEquals(true, first.getCalcMax());
assertEquals(true, first.getCalcMedian());
assertEquals(.5, first.getCalcPercentile(), 0);
assertEquals(true, first.getInterpolatePercentile());
UnivariateStatsMetaFunction second = meta.getInputFieldMetaFunctions()[1];
assertEquals("b", second.getSourceFieldName());
assertEquals(false, second.getCalcN());
assertEquals(false, second.getCalcMean());
assertEquals(false, second.getCalcStdDev());
assertEquals(false, second.getCalcMin());
assertEquals(false, second.getCalcMax());
assertEquals(false, second.getCalcMedian());
assertEquals(-1.0, second.getCalcPercentile(), 0);
assertEquals(false, second.getInterpolatePercentile());
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class WebServiceMetaTest method testGetFields.
@Test
public void testGetFields() throws Exception {
WebServiceMeta webServiceMeta = new WebServiceMeta();
webServiceMeta.setDefault();
RowMetaInterface rmi = mock(RowMetaInterface.class);
RowMetaInterface rmi2 = mock(RowMetaInterface.class);
StepMeta nextStep = mock(StepMeta.class);
IMetaStore metastore = mock(IMetaStore.class);
Repository rep = mock(Repository.class);
WebServiceField field1 = new WebServiceField();
field1.setName("field1");
field1.setWsName("field1WS");
field1.setXsdType("string");
WebServiceField field2 = new WebServiceField();
field2.setName("field2");
field2.setWsName("field2WS");
field2.setXsdType("string");
WebServiceField field3 = new WebServiceField();
field3.setName("field3");
field3.setWsName("field3WS");
field3.setXsdType("string");
webServiceMeta.setFieldsOut(Arrays.asList(field1, field2, field3));
webServiceMeta.getFields(rmi, "idk", new RowMetaInterface[] { rmi2 }, nextStep, new Variables(), rep, metastore);
verify(rmi).addValueMeta(argThat(matchValueMetaString("field1")));
verify(rmi).addValueMeta(argThat(matchValueMetaString("field2")));
verify(rmi).addValueMeta(argThat(matchValueMetaString("field3")));
}
Aggregations