BTree extends ExpandableBTree<I, K> { @Override public void delete(I value) { delete(value.getKey()); } BTree(Storage<I> dataStore, Storage<NodeDefinition<K>> nodeStore, int degree); @Override void delete(I value);  }
@Test(dataProvider = "stressDataProvider") public void stressTest(int degree, int benchmark, List<String> input) throws Exception { for (int size = degree; size < benchmark; size++) { final MapStorage<ReflectiveIndexed<String>> dataStore = new MapStorage<>(); final MapStorage<NodeDefinition<String>> nodeStore = new MapStorage<>(); final BTree<ReflectiveIndexed<String>, String> tree = new BTree<>(dataStore, nodeStore, degree); for (int insertion = 0; insertion < size; insertion ++) { tree.insert(new ReflectiveIndexed<>(input.get(insertion))); } BTreeTestTools.checkNodes(tree.getRoot(), degree); final List<String> inserted = new ArrayList<>(input).subList(0, size); Collections.sort(inserted); final List<String> initialState = new ArrayList<>(); BTreeTestTools.collectLeaves(dataStore, tree.getRoot(), initialState); assertThat(initialState, is(inserted)); for (int deletion = 0; deletion < size; deletion++) { final String item = input.get(deletion); tree.delete(new ReflectiveIndexed<>(item)); inserted.remove(item); if (!inserted.isEmpty()) { BTreeTestTools.checkNodes(tree.getRoot(), degree); } assertThat(tree.find(item), is(nullValue())); for (String remaining : inserted) { final ReflectiveIndexed<String> found = tree.find(remaining); assertThat(found, is(notNullValue())); assertThat(found.getKey(), is(notNullValue())); assertThat(found.getKey(), is(remaining)); } final List<String> leaves = new ArrayList<>(); BTreeTestTools.collectLeaves(dataStore, tree.getRoot(), leaves); assertThat(leaves, is(inserted)); } } }