MediaIndexDaoImpl implements MediaIndexDao { @Subscribe public void handleConfigEvent(final ConfigurationEvent configurationEvent) { ConfigurationNode configNode = configurationEvent.getNode(); RootNode rootNode = configurationEvent.getRootNode(); switch (configurationEvent.getType()) { case ADD_FOLDER: put(configNode.getId(), buildConfigMediaIndexElement(rootNode, configNode)); break; case UPDATE_FOLDER: remove(configNode.getId(), configNode); put(configNode.getId(), buildConfigMediaIndexElement(rootNode, configNode)); break; case DELETE_FOLDER: remove(configNode.getId(), configNode); break; default: break; } } MediaIndexDaoImpl(); @Override MediaIndexElement get(final String uuid); @Override String add(final MediaIndexElement element); @Override void put(final String uuid, final MediaIndexElement element); @Override synchronized void removeChildren(final String uuid); @Override synchronized void clean(); @Subscribe void handleConfigEvent(final ConfigurationEvent configurationEvent);  }
@Test public void testHandleConfigEventAdd() { MediaIndexDaoImpl mediaIndexDao = new MediaIndexDaoImpl(); ConfigurationEvent configurationEvent = new ConfigurationEvent(ADD_FOLDER, new ConfigurationNode("id", "label", "path"), RootNode.VIDEO); mediaIndexDao.handleConfigEvent(configurationEvent); }
@Test public void testHandleConfigEventUpdate() { MediaIndexDaoImpl mediaIndexDao = new MediaIndexDaoImpl(); ConfigurationEvent configurationEvent = new ConfigurationEvent(UPDATE_FOLDER, new ConfigurationNode("id", "label", "path"), RootNode.VIDEO); mediaIndexDao.handleConfigEvent(configurationEvent); }
@Test public void testHandleConfigEventDelete() { MediaIndexDaoImpl mediaIndexDao = new MediaIndexDaoImpl(); ConfigurationEvent configurationEvent = new ConfigurationEvent(DELETE_FOLDER, new ConfigurationNode("id", "label", "path"), RootNode.VIDEO); mediaIndexDao.handleConfigEvent(configurationEvent); }
@Test public void testHandleConfigEventUnknown() { MediaIndexDaoImpl mediaIndexDao = new MediaIndexDaoImpl(); ConfigurationEvent configurationEvent = new ConfigurationEvent(ConfigurationEvent.EventType.UNKNOWN, new ConfigurationNode("id", "label", "path"), RootNode.VIDEO); mediaIndexDao.handleConfigEvent(configurationEvent); }