RuntimeKieServerDataSetProvider implements DataSetProvider { protected ConsoleDataSetLookup adoptLookup(DataSetDef def, DataSetLookup lookup) { ConsoleDataSetLookup dataSetLookup = null; if (!(lookup instanceof ConsoleDataSetLookup)) { if (def instanceof RemoteDataSetDef) { dataSetLookup = (ConsoleDataSetLookup) ConsoleDataSetLookup.fromInstance(lookup, ((RemoteDataSetDef) def).getServerTemplateId()); DataSetFilter filter = def.getDataSetFilter(); if (filter != null) { dataSetLookup.addOperation(filter); } } else { throw new IllegalArgumentException("DataSetLookup is of incorrect type " + lookup.getClass().getName()); } } else { dataSetLookup = (ConsoleDataSetLookup) lookup; } return dataSetLookup; }  @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 testNoAdoptLookup() throws Exception { ConsoleDataSetLookup dataSetLookup = Mockito.mock(ConsoleDataSetLookup.class); kieServerDataSetProvider.adoptLookup(dataSetDef, dataSetLookup); verify(dataSetDef, times(0)).getServerTemplateId(); }
@Test public void testAdoptLookup() throws Exception { DataSetLookup dataSetLookup = Mockito.mock(DataSetLookup.class); when(dataSetDef.getDataSetFilter()).thenReturn(Mockito.mock(DataSetFilter.class)); when(dataSetDef.getServerTemplateId()).thenReturn("servereTemplateId"); when(dataSetLookup.cloneInstance()).thenReturn(dataSetLookup); ConsoleDataSetLookup adopted = kieServerDataSetProvider.adoptLookup(dataSetDef, dataSetLookup); verify(dataSetDef, times(1)).getServerTemplateId(); assertNotNull(adopted.getOperationList()); assertEquals(1, adopted.getOperationList().size()); }