protected List<CassandraEndpointConfiguration> generateConfiguration(int count) { List<CassandraEndpointConfiguration> configurations = new ArrayList<>(); for (int i = 0; i < count; i++) { CassandraEndpointConfiguration configuration = new CassandraEndpointConfiguration(); configuration.setConfiguration(ByteBuffer.wrap(generateBytes())); configuration.setConfigurationHash(ByteBuffer.wrap(generateBytes())); configurations.add(endpointConfigurationDao.save(configuration)); } return configurations; }
@Override public CassandraEndpointConfiguration save(EndpointConfigurationDto dto) { LOG.debug("Save endpoint configuration [{}] ", dto); return save(new CassandraEndpointConfiguration(dto)); }
@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 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 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 testFindById() throws Exception { List<CassandraEndpointConfiguration> configs = generateConfiguration(3); CassandraEndpointConfiguration expected = configs.get(0); CassandraEndpointConfiguration found = endpointConfigurationDao.findById(expected.getConfigurationHash()); Assert.assertEquals(expected, 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); }