public static Collection<TestEvent<String>> writeRemove(String... values) { List<TestEvent<String>> all = new ArrayList<>(); for (String s : values) all.addAll(TestEvent.create(WRITE, s)); for (String s : values) all.addAll(TestEvent.create(REMOVE, null, s)); for (String s : values) all.addAll(TestEvent.create(WRITE, null)); return all; }
public static Collection<TestEvent<String>> createRemove(String value) { List<TestEvent<String>> all = new ArrayList<>(); all.addAll(TestEvent.create(CREATE, value)); all.addAll(TestEvent.create(WRITE, value)); all.addAll(TestEvent.create(REMOVE, null, value)); all.addAll(TestEvent.create(WRITE, null)); return all; }
public static Collection<TestEvent<String>> createModify( String createdValue, String modifiedValue) { List<TestEvent<String>> all = new ArrayList<>(); all.addAll(TestEvent.create(CREATE, createdValue)); all.addAll(TestEvent.create(WRITE, createdValue)); all.addAll(TestEvent.create(MODIFY, modifiedValue, createdValue)); all.addAll(TestEvent.create(WRITE, modifiedValue)); return all; }
public static Collection<TestEvent<String>> createModifyRemove( List<String> created, List<String> modified) { List<TestEvent<String>> all = new ArrayList<>(); created.forEach(s -> all.addAll(TestEvent.create(CREATE, s))); created.forEach(s -> all.addAll(TestEvent.create(WRITE, s))); modified.forEach(s -> all.addAll(TestEvent.create(WRITE, s))); modified.forEach(s -> all.addAll(TestEvent.create(REMOVE, null, s))); modified.forEach(s -> all.addAll(TestEvent.create(WRITE, null))); return all; }
public static Collection<TestEvent<String>> writeModify( List<String> written, List<String> modified) { List<TestEvent<String>> all = new ArrayList<>(); for (String value : written) all.addAll(TestEvent.create(WRITE, value)); IntStream.range(0, modified.size()) .forEach( i -> { all.addAll(TestEvent.create(MODIFY, modified.get(i), written.get(i))); all.addAll(TestEvent.create(WRITE, modified.get(i))); }); return all; }
public static Collection<TestEvent<String>> createAllRemoveAll(String... values) { List<TestEvent<String>> all = new ArrayList<>(); for (String s : values) { all.addAll(TestEvent.create(CREATE, s)); all.addAll(TestEvent.create(WRITE, s)); } for (String s : values) { all.addAll(TestEvent.create(REMOVE, null, s)); all.addAll(TestEvent.create(WRITE, null)); } return all; }
private FunctionalListenerAssertions(FunctionalListeners<K, V> listeners, Runnable runnable) { this.listeners = listeners; this.runnable = runnable; Listeners.ReadWriteListeners<K, V> rw = this.listeners.readWriteListeners(); closeables.add( rw.onCreate(c -> recorded.add(TestEvent.create(InternalTestType.LAMBDA_CREATE, c.get())))); closeables.add( rw.onModify( (b, a) -> recorded.add(TestEvent.create(InternalTestType.LAMBDA_MODIFY, a.get(), b.get())))); closeables.add( rw.onRemove( r -> recorded.add(TestEvent.create(InternalTestType.LAMBDA_REMOVE, null, r.get())))); closeables.add( rw.add( new Listeners.ReadWriteListeners.ReadWriteListener<K, V>() { @Override public void onCreate(ReadEntryView<K, V> created) { recorded.add(TestEvent.create(InternalTestType.LISTENER_CREATE, created.get())); } @Override public void onModify(ReadEntryView<K, V> before, ReadEntryView<K, V> after) { recorded.add( TestEvent.create(InternalTestType.LISTENER_MODIFY, after.get(), before.get())); } @Override public void onRemove(ReadEntryView<K, V> removed) { recorded.add( TestEvent.create(InternalTestType.LISTENER_REMOVE, null, removed.get())); } })); Listeners.WriteListeners<K, V> wo = this.listeners.writeOnlyListeners(); closeables.add( wo.onWrite( w -> recorded.add( TestEvent.create(InternalTestType.LAMBDA_WRITE, w.find().orElse(null))))); closeables.add( wo.add( w -> recorded.add( TestEvent.create(InternalTestType.LISTENER_WRITE, w.find().orElse(null))))); }
public static Collection<TestEvent<String>> createModifyRemove(String created, String modified) { List<TestEvent<String>> all = new ArrayList<>(); all.addAll(TestEvent.create(CREATE, created)); all.addAll(TestEvent.create(WRITE, created)); all.addAll(TestEvent.create(MODIFY, modified, created)); all.addAll(TestEvent.create(WRITE, modified)); all.addAll(TestEvent.create(REMOVE, null, modified)); all.addAll(TestEvent.create(WRITE, null)); return all; }
public static <V> Collection<TestEvent<V>> create(TestType type, V value, V prev) { return Arrays.asList( TestEvent.create(type.lambdaType(), value, prev), TestEvent.create(type.listenerType(), value, prev)); }
public static Collection<TestEvent<String>> write(String... values) { List<TestEvent<String>> all = new ArrayList<>(); for (String value : values) all.addAll(TestEvent.create(WRITE, value)); return all; }