Search in sources :

Example 1 with NoneDatabaseMeta

use of org.apache.hop.core.database.NoneDatabaseMeta in project hop by apache.

the class DatabaseLookupUTest method createSpiedTransform.

private DatabaseLookup createSpiedTransform(Database db, TransformMockHelper<DatabaseLookupMeta, DatabaseLookupData> mockHelper, DatabaseLookupMeta meta, DatabaseLookupData data) throws HopException {
    NoneDatabaseMeta genericMeta = new NoneDatabaseMeta();
    DatabaseMeta dbMeta = new DatabaseMeta();
    dbMeta.setIDatabase(genericMeta);
    DatabaseLookup transform = spyLookup(mockHelper, meta, data, db, dbMeta);
    when(transform.getPipelineMeta().findDatabase(any(String.class), any(IVariables.class))).thenReturn(dbMeta);
    doNothing().when(transform).determineFieldsTypesQueryingDb();
    doReturn(null).when(transform).lookupValues(any(IRowMeta.class), any(Object[].class));
    RowMeta input = new RowMeta();
    input.addValueMeta(new ValueMetaInteger("Test"));
    transform.setInputRowMeta(input);
    return transform;
}
Also used : RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IVariables(org.apache.hop.core.variables.IVariables) IRowMeta(org.apache.hop.core.row.IRowMeta) NoneDatabaseMeta(org.apache.hop.core.database.NoneDatabaseMeta) ValueMetaInteger(org.apache.hop.core.row.value.ValueMetaInteger) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) NoneDatabaseMeta(org.apache.hop.core.database.NoneDatabaseMeta) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta)

Example 2 with NoneDatabaseMeta

use of org.apache.hop.core.database.NoneDatabaseMeta in project hop by apache.

the class DatabaseLookupUTest method testEqualsAndIsNullAreCached.

@Test
public void testEqualsAndIsNullAreCached() throws Exception {
    when(mockHelper.logChannelFactory.create(any(), any(ILoggingObject.class))).thenReturn(mockHelper.iLogChannel);
    DatabaseLookupData data = new DatabaseLookupData();
    data.cache = DefaultCache.newCache(data, 0);
    data.lookupMeta = new RowMeta();
    NoneDatabaseMeta genericMeta = new NoneDatabaseMeta();
    DatabaseMeta dbMeta = new DatabaseMeta();
    dbMeta.setIDatabase(genericMeta);
    DatabaseLookupMeta meta = new DatabaseLookupMeta();
    meta.setConnection("connection1");
    Lookup lookup = meta.getLookup();
    // meta.setDatabaseMeta(dbMeta);
    lookup.setTableName("VirtualTable");
    lookup.getKeyFields().add(new KeyField("", "", "=", "ID1"));
    lookup.getKeyFields().add(new KeyField("", "", "IS NULL", "ID2"));
    lookup.getReturnValues().add(new ReturnValue(BINARY_FIELD, "val1", "", "Binary", ValueMetaString.getTrimTypeCode(IValueMeta.TRIM_TYPE_NONE)));
    lookup.getReturnValues().add(new ReturnValue(BINARY_FIELD, "val2", "", "Binary", ValueMetaString.getTrimTypeCode(IValueMeta.TRIM_TYPE_NONE)));
    meta = spy(meta);
    doAnswer(invocation -> {
        IRowMeta row = (IRowMeta) invocation.getArguments()[0];
        IValueMeta v = new ValueMetaBinary(BINARY_FIELD);
        row.addValueMeta(v);
        return null;
    }).when(meta).getFields(nullable(IRowMeta.class), nullable(String.class), nullable(IRowMeta[].class), nullable(TransformMeta.class), nullable(IVariables.class), nullable(IHopMetadataProvider.class));
    DatabaseLookup look = new MockDatabaseLookup(mockHelper.transformMeta, meta, data, 0, mockHelper.pipelineMeta, mockHelper.pipeline);
    when(look.getPipelineMeta().findDatabase(nullable(String.class), nullable(IVariables.class))).thenReturn(dbMeta);
    look.init();
    assertTrue(data.allEquals);
}
Also used : ILoggingObject(org.apache.hop.core.logging.ILoggingObject) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) NoneDatabaseMeta(org.apache.hop.core.database.NoneDatabaseMeta) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) ValueMetaBinary(org.apache.hop.core.row.value.ValueMetaBinary) IValueMeta(org.apache.hop.core.row.IValueMeta) IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) NoneDatabaseMeta(org.apache.hop.core.database.NoneDatabaseMeta) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider)

Example 3 with NoneDatabaseMeta

use of org.apache.hop.core.database.NoneDatabaseMeta in project hop by apache.

the class DatabaseLookupUTest method createDatabaseLookup.

private DatabaseLookupMeta createDatabaseLookup() throws HopException {
    NoneDatabaseMeta genericMeta = new NoneDatabaseMeta();
    DatabaseMeta dbMeta = new DatabaseMeta();
    dbMeta.setIDatabase(genericMeta);
    DatabaseLookupMeta meta = new DatabaseLookupMeta();
    Lookup lookup = meta.getLookup();
    // meta.setDatabaseMeta(dbMeta);
    lookup.setSchemaName("VirtualSchema");
    lookup.setTableName("VirtualTable");
    lookup.getKeyFields().add(new KeyField("", "", "=", ID_FIELD));
    lookup.getReturnValues().add(new ReturnValue(BINARY_FIELD, "returned value", "", "Binary", ValueMetaString.getTrimTypeCode(IValueMeta.TRIM_TYPE_NONE)));
    meta = spy(meta);
    doAnswer(invocation -> {
        IRowMeta row = (IRowMeta) invocation.getArguments()[0];
        IValueMeta v = new ValueMetaBinary(BINARY_FIELD);
        row.addValueMeta(v);
        return null;
    }).when(meta).getFields(any(IRowMeta.class), anyString(), any(IRowMeta[].class), any(TransformMeta.class), any(IVariables.class), any(IHopMetadataProvider.class));
    return meta;
}
Also used : ValueMetaBinary(org.apache.hop.core.row.value.ValueMetaBinary) IValueMeta(org.apache.hop.core.row.IValueMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) NoneDatabaseMeta(org.apache.hop.core.database.NoneDatabaseMeta) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) NoneDatabaseMeta(org.apache.hop.core.database.NoneDatabaseMeta) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta)

Aggregations

DatabaseMeta (org.apache.hop.core.database.DatabaseMeta)3 NoneDatabaseMeta (org.apache.hop.core.database.NoneDatabaseMeta)3 IRowMeta (org.apache.hop.core.row.IRowMeta)3 IVariables (org.apache.hop.core.variables.IVariables)3 IValueMeta (org.apache.hop.core.row.IValueMeta)2 RowMeta (org.apache.hop.core.row.RowMeta)2 ValueMetaBinary (org.apache.hop.core.row.value.ValueMetaBinary)2 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)2 IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)2 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)2 ILoggingObject (org.apache.hop.core.logging.ILoggingObject)1 ValueMetaInteger (org.apache.hop.core.row.value.ValueMetaInteger)1