BackendManagerImpl implements BackendManager { @Override public ConfigurationFolder getFolder(final String id, final RootNode rootNode) { try { return new ConfigurationNodeFactory().apply(configurationManager.getNode(rootNode, id)); } 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 testGetFolder() throws UnknownNodeException { ConfigurationManager configurationManager = createMock(ConfigurationManager.class); EventBus eventBus = createMock(EventBus.class); expect(configurationManager.getNode(eq(AUDIO), eq("id"))).andReturn(new ConfigurationNode("id", "name", "path")); replay(configurationManager, eventBus); BackendManagerImpl backendManager = new BackendManagerImpl(configurationManager, eventBus); assertNotNull(backendManager.getFolder("id", AUDIO)); verify(configurationManager, eventBus); }
@Test public void testGetNullFolder() throws UnknownNodeException { ConfigurationManager configurationManager = createMock(ConfigurationManager.class); EventBus eventBus = createMock(EventBus.class); expect(configurationManager.getNode(eq(AUDIO), eq("id"))).andReturn(null); replay(configurationManager, eventBus); BackendManagerImpl backendManager = new BackendManagerImpl(configurationManager, eventBus); assertNull(backendManager.getFolder("id", AUDIO)); verify(configurationManager, eventBus); }
@Test(expected = BackendException.class) public void testGetBadFolder() throws UnknownNodeException { ConfigurationManager configurationManager = createMock(ConfigurationManager.class); EventBus eventBus = createMock(EventBus.class); expect(configurationManager.getNode(eq(AUDIO), eq("bad_id"))).andThrow(new UnknownNodeException("bad_id")); replay(configurationManager, eventBus); try { BackendManagerImpl backendManager = new BackendManagerImpl(configurationManager, eventBus); backendManager.getFolder("bad_id", AUDIO); } finally { verify(configurationManager, eventBus); } }