@Override public EndpointConfigurationDto findEndpointConfigurationByHash(byte[] hash) { validateHash(hash, "Can't find endpoint configuration by hash. Invalid configuration hash " + hash); return getDto(endpointConfigurationDao.findByHash(hash)); }
@Test public void testFindByHash() throws Exception { List<CassandraEndpointConfiguration> configs = generateConfiguration(3); CassandraEndpointConfiguration expected = configs.get(0); CassandraEndpointConfiguration found = endpointConfigurationDao.findByHash(expected.getConfigurationHash().array()); Assert.assertEquals(expected, found); }
@Test public void testRemoveByHash() throws Exception { List<CassandraEndpointConfiguration> configs = generateConfiguration(3); CassandraEndpointConfiguration expected = configs.get(0); endpointConfigurationDao.removeByHash(expected.getConfigurationHash().array()); CassandraEndpointConfiguration found = endpointConfigurationDao.findByHash(expected.getConfigurationHash().array()); Assert.assertNull(found); }
@Test public void testRemoveByIdNullKey() throws Exception { List<CassandraEndpointConfiguration> configs = generateConfiguration(3); CassandraEndpointConfiguration expected = configs.get(0); endpointConfigurationDao.removeById(null); CassandraEndpointConfiguration found = endpointConfigurationDao.findByHash(expected.getConfigurationHash().array()); Assert.assertEquals(expected, found); }
@Test public void testRemoveById() throws Exception { List<CassandraEndpointConfiguration> configs = generateConfiguration(3); CassandraEndpointConfiguration expected = configs.get(0); endpointConfigurationDao.removeById(expected.getConfigurationHash()); CassandraEndpointConfiguration found = endpointConfigurationDao.findByHash(expected.getConfigurationHash().array()); Assert.assertNull(found); } }
@Test public void removeEndpointConfigurationByHashTest() { EndpointConfigurationDto endpointConfiguration = generateEndpointConfiguration(); Assert.assertNotNull(endpointConfiguration); byte[] bytes = endpointConfiguration.getConfigurationHash(); endpointConfigurationDao.removeByHash(bytes); MongoEndpointConfiguration configurationDto = endpointConfigurationDao.findByHash(bytes); Assert.assertNull(configurationDto); }