@Test void testDeleteAll() { String pluginId = "myPluginId"; Plugin plugin = when(mock(Plugin.class).getId()).thenReturn(pluginId).getMock(); doAnswer( invocation -> { Consumer<List<Plugin>> consumer = invocation.getArgument(1); consumer.accept(singletonList(plugin)); return null; }) .when(delegateRepository) .forEachBatched(any(), any(), eq(1000)); String menu = "{\"type\":\"menu\",\"id\":\"main\",\"items\":[{\"type\":\"plugin\",\"id\":\"myPluginId\"}]}"; when(appSettings.getMenu()).thenReturn(menu); pluginRepositoryDecorator.deleteAll(); @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Plugin>> pluginCaptor = ArgumentCaptor.forClass(Stream.class); verify(delegateRepository).delete(pluginCaptor.capture()); assertEquals(singletonList(plugin), pluginCaptor.getValue().collect(toList())); verify(appSettings).setMenu("{\"type\":\"menu\",\"id\":\"main\",\"items\":[]}"); }
@Override public void deleteAll() { forEachBatched(this::deleteBatch, BATCH_SIZE); }
PluginRepositoryDecorator extends AbstractRepositoryDecorator<Plugin> { @Override public void deleteAll() { forEachBatched(this::deleteBatch, BATCH_SIZE); } }
PluginRepositoryDecorator extends AbstractRepositoryDecorator<Plugin> { @Override public void deleteAll() { forEachBatched(this::deleteBatch, BATCH_SIZE); } PluginRepositoryDecorator(Repository<Plugin> delegateRepository, AppSettings appSettings); }
PluginRepositoryDecorator extends AbstractRepositoryDecorator<Plugin> { @Override public void deleteAll() { forEachBatched(this::deleteBatch, BATCH_SIZE); } PluginRepositoryDecorator(Repository<Plugin> delegateRepository, AppSettings appSettings); @Override void delete(Plugin plugin); @Override void deleteById(Object id); @Override void deleteAll(); @Override void delete(Stream<Plugin> pluginStream); @Override void deleteAll(Stream<Object> ids); }
PluginRepositoryDecorator extends AbstractRepositoryDecorator<Plugin> { @Override public void deleteAll() { forEachBatched(this::deleteBatch, BATCH_SIZE); } PluginRepositoryDecorator(Repository<Plugin> delegateRepository, AppSettings appSettings); @Override void delete(Plugin plugin); @Override void deleteById(Object id); @Override void deleteAll(); @Override void delete(Stream<Plugin> pluginStream); @Override void deleteAll(Stream<Object> ids);  }