use of com.thinkbiganalytics.kylo.catalog.api.KyloCatalogClient in project kylo by Teradata.
the class AbstractJdbcDataSetProviderTest method createHighWaterMark.
/**
* Verify creating a high water mark.
*/
@Test
public void createHighWaterMark() {
final KyloCatalogClient client = Mockito.mock(KyloCatalogClient.class);
// Test creating high water mark
final MockJdbcDataSetProvider provider = new MockJdbcDataSetProvider();
final JdbcHighWaterMark highWaterMark = provider.createHighWaterMark("mockWaterMark", client);
Assert.assertEquals("mockWaterMark", highWaterMark.getName());
Assert.assertNull("Expected initial value to be null", highWaterMark.getValue());
// Test adding a value
highWaterMark.accumulate(1525014303000L);
Mockito.verify(client).setHighWaterMarks(Collections.singletonMap("mockWaterMark", "2018-04-29T15:05:03"));
}
use of com.thinkbiganalytics.kylo.catalog.api.KyloCatalogClient in project kylo by Teradata.
the class AbstractJdbcDataSetProviderTest method updateHighWaterMarkWithTimestamp.
/**
* Verify updating a high water mark for a timestamp column.
*/
@Test
public void updateHighWaterMarkWithTimestamp() {
// Mock data set
final DataFrame dataSet = Mockito.mock(DataFrame.class);
Mockito.when(dataSet.col("mockField")).thenReturn(new Column("mockField"));
final StructField field = DataTypes.createStructField("mockField", DataTypes.TimestampType, true);
Mockito.when(dataSet.schema()).thenReturn(DataTypes.createStructType(Collections.singletonList(field)));
final DataFrame mapDataSet = Mockito.mock(DataFrame.class);
Mockito.when(dataSet.withColumn(Mockito.eq("mockField"), Mockito.any(Column.class))).thenReturn(mapDataSet);
// Test updating high water mark
final KyloCatalogClient client = Mockito.mock(KyloCatalogClient.class);
final JdbcHighWaterMark highWaterMark = new JdbcHighWaterMark("mockWaterMark", client);
final MockJdbcDataSetProvider provider = new MockJdbcDataSetProvider();
final DataFrame newDataSet = provider.updateHighWaterMark(dataSet, "mockField", highWaterMark, client);
Assert.assertEquals(mapDataSet, newDataSet);
// Test replaced column
final ArgumentCaptor<Column> newColumn = ArgumentCaptor.forClass(Column.class);
Mockito.verify(dataSet).withColumn(Mockito.eq("mockField"), newColumn.capture());
Assert.assertTrue("Expected new column to be a UDF", newColumn.getValue().expr() instanceof ScalaUDF);
}
Aggregations