public void testAddTwice() {
   DummyConfigurationItem item = new DummyConfigurationItem(_applied);
   _config.addConfigurationItem(item);
   _config.addConfigurationItem(item);
   _config.applyConfigurationItems(new MockServer());
   Assert.areEqual(1, item.prepareCount());
   assertListsAreEqual(Arrays.asList(item), _applied);
 }
 private void withCache(final Procedure4<ClientSlotCache> procedure) {
   ClientSlotCache clientSlotCache = null;
   try {
     clientSlotCache =
         (ClientSlotCache) Reflection4.getFieldValue(container(), "_clientSlotCache");
   } catch (ReflectException e) {
     Assert.fail("Can't get field _clientSlotCache on  container. " + e.toString());
   }
   procedure.apply(clientSlotCache);
 }
 private <T> void assertListsAreEqual(List<T> a, List<T> b) {
   Assert.areEqual(a.size(), b.size());
   for (int i = 0; i < a.size(); i++) {
     Assert.areEqual(a.get(i), b.get(i));
   }
 }
 public void testPrepareApply() {
   List<DummyConfigurationItem> items =
       Arrays.asList(new DummyConfigurationItem(_applied), new DummyConfigurationItem(_applied));
   for (DummyConfigurationItem item : items) {
     _config.addConfigurationItem(item);
     Assert.areEqual(1, item.prepareCount());
   }
   Assert.areEqual(0, _applied.size());
   _config.applyConfigurationItems(new MockServer());
   assertListsAreEqual(items, _applied);
   for (DummyConfigurationItem item : items) {
     Assert.areEqual(1, item.prepareCount());
   }
 }