use of org.pentaho.di.core.ProgressMonitorListener in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConnectionDelegateUnitTest method testGetValueToIdMap.
@Test
public void testGetValueToIdMap() throws KettleException {
String tablename = "test-tablename";
String idfield = "test-idfield";
String lookupfield = "test-lookupfield";
List<Object[]> rows = new ArrayList<Object[]>();
int id = 1234;
LongObjectId longObjectId = new LongObjectId(id);
rows.add(new Object[] { lookupfield, id });
when(database.getRows(eq("SELECT " + lookupfield + ", " + idfield + " FROM " + tablename), any(RowMetaInterface.class), eq(new Object[] {}), eq(ResultSet.FETCH_FORWARD), eq(false), eq(-1), eq((ProgressMonitorListener) null))).thenReturn(rows);
Map<String, LongObjectId> valueToIdMap = kettleDatabaseRepositoryConnectionDelegate.getValueToIdMap(tablename, idfield, lookupfield);
assertEquals(1, valueToIdMap.size());
assertEquals(longObjectId, valueToIdMap.get(lookupfield));
}
use of org.pentaho.di.core.ProgressMonitorListener in project pentaho-kettle by pentaho.
the class RepositoryImportExporterApiIT method testExportApi.
/**
* Validate the the repository export api hasn't changed from what we use in example files.
*
* @see RepositoryExporter#exportAllObjects(ProgressMonitorListener, String, RepositoryDirectoryInterface, String)
*/
public void testExportApi() throws Exception {
Class<RepositoryExporter> exporter = RepositoryExporter.class;
// Make sure we the expected constructor that takes a repository
Constructor<RepositoryExporter> c = exporter.getConstructor(Repository.class);
assertNotNull(c);
// Make sure we have the correct signature for exporting objects
// RepositoryExporter.exportAllObjects(ProgressMonitorListener, String, RepositoryDirectoryInterface, String)
Class<?> param1 = ProgressMonitorListener.class;
Class<?> param2 = String.class;
Class<?> param3 = RepositoryDirectoryInterface.class;
Class<?> param4 = String.class;
Method m = exporter.getMethod("exportAllObjects", param1, param2, param3, param4);
assertNotNull(m);
}
use of org.pentaho.di.core.ProgressMonitorListener in project pentaho-kettle by pentaho.
the class TransMetaTest method testTransWithOneStepIsConsideredUsed.
@Test
public void testTransWithOneStepIsConsideredUsed() throws Exception {
TransMeta transMeta = new TransMeta(getClass().getResource("one-step-trans.ktr").getPath());
assertEquals(1, transMeta.getUsedSteps().size());
Repository rep = mock(Repository.class);
ProgressMonitorListener monitor = mock(ProgressMonitorListener.class);
List<CheckResultInterface> remarks = new ArrayList<>();
IMetaStore metaStore = mock(IMetaStore.class);
transMeta.checkSteps(remarks, false, monitor, new Variables(), rep, metaStore);
assertEquals(4, remarks.size());
for (CheckResultInterface remark : remarks) {
assertEquals(CheckResultInterface.TYPE_RESULT_OK, remark.getType());
}
}
Aggregations