Search in sources :

Example 1 with ProgressMonitorListener

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));
}
Also used : ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) LongObjectId(org.pentaho.di.repository.LongObjectId) ProgressMonitorListener(org.pentaho.di.core.ProgressMonitorListener) Test(org.junit.Test)

Example 2 with ProgressMonitorListener

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);
}
Also used : Method(java.lang.reflect.Method) ProgressMonitorListener(org.pentaho.di.core.ProgressMonitorListener)

Example 3 with ProgressMonitorListener

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());
    }
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) ProgressMonitorListener(org.pentaho.di.core.ProgressMonitorListener) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Aggregations

ProgressMonitorListener (org.pentaho.di.core.ProgressMonitorListener)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Method (java.lang.reflect.Method)1 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 Variables (org.pentaho.di.core.variables.Variables)1 LongObjectId (org.pentaho.di.repository.LongObjectId)1 Repository (org.pentaho.di.repository.Repository)1 IMetaStore (org.pentaho.metastore.api.IMetaStore)1