@Override public List<EndpointNotificationDto> findUnicastNotificationsByKeyHash(final byte[] keyHash) { validateHash(keyHash, "Can't find unicast notification. Invalid key hash " + keyHash); return convertDtoList(unicastNotificationDao.findNotificationsByKeyHash(keyHash)); }
@Test public void testSave() throws Exception { CassandraEndpointNotification notification = generateEndpointNotification(null, 1).get(0); List<CassandraEndpointNotification> found = unicastNotificationDao.findNotificationsByKeyHash(notification.getEndpointKeyHash().array()); Assert.assertEquals(1, found.size()); }
@Test public void testFindNotificationsByKeyHash() throws Exception { List<CassandraEndpointNotification> notifications = generateEndpointNotification(null, 1); generateEndpointNotification(null, 2); CassandraEndpointNotification notification = notifications.get(0); List<CassandraEndpointNotification> found = unicastNotificationDao.findNotificationsByKeyHash(notification.getEndpointKeyHash().array()); Assert.assertEquals(notifications.size(), found.size()); }
@Test public void testRemoveNotificationsByKeyHash() throws Exception { ByteBuffer epKeyHash = ByteBuffer.wrap(generateBytes()); generateEndpointNotification(epKeyHash, 3); unicastNotificationDao.removeNotificationsByKeyHash(epKeyHash.array()); List<CassandraEndpointNotification> found = unicastNotificationDao.findNotificationsByKeyHash(epKeyHash.array()); Assert.assertTrue(found.isEmpty()); }
@Test public void testRemoveNotificationsByAppId() throws Exception { CassandraEndpointNotification notification = generateEndpointNotification(null, 3).get(0); String appId = notification.getApplicationId(); unicastNotificationDao.removeNotificationsByAppId(appId); List<CassandraEndpointNotification> found = unicastNotificationDao.findNotificationsByKeyHash(notification.getEndpointKeyHash().array()); Assert.assertTrue(found.isEmpty()); }