BackendManagerImpl implements BackendManager { @Override public void removeFolder(final String id, final RootNode rootNode) { try { ConfigurationNode node = configurationManager.removeNode(id, rootNode); eventBus.post(new ConfigurationEvent(DELETE_FOLDER, node, rootNode)); } catch (IOException e) { throw new BackendException(e); } catch (UnknownNodeException e) { throw new BackendException(FOLDER_UNKNOWN_ERROR, e); } } @Inject  BackendManagerImpl(final ConfigurationManager configurationManager, final EventBus eventBus); @Override Collection<ConfigurationFolder> getFolders(final RootNode rootNode); @Override ConfigurationFolder getFolder(final String id, final RootNode rootNode); @Override void addFolder(final ConfigurationFolder folder, final RootNode rootNode); @Override void editFolder(final String id, final ConfigurationFolder folder, final RootNode rootNode); @Override void removeFolder(final String id, final RootNode rootNode); @Override Settings getSettings(); @Override void saveSettings(final Settings settings);  }
@Test public void testRemoveFolder() throws IOException, UnknownNodeException { ConfigurationManager configurationManager = createMock(ConfigurationManager.class); EventBus eventBus = createMock(EventBus.class); ConfigurationNode node = new ConfigurationNode("id", "name", System.getProperty("java.io.tmpdir")); expect(configurationManager.removeNode("id", AUDIO)).andReturn(node); expectLastCall(); eventBus.post(isA(ConfigurationEvent.class)); expectLastCall(); replay(configurationManager, eventBus); try { BackendManagerImpl backendManager = new BackendManagerImpl(configurationManager, eventBus); backendManager.removeFolder("id", AUDIO); } finally { verify(configurationManager, eventBus); } }
@Test(expected = BackendException.class) public void testRemoveFolderIOException() throws IOException, UnknownNodeException { ConfigurationManager configurationManager = createMock(ConfigurationManager.class); EventBus eventBus = createMock(EventBus.class); expect(configurationManager.removeNode(eq("id"), eq(AUDIO))).andThrow(new IOException()); replay(configurationManager, eventBus); try { BackendManagerImpl backendManager = new BackendManagerImpl(configurationManager, eventBus); backendManager.removeFolder("id", AUDIO); } finally { verify(configurationManager, eventBus); } }
@Test(expected = BackendException.class) public void testRemoveBadFolder() throws UnknownNodeException, IOException { ConfigurationManager configurationManager = createMock(ConfigurationManager.class); EventBus eventBus = createMock(EventBus.class); expect(configurationManager.removeNode("bad_folder", AUDIO)).andThrow(new UnknownNodeException("bad_folder")); replay(configurationManager, eventBus); try { BackendManagerImpl backendManager = new BackendManagerImpl(configurationManager, eventBus); backendManager.removeFolder("bad_folder", AUDIO); } finally { verify(configurationManager, eventBus); } }