@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()); }
@Test(expected = NullPointerException.class) public void testInitFail() { TableProvider tableProvider = createTableProvider("t1"); Assert.assertNotNull(tableProvider.getTable()); }