Search in sources :

Example 1 with CompositeDataGenerator

use of com.vaadin.flow.data.provider.CompositeDataGenerator in project flow by vaadin.

the class CompositeDataGeneratorTest method removeDataGenerator_dataIsDestroyed.

@Test
public void removeDataGenerator_dataIsDestroyed() {
    CompositeDataGenerator<String> composite = new CompositeDataGenerator<>();
    MockDataGenerator mock1 = new MockDataGenerator("mock", "value1");
    MockDataGenerator mock2 = new MockDataGenerator("mock", "value1");
    Registration registration = composite.addDataGenerator(mock1);
    composite.addDataGenerator(mock2);
    composite.generateData("item1", Json.createObject());
    Assert.assertThat(mock1.getProcessed(), CoreMatchers.hasItem("item1"));
    Assert.assertThat(mock2.getProcessed(), CoreMatchers.hasItem("item1"));
    registration.remove();
    Assert.assertThat(mock1.getProcessed(), CoreMatchers.not(CoreMatchers.hasItem("item1")));
    Assert.assertThat(mock2.getProcessed(), CoreMatchers.hasItem("item1"));
    composite.removeDataGenerator(mock2);
    Assert.assertThat(mock2.getProcessed(), CoreMatchers.not(CoreMatchers.hasItem("item1")));
}
Also used : CompositeDataGenerator(com.vaadin.flow.data.provider.CompositeDataGenerator) Registration(com.vaadin.flow.shared.Registration) Test(org.junit.Test)

Aggregations

CompositeDataGenerator (com.vaadin.flow.data.provider.CompositeDataGenerator)1 Registration (com.vaadin.flow.shared.Registration)1 Test (org.junit.Test)1