### Question:
Upstream { public void request(long n) { Subscription currentSubscription = subscription; if (currentSubscription != null) { currentSubscription.request(n); } } Upstream(); boolean setOrCancel(Subscription incoming); void request(long n); void cancel(); void clear();  }### Answer:
@Test void request() { var s = new TestSubscription(); var ups = new Upstream(); ups.request(1); ups.setOrCancel(s); ups.request(5); ups.cancel(); ups.request(1); assertEquals(1, s.cancels); assertEquals(1, s.demands.size()); assertEquals(5, s.demands.poll()); }