CommModel extends AbstractModel<CommUser> implements TickListener { public ImmutableBiMap<CommUser, CommDevice> getUsersAndDevices() { if (usersHasChanged) { synchronized (usersDevices) { usersDevicesSnapshot = ImmutableBiMap.copyOf(usersDevices); usersHasChanged = false; } } return usersDevicesSnapshot; } CommModel(RandomGenerator rng, Builder b); EventAPI getEventAPI(); @Override boolean register(CommUser commUser); @Override boolean unregister(CommUser commUser); boolean contains(CommUser commUser); double getDefaultReliability(); Optional<Double> getDefaultMaxRange(); @Override @Nonnull U get(Class<U> clazz); @Override void tick(TimeLapse timeLapse); @Override void afterTick(TimeLapse timeLapse); ImmutableBiMap<CommUser, CommDevice> getUsersAndDevices(); static Builder builder();  }
@Test public void testGetUsersAndDevices() { final List<CommUser> users = model.getUsersAndDevices().keySet().asList(); assertSame(agent1, users.get(0)); assertSame(agent2, users.get(1)); assertSame(agent3, users.get(2)); assertSame(agent4, users.get(3)); assertSame(agent5, users.get(4)); assertSame(users, model.getUsersAndDevices().keySet().asList()); final CommUser agent6 = new RangedAgent(new Point(6, 6), 4); model.register(agent6); assertSame(agent6, model.getUsersAndDevices().keySet().asList().get(5)); }
@Test public void testImmutableGetUsersAndDevices() { final List<CommUser> users = model.getUsersAndDevices().keySet().asList(); thrown.expect(UnsupportedOperationException.class); users.clear(); }