RuntimeKieServerDataSetProvider 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) { KieServerConnectionInfo connectionInfo = connectionInfoProvider.verifiedConnectionInfo((RemoteDataSetDef) def); QueryDefinition definition = queryClient.getQuery(connectionInfo, def.getUUID()); if (definition.getColumns() != null) { addColumnsToDefinition(def, definition); } } def.getColumns().forEach(column -> { 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 { when(kieServerConnectionInfoProvider.verifiedConnectionInfo(dataSetDef)).thenReturn(connectionInfo); when(dataSetDef.getColumns()).thenReturn(null, new ArrayList<>()); when(dataSetDef.getServerTemplateId()).thenReturn(SERVER_TEMPLATE); when(queryClient.getQuery(eq(connectionInfo), anyString())).thenReturn(definition); kieServerDataSetProvider.getDataSetMetadata(dataSetDef); verify(dataSetDef, times(1)).addColumn(eq("test"), eq(ColumnType.NUMBER)); verify(queryClient).getQuery(eq(connectionInfo), anyString()); }