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()); } }
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(); } }