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")));
}
Aggregations