// =====================================================================
// Set Expectations
// =====================================================================
GroupImpl group = new GroupImpl(cacheMock, null, 10, "", clock);
builderMock.expects.buildGroup(cacheMock, group, "group1", clock)
.returns(group1Mock);
builderMock.expects.buildGroup(cacheMock, group, "group2", clock)
.returns(group2Mock);
// =====================================================================
// Test Expectations
// =====================================================================
Group group1 = group.addGroup("group1", builderMock);
assertSame(group1, group1Mock);
Group group2 = group.addGroup("group2", builderMock);
assertSame(group2, group2Mock);
try {
group1 = group.addGroup("group1", builderMock);
fail("Did not detect attempt to add same group multiple times");
} catch (IllegalStateException expected) {
assertEquals("Group 'group1' already exists",
expected.getMessage());
}