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;
}
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);
}
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;
}
Aggregations