Search in sources :

Example 1 with TableProvider

use of org.apache.samza.table.TableProvider in project samza by apache.

the class TestLocalTableProvider method testInit.

@Test
public void testInit() {
    Context context = mock(Context.class);
    JobContext jobContext = mock(JobContext.class);
    when(context.getJobContext()).thenReturn(jobContext);
    when(jobContext.getConfig()).thenReturn(new MapConfig());
    ContainerContext containerContext = mock(ContainerContext.class);
    when(context.getContainerContext()).thenReturn(containerContext);
    when(containerContext.getContainerMetricsRegistry()).thenReturn(new NoOpMetricsRegistry());
    TaskContext taskContext = mock(TaskContext.class);
    when(context.getTaskContext()).thenReturn(taskContext);
    when(taskContext.getStore(any())).thenReturn(mock(KeyValueStore.class));
    TableProvider tableProvider = createTableProvider("t1");
    tableProvider.init(context);
    Assert.assertNotNull(tableProvider.getTable());
}
Also used : Context(org.apache.samza.context.Context) JobContext(org.apache.samza.context.JobContext) ContainerContext(org.apache.samza.context.ContainerContext) TaskContext(org.apache.samza.context.TaskContext) ContainerContext(org.apache.samza.context.ContainerContext) TaskContext(org.apache.samza.context.TaskContext) NoOpMetricsRegistry(org.apache.samza.util.NoOpMetricsRegistry) JobContext(org.apache.samza.context.JobContext) MapConfig(org.apache.samza.config.MapConfig) TableProvider(org.apache.samza.table.TableProvider) Test(org.junit.Test)

Example 2 with TableProvider

use of org.apache.samza.table.TableProvider in project samza by apache.

the class TestLocalTableProvider method testInitFail.

@Test(expected = NullPointerException.class)
public void testInitFail() {
    TableProvider tableProvider = createTableProvider("t1");
    Assert.assertNotNull(tableProvider.getTable());
}
Also used : TableProvider(org.apache.samza.table.TableProvider) Test(org.junit.Test)

Aggregations

TableProvider (org.apache.samza.table.TableProvider)2 Test (org.junit.Test)2 MapConfig (org.apache.samza.config.MapConfig)1 ContainerContext (org.apache.samza.context.ContainerContext)1 Context (org.apache.samza.context.Context)1 JobContext (org.apache.samza.context.JobContext)1 TaskContext (org.apache.samza.context.TaskContext)1 NoOpMetricsRegistry (org.apache.samza.util.NoOpMetricsRegistry)1