DataSetDefsBootstrap extends AbstractDataSetDefsBootstrap { public void registerDataSetDefinitions(@Observes QueryDefinitionLoaded event) { if (event.getDefinition().getName().equals(DATASET_PROCESS_INSTANCES)) { registerDataSetDefinition(event.getDefinition(), builder -> builder.number(COLUMN_PROCESS_INSTANCE_ID) .label(COLUMN_PROCESS_ID) .date(COLUMN_PROCESS_START_DATE) .date(COLUMN_PROCESS_END_DATE) .number(COLUMN_PROCESS_STATUS) .number(COLUMN_PROCESS_DURATION) .label(COLUMN_PROCESS_USER_ID) .label(COLUMN_PROCESS_VERSION) .label(COLUMN_PROCESS_NAME) .label(COLUMN_PROCESS_EXTERNAL_ID) ); } else if (event.getDefinition().getName().equals(DATASET_HUMAN_TASKS)) { registerDataSetDefinition(event.getDefinition(), builder -> builder.label(COLUMN_PROCESS_NAME) .label(COLUMN_PROCESS_EXTERNAL_ID) .label(COLUMN_TASK_ID) .label(COLUMN_TASK_NAME) .label(COLUMN_TASK_STATUS) .date(COLUMN_TASK_CREATED_DATE) .date(COLUMN_TASK_START_DATE) .date(COLUMN_TASK_END_DATE) .number(COLUMN_PROCESS_INSTANCE_ID) .label(COLUMN_TASK_OWNER_ID) .number(COLUMN_TASK_DURATION) ); } }  void registerDataSetDefinitions(@Observes QueryDefinitionLoaded event);  }
@Test public void testProcessInstancesDataSet() { QueryDefinition qd = QueryDefinition.builder().name(DATASET_PROCESS_INSTANCES).expression("SELECT *").source("source").target("target").build(); dataSetsBootstrap.registerDataSetDefinitions(new QueryDefinitionLoaded(qd)); ArgumentCaptor<SQLDataSetDef> argument = ArgumentCaptor.forClass(SQLDataSetDef.class); verify(dataSetRegistry).registerDataSetDef(argument.capture()); SQLDataSetDef dataSetDef = argument.getValue(); assertEquals(DATASET_PROCESS_INSTANCES, dataSetDef.getUUID()); assertEquals("target-" + DATASET_PROCESS_INSTANCES, dataSetDef.getName()); assertEquals(KieServerDataSetProvider.TYPE, dataSetDef.getProvider()); assertEquals("SELECT *", dataSetDef.getDbSQL()); assertEquals(10, dataSetDef.getColumns().size()); }
@Test public void testHumanTasksDataSet() { QueryDefinition qd = QueryDefinition.builder().name(DATASET_HUMAN_TASKS).expression("SELECT *").source("source").target("target").build(); dataSetsBootstrap.registerDataSetDefinitions(new QueryDefinitionLoaded(qd)); ArgumentCaptor<SQLDataSetDef> argument = ArgumentCaptor.forClass(SQLDataSetDef.class); verify(dataSetRegistry).registerDataSetDef(argument.capture()); SQLDataSetDef dataSetDef = argument.getValue(); assertEquals(DATASET_HUMAN_TASKS, dataSetDef.getUUID()); assertEquals("target-" + DATASET_HUMAN_TASKS, dataSetDef.getName()); assertEquals(KieServerDataSetProvider.TYPE, dataSetDef.getProvider()); assertEquals("SELECT *", dataSetDef.getDbSQL()); assertEquals(11, dataSetDef.getColumns().size()); }