// d
// / \
// b f
// / \
// a g
SimpleNode a = new SimpleNode('a', null, null);
SimpleNode b = new SimpleNode('b', a, null);
SimpleNode g = new SimpleNode('g', null, null);
SimpleNode f = new SimpleNode('f', null, g);
SimpleNode d = new SimpleNode('d', b, f);
BstNodeFactory<SimpleNode> nodeFactory = EasyMock.createStrictMock(BstNodeFactory.class);
BstBalancePolicy<SimpleNode> balancePolicy = EasyMock.createStrictMock(BstBalancePolicy.class);
BstModifier<Character, SimpleNode> modifier = EasyMock.createStrictMock(BstModifier.class);
SimpleNode c = new SimpleNode('c', null, null);
expect(modifier.modify(eq('c'), (SimpleNode) isNull())).andReturn(
BstModificationResult.rebalancingChange(null, c));
expect(balancePolicy.balance(
same(nodeFactory), same(c), (SimpleNode) isNull(), (SimpleNode) isNull()))
.andReturn(c)
.times(0, 1);
SimpleNode bWithC = new SimpleNode('b', a, c);
expectPossibleEntryfication(nodeFactory, b);
expect(balancePolicy.balance(
same(nodeFactory), withKey('b'), same(a), withKey('c')))
.andReturn(bWithC);
SimpleNode dWithBWithC = new SimpleNode('d', bWithC, f);
expectPossibleEntryfication(nodeFactory, d);
expect(
balancePolicy.balance(same(nodeFactory), withKey('d'), same(bWithC), same(f)))
.andReturn(dWithBWithC);
replay(nodeFactory, balancePolicy, modifier);