use of com.squareup.tape.ObjectQueue in project java by wavefrontHQ.
the class TapeDeckTest method testTape.
private void testTape(ObjectQueue<List<String>> tape) {
final AtomicInteger addCalls = new AtomicInteger(0);
final AtomicInteger removeCalls = new AtomicInteger(0);
ObjectQueue.Listener<List<String>> listener = new ObjectQueue.Listener<List<String>>() {
@Override
public void onAdd(ObjectQueue<List<String>> objectQueue, List<String> strings) {
addCalls.incrementAndGet();
}
@Override
public void onRemove(ObjectQueue<List<String>> objectQueue) {
removeCalls.incrementAndGet();
}
};
tape.setListener(listener);
assertThat(tape).isNotNull();
tape.add(ImmutableList.of("test"));
assertThat(tape.size()).isEqualTo(1);
assertThat(tape.peek()).containsExactly("test");
assertThat(addCalls.get()).isEqualTo(1);
assertThat(removeCalls.get()).isEqualTo(0);
tape.remove();
assertThat(addCalls.get()).isEqualTo(1);
assertThat(removeCalls.get()).isEqualTo(1);
}
Aggregations