XmlConfigurationDaoImpl implements ConfigurationDao { @Override public ConfigurationNode getNode(final RootNode rootNode, final String nodeId) throws UnknownNodeException { return this.rootNode.getConfigurationNodes(rootNode).stream() .filter(node -> node.getId().equals(nodeId)) .findFirst() .orElseThrow(() -> new UnknownNodeException(nodeId)); } @Inject  XmlConfigurationDaoImpl(@Named("localHolmesDataDir") final String localHolmesDataDir); @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 void save(); @Override T getParameter(final ConfigurationParameter<T> parameter); @Override void setParameter(final ConfigurationParameter<T> parameter, final T value);  }
@Test public void testGetConfigurationNode() throws IOException, UnknownNodeException { String configDir = new File(this.getClass().getResource("/configuration").getPath()).getAbsolutePath(); XmlConfigurationDaoImpl configuration = new XmlConfigurationDaoImpl(configDir); ConfigurationNode node = configuration.getNode(VIDEO, "video1"); assertNotNull(node); }
@Test(expected = UnknownNodeException.class) public void testGetBadConfigurationNode() throws IOException, UnknownNodeException { String configDir = new File(this.getClass().getResource("/configuration").getPath()).getAbsolutePath(); XmlConfigurationDaoImpl configuration = new XmlConfigurationDaoImpl(configDir); ConfigurationNode node = configuration.getNode(VIDEO, "badVideo"); assertNotNull(node); }