Search in sources :

Example 11 with MockContext

use of org.apache.samza.context.MockContext in project samza by apache.

the class TestTableManager method doTestInit.

private void doTestInit(Map<String, String> map) {
    Map<String, StorageEngine> storageEngines = new HashMap<>();
    storageEngines.put(TABLE_ID, mock(StorageEngine.class));
    TableManager tableManager = new TableManager(new MapConfig(map));
    tableManager.init(new MockContext());
    for (int i = 0; i < 2; i++) {
        Table table = tableManager.getTable(TABLE_ID);
        verify(DummyTableProviderFactory.tableProvider, times(1)).init(anyObject());
        verify(DummyTableProviderFactory.tableProvider, times(1)).getTable();
        Assert.assertEquals(DummyTableProviderFactory.table, table);
    }
    Map<String, TableManager.TableCtx> ctxMap = getFieldValue(tableManager, "tableContexts");
    TableManager.TableCtx ctx = ctxMap.get(TABLE_ID);
    Assert.assertEquals(TABLE_ID, ctxMap.keySet().iterator().next());
    TableProvider tableProvider = getFieldValue(ctx, "tableProvider");
    Assert.assertNotNull(tableProvider);
}
Also used : MockContext(org.apache.samza.context.MockContext) HashMap(java.util.HashMap) StorageEngine(org.apache.samza.storage.StorageEngine) MapConfig(org.apache.samza.config.MapConfig)

Aggregations

MockContext (org.apache.samza.context.MockContext)11 MapConfig (org.apache.samza.config.MapConfig)7 Context (org.apache.samza.context.Context)7 HashMap (java.util.HashMap)4 TaskModel (org.apache.samza.job.model.TaskModel)4 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)4 Counter (org.apache.samza.metrics.Counter)3 MetricsRegistry (org.apache.samza.metrics.MetricsRegistry)3 Timer (org.apache.samza.metrics.Timer)3 ReadWriteUpdateTable (org.apache.samza.table.ReadWriteUpdateTable)3 Before (org.junit.Before)3 Partition (org.apache.samza.Partition)2 TaskName (org.apache.samza.container.TaskName)2 Gauge (org.apache.samza.metrics.Gauge)2 KV (org.apache.samza.operators.KV)2 StreamTableJoinOperatorSpec (org.apache.samza.operators.spec.StreamTableJoinOperatorSpec)2 IntegerSerde (org.apache.samza.serializers.IntegerSerde)2 KVSerde (org.apache.samza.serializers.KVSerde)2 SystemStreamPartition (org.apache.samza.system.SystemStreamPartition)2 MessageCollector (org.apache.samza.task.MessageCollector)2