### Question:
PluginConfigurationHibernateDao extends GenericDao<PluginConfiguration> implements PluginConfigurationDao { @Override public PluginConfiguration get(String name) throws NotFoundException { Query query = session().getNamedQuery("getPluginConfiguration"); PluginConfiguration configuration = (PluginConfiguration) query.setParameter("name", name).uniqueResult(); if (configuration == null){ throw new NotFoundException(name + " plugin not found in the database"); } else { return configuration; } } PluginConfigurationHibernateDao(SessionFactory sessionFactory); @Override PluginConfiguration get(String name); @Override void saveOrUpdate(PluginConfiguration entity); @Override void updateProperties(List<PluginProperty> properties);  }### Answer:
@Test public void getShouldReturnPluginById() { session.clear(); PluginConfiguration pluginConfiguration = PersistedObjectsFactory.getDefaultPluginConfiguration(); PluginConfiguration foundPluginConfiguration = pluginConfigurationDao.get(pluginConfiguration.getId()); assertNotNull(foundPluginConfiguration); assertReflectionEquals(foundPluginConfiguration, pluginConfiguration); }
@Test public void getWithPassedIdOfNonExistingPluginShouldReturnNull() { PluginConfiguration nonExistPluginConfiguration = pluginConfigurationDao.get(-788888L); assertNull(nonExistPluginConfiguration, "PluginConfiguration doesn't exist, so get must return null"); }
@Test public void getByNameShouldReturnOnePluginConfiguration() throws NotFoundException { PluginConfiguration pluginConfiguration = PersistedObjectsFactory.getDefaultPluginConfiguration(); PluginConfiguration actual = pluginConfigurationDao.get(pluginConfiguration.getName()); assertEquals(actual, pluginConfiguration); }
@Test(expectedExceptions = NotFoundException.class) public void getShouldThrowIfDidNotFindPlugin() throws NotFoundException { pluginConfigurationDao.get("Some fake name"); }