KieServerDataSetProvider extends AbstractKieServerService implements DataSetProvider { @Override public DataSetMetadata getDataSetMetadata(DataSetDef def) throws Exception { List<String> columnNames = new ArrayList<>(); List<ColumnType> columnTypes = new ArrayList<>(); if (def.getColumns() == null && def instanceof RemoteDataSetDef) { final QueryServicesClient queryClient = getClient(((RemoteDataSetDef) def).getServerTemplateId(), QueryServicesClient.class); QueryDefinition definition = queryClient.getQuery(def.getUUID()); if (definition.getColumns() != null) { for (Entry<String, String> entry : definition.getColumns().entrySet()) { if (def.getColumnById(entry.getKey()) == null) { def.addColumn(entry.getKey(), ColumnType.valueOf(entry.getValue())); } } } } List<DataColumnDef> columns = def.getColumns(); for (DataColumnDef column : columns) { columnNames.add(column.getId()); columnTypes.add(column.getColumnType()); } return new DataSetMetadataImpl(def, def.getUUID(), -1, def.getColumns().size(), columnNames, columnTypes, -1); }  @Override DataSetProviderType getType(); @Override DataSetMetadata getDataSetMetadata(DataSetDef def); @Override DataSet lookupDataSet(DataSetDef def,
                                 DataSetLookup lookup); @Override boolean isDataSetOutdated(DataSetDef def); static final DataSetProviderType TYPE; }
@Test public void testDataSetMetaData() throws Exception { Map<String, String> columns = new HashMap<>(); columns.put("test", "NUMBER"); QueryDefinition definition = QueryDefinition.builder() .name("q1") .columns(columns) .build(); when(dataSetDef.getColumns()).thenReturn(null, new ArrayList<>()); when(dataSetDef.getServerTemplateId()).thenReturn("servereTemplateId"); when(queryServicesClient.getQuery(anyString())).thenReturn(definition); kieServerDataSetProvider.getDataSetMetadata(dataSetDef); verify(dataSetDef, times(1)).addColumn(eq("test"), eq(ColumnType.NUMBER)); verify(queryServicesClient).getQuery(anyString()); }