@Override public CassandraNotification save(NotificationDto notification) { return save(new CassandraNotification(notification)); }
@Test public void testToDto() { NotificationDto expected = generateNotifications(null, null, null, 1, NotificationTypeDto.USER).get(0); Assert.assertEquals(expected, new CassandraNotification(expected).toDto()); } }
@Override public CassandraNotification findById(String id) { LOG.debug("Try to find notification by id {}", id); CassandraNotification nf = new CassandraNotification(id); Where query = select().from(getColumnFamilyName()) .where(eq(NF_TOPIC_ID_PROPERTY, nf.getTopicId())) .and(eq(NF_NOTIFICATION_TYPE_PROPERTY, nf.getType().name())) .and(eq(NF_VERSION_PROPERTY, nf.getNfVersion())) .and(eq(NF_SEQ_NUM_PROPERTY, nf.getSeqNum())); LOG.trace("Execute query {}", query); nf = findOneByStatement(query); LOG.trace("Found notification {} by id {}", nf, id); return nf; }
@Override public void removeById(String id) { LOG.debug("Remove notification by id {}", id); CassandraNotification nf = new CassandraNotification(id); Delete.Where deleteQuery = delete().from(getColumnFamilyName()) .where(eq(NF_TOPIC_ID_PROPERTY, nf.getTopicId())) .and(eq(NF_NOTIFICATION_TYPE_PROPERTY, nf.getType().name())) .and(eq(NF_VERSION_PROPERTY, nf.getNfVersion())) .and(eq(NF_SEQ_NUM_PROPERTY, nf.getSeqNum())); LOG.trace("Remove notification by id {}", deleteQuery); execute(deleteQuery); }