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));
   }
 }
예제 #2
0
 private String[] reverseFieldPath(List<String> path) {
   final String[] reversedPath = new String[path.size()];
   for (int i = 0; i < reversedPath.length; i++) {
     reversedPath[i] = path.get(path.size() - i - 1);
   }
   return reversedPath;
 }
 public void addConfigurationItem(ServerConfigurationItem configItem) {
   if (_configItems != null && _configItems.contains(configItem)) {
     return;
   }
   configItem.prepare(this);
   if (_configItems == null) {
     _configItems = new ArrayList<ServerConfigurationItem>();
   }
   _configItems.add(configItem);
 }
 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());
   }
 }
  public <T, T1> void querydb(
      EmbeddedConfiguration config, int[] count, Class<T> class1, Class<T1> class2) {
    EmbeddedObjectContainer database = Db4oEmbedded.openFile(config, tempFile());
    try {
      List<T> list = database.query(class1);
      Assert.areEqual(
          count[0], list.size(), "Unexpected result querying for " + class1.getSimpleName());
      if (count[0] > 0) {
        // System.out.println("Querying for " + class1.getSimpleName() + " getting " +
        // list.get(0).getClass().getSimpleName());
      }

      List<T1> list1 = database.query(class2);
      Assert.areEqual(
          count[1], list1.size(), "Unexpected result querying for " + class2.getSimpleName());
      if (count[1] > 0) {
        // System.out.println("Querying for " + class2.getSimpleName() + " getting " +
        // list1.get(0).getClass().getSimpleName());
      }

    } finally {
      database.close();
    }
  }
예제 #6
0
  protected final void addOrdering(Direction direction, List<String> path) {

    if (i_field != null) {
      path.add(i_field);
    }

    if (i_parent != null) {
      i_parent.addOrdering(direction, path);
      return;
    }

    final String[] fieldPath = reverseFieldPath(path);
    removeExistingOrderingFor(fieldPath);
    orderings().add(new SodaQueryComparator.Ordering(direction, fieldPath));
  }
 public void apply(ObjectServer server) {
   _applied.add(this);
 }
예제 #8
0
 private IntComparator newSodaQueryComparator() {
   return new SodaQueryComparator(
       (LocalObjectContainer) this.transaction().container(),
       extentType(),
       _orderings.toArray(new SodaQueryComparator.Ordering[_orderings.size()]));
 }