public void testNewCollection() {
// Environment setup: platform, collection provider, lock manager, and component registry.
Platform mockPlatform = Mockito.mock(Platform.class);
// Also need a sandbox
AbstractComponent mockSandbox = Mockito.mock(AbstractComponent.class);
Mockito.when(mockPlatform.getMySandbox()).thenReturn(mockSandbox);
MockComponentRegistry registry = new MockComponentRegistry();
// Set the platform SPI
PlatformAccess platformAccess = new PlatformAccess();
platformAccess.setPlatform(mockPlatform);
// Case #1: test returned collection when adding selectedComponents to the new collection is successful
// Setup
TestBaseComponent collection = Mockito.mock(TestBaseComponent.class);
registry.setDefaultCollection(collection);
List<AbstractComponent> selectedComponents = Collections.singletonList(Mockito.mock(AbstractComponent.class));
registry.setExpectedResultForAddComponents(true);
// The test
AbstractComponent newCollection = registry.newCollection(selectedComponents);
Assert.assertSame(newCollection, collection);
// Case #2: test returned collection when adding selectedComponents to the new collection fails
// Setup