You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InMemoryDataSourceTest.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.vaadin.tokka.data.datasource;
  2. import static org.junit.Assert.assertTrue;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.stream.Stream;
  6. import org.junit.Before;
  7. import org.junit.Test;
  8. import com.vaadin.tokka.server.communication.data.DataSource;
  9. import com.vaadin.tokka.server.communication.data.InMemoryDataSource;
  10. public class InMemoryDataSourceTest {
  11. private static class StrBean {
  12. private String value;
  13. public StrBean(String value) {
  14. this.value = value;
  15. }
  16. public String getValue() {
  17. return value;
  18. }
  19. public void setValue(String value) {
  20. this.value = value;
  21. }
  22. }
  23. private InMemoryDataSource<StrBean> dataSource;
  24. private List<StrBean> data;
  25. @Before
  26. public void setUp() {
  27. data = createData();
  28. dataSource = DataSource.create(data);
  29. }
  30. @Test
  31. public void testListContainsAllData() {
  32. dataSource.apply(null).forEach(str -> assertTrue(data.contains(str)));
  33. }
  34. private List<StrBean> createData() {
  35. List<StrBean> list = new ArrayList<>();
  36. Stream.of("Foo", "Bar", "Baz").map(StrBean::new).forEach(list::add);
  37. return list;
  38. }
  39. }