Skip to content

Commit

Permalink
fix: Add missing refreshAll method to data view
Browse files Browse the repository at this point in the history
Adds the missed refresh all method to data view API.

Fixes: #9574
  • Loading branch information
mshabarov authored Dec 7, 2020
1 parent dedb8dd commit c60b51b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit c60b51b

Please sign in to comment.