ConfigurationManagerImpl implements ConfigurationManager { @Override public ConfigurationNode getNode(final RootNode rootNode, final String nodeId) throws UnknownNodeException { return configurationDao.getNode(rootNode, nodeId); } @Inject  ConfigurationManagerImpl(ConfigurationDao configurationDao); @Override List<ConfigurationNode> getNodes(final RootNode rootNode); @Override ConfigurationNode getNode(final RootNode rootNode, final String nodeId); @Override Optional<ConfigurationNode> findNode(final RootNode rootNode, final String excludedNodeId, final String label, final String path); @Override boolean addNode(final RootNode rootNode, final ConfigurationNode node); @Override Optional<ConfigurationNode> editNode(final RootNode rootNode, final String nodeId, final String label, final String path); @Override void save(); @Override ConfigurationNode removeNode(final String nodeId, final RootNode rootNode); @Override T getParameter(final ConfigurationParameter<T> parameter); @Override void setParameter(final ConfigurationParameter<T> parameter, final T value);  }
@Test public void testGetNode() throws UnknownNodeException { ConfigurationDao configurationDao = createMock(ConfigurationDao.class); ConfigurationNode configurationNode = new ConfigurationNode("nodeId", "label", "path"); expect(configurationDao.getNode(eq(ROOT), eq("nodeId"))).andReturn(configurationNode); replay(configurationDao); ConfigurationManager configurationManager = new ConfigurationManagerImpl(configurationDao); ConfigurationNode result = configurationManager.getNode(ROOT, "nodeId"); verify(configurationDao); assertEquals(result, configurationNode); }
@Test(expected = UnknownNodeException.class) public void testGetUnknownNode() throws UnknownNodeException { ConfigurationDao configurationDao = createMock(ConfigurationDao.class); expect(configurationDao.getNode(eq(ROOT), eq("nodeId"))).andThrow(new UnknownNodeException("nodeId")); replay(configurationDao); try { ConfigurationManager configurationManager = new ConfigurationManagerImpl(configurationDao); configurationManager.getNode(ROOT, "nodeId"); } finally { verify(configurationDao); } }