LiveOperationRegistry { public void populate(LiveOperations liveOperations) { this.liveOperations.forEach((key, value) -> value.keySet().forEach(callId -> liveOperations.add(key, callId))); }  void register(Operation operation); void deregister(Operation operation); void populate(LiveOperations liveOperations);  }
@Test public void testPopulate() throws UnknownHostException { r.register(createOperation("1.2.3.4", 1234, 2223L)); r.register(createOperation("1.2.3.4", 1234, 2222L)); r.register(createOperation("1.2.3.3", 1234, 2222L)); CallsPerMember liveOperations = new CallsPerMember(new Address("1.2.3.3", 1234)); r.populate(liveOperations); Set<Address> addresses = liveOperations.addresses(); assertEquals(addresses.size(), 2); assertTrue(addresses.contains(new Address("1.2.3.4", 1234))); assertTrue(addresses.contains(new Address("1.2.3.3", 1234))); long[] runningOperations = liveOperations.toOpControl(new Address("1.2.3.4", 1234)).runningOperations(); assertTrue(Arrays.equals(new long[] { 2222, 2223}, runningOperations) || Arrays.equals(new long[] { 2223, 2222 }, runningOperations)); runningOperations = liveOperations.toOpControl(new Address("1.2.3.3", 1234)).runningOperations(); assertArrayEquals(new long[] { 2222 }, runningOperations); }