Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing refreshAll method to data view #9580

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -131,6 +131,11 @@ public void refreshItem(T item) {
//@formatter:on
}

@Override
public void refreshAll() {
dataProviderSupplier.get().refreshAll();
}

@Override
public void setIdentifierProvider(
IdentifierProvider<T> identifierProvider) {
Expand Down
Expand Up @@ -73,6 +73,11 @@ public interface DataView<T> extends Serializable {
*/
void refreshItem(T item);

/**
* Notifies the component that all the items should be refreshed.
*/
void refreshAll();

/**
* Add an item count change listener that is fired when the item count
* changes. This can happen for instance when filtering the items.
Expand Down
Expand Up @@ -20,6 +20,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream;

import com.vaadin.flow.component.Component;
Expand Down Expand Up @@ -88,6 +89,19 @@ public void addItemCountChangeListener_fireEvent_listenerNotified() {
Assert.assertEquals(10, fired.get());
}

@Test
public void refreshAll_listenersNotified() {
AtomicReference<DataChangeEvent<Item>> refreshAllEvent =
new AtomicReference<>();
dataProvider.addDataProviderListener(event -> {
Assert.assertNull(refreshAllEvent.get());
refreshAllEvent.set(event);
});
dataView.refreshAll();
Assert.assertNotNull(refreshAllEvent.get());
Assert.assertEquals(dataProvider, refreshAllEvent.get().getSource());
}

/**
* setIdentifierProvider is tested in AbstractListDataView since it
* has the container(T item) method.
Expand Down
Expand Up @@ -120,6 +120,11 @@ public TestListDataView addItemBefore(String item, String before) {
public void refreshItem(String item) {
}

@Override
public void refreshAll() {

}

@Override
public TestListDataView addItems(Collection<String> items) {
return null;
Expand Down