/** * Generate configuration for provided tables * * @param jobConfig existing job config * @param tableDescriptors table descriptors, for which configuration to be generated * @return table configuration */ public static Map<String, String> generate(Config jobConfig, List<TableDescriptor> tableDescriptors) { Map<String, String> tableConfig = new HashMap<>(); tableDescriptors.forEach(tableDescriptor -> tableConfig.putAll(tableDescriptor.toConfig(jobConfig))); LOG.info("TableConfigGenerator has generated configs {}", tableConfig); return tableConfig; }
private Context createMockContext(TableDescriptor tableDescriptor) { Context context = mock(Context.class); ContainerContext containerContext = mock(ContainerContext.class); when(context.getContainerContext()).thenReturn(containerContext); MetricsRegistry metricsRegistry = mock(MetricsRegistry.class); when(metricsRegistry.newTimer(anyString(), anyString())).thenReturn(mock(Timer.class)); when(metricsRegistry.newCounter(anyString(), anyString())).thenReturn(mock(Counter.class)); when(containerContext.getContainerMetricsRegistry()).thenReturn(metricsRegistry); TaskContextImpl taskContext = mock(TaskContextImpl.class); when(context.getTaskContext()).thenReturn(taskContext); TaskName taskName = new TaskName("MyTask"); TaskModel taskModel = mock(TaskModel.class); when(taskModel.getTaskName()).thenReturn(taskName); when(context.getTaskContext().getTaskModel()).thenReturn(taskModel); ContainerModel containerModel = mock(ContainerModel.class); when(containerModel.getTasks()).thenReturn(ImmutableMap.of(taskName, taskModel)); when(containerContext.getContainerModel()).thenReturn(containerModel); String containerId = "container-1"; JobModel jobModel = mock(JobModel.class); when(taskContext.getJobModel()).thenReturn(jobModel); when(jobModel.getContainers()).thenReturn(ImmutableMap.of(containerId, containerModel)); JobContext jobContext = mock(JobContext.class); when(jobContext.getConfig()).thenReturn(new MapConfig(tableDescriptor.toConfig(new MapConfig()))); when(context.getJobContext()).thenReturn(jobContext); return context; }