@Test public void testRemoveById() { NotificationDto notification = generateNotificationsDto(null, null, 1, null).get(0); Assert.assertNotNull(notification.getId()); notificationDao.removeById(notification.getId()); Notification found = notificationDao.findById(notification.getId()); Assert.assertNull(found); }
@Test public void testFindNotificationById() { NotificationDto notification = generateNotificationsDto(null, null, 1, null).get(0); Assert.assertNotNull(notification); Assert.assertTrue(isNotBlank(notification.getId())); NotificationDto found = notificationService.findNotificationById(notification.getId()); Assert.assertEquals(notification, found); }
@Test public void testSaveNotification() { NotificationDto notification = generateNotificationsDto(null, null, 1, null).get(0); Assert.assertNotNull(notification); Assert.assertTrue(isNotBlank(notification.getId())); Assert.assertEquals(NotificationTypeDto.USER, notification.getType()); }
@Test public void testSave() throws Exception { NotificationDto expected = generateNotifications(null, null, null, 1, NotificationTypeDto.USER).get(0); NotificationDto found = notificationDao.findById(expected.getId()).toDto(); Assert.assertEquals(expected, found); }
/** * Create new instance of <code>CassandraNotification</code>. * * @param dto data transfer object contain data that * assign on fields of new instance */ public CassandraNotification(NotificationDto dto) { this.applicationId = dto.getApplicationId(); this.schemaId = dto.getSchemaId(); this.topicId = dto.getTopicId(); this.type = dto.getType(); this.nfVersion = dto.getNfVersion(); this.seqNum = dto.getSecNum(); this.lastModifyTime = dto.getLastTimeModify(); this.body = getByteBuffer(dto.getBody()); this.expiredAt = dto.getExpiredAt(); this.seqNum = dto.getSecNum(); this.id = dto.getId(); if (isBlank(id)) { generateId(); } }
/** * Create new instance of <code>MongoNotification</code>. * @param dto data transfer object contain data that * assign on fields of new instance */ public MongoNotification(NotificationDto dto) { this.id = dto.getId(); this.applicationId = dto.getApplicationId(); this.schemaId = dto.getSchemaId(); this.topicId = dto.getTopicId(); this.nfVersion = dto.getNfVersion(); this.lastModifyTime = dto.getLastTimeModify(); this.type = dto.getType(); this.body = getArrayCopy(dto.getBody()); this.expiredAt = dto.getExpiredAt(); this.secNum = dto.getSecNum(); }
/** * Convert notification. * * @param notificationDto the notification dto * @return the notification */ private static Notification convertNotification(NotificationDto notificationDto) { Notification notification = new Notification(); notification.setBody(ByteBuffer.wrap(notificationDto.getBody())); notification.setTopicId(notificationDto.getTopicId()); switch (notificationDto.getType()) { case SYSTEM: notification.setType(NotificationType.SYSTEM); break; case USER: notification.setType(NotificationType.CUSTOM); break; default: break; } if (notificationDto.getSecNum() >= 0) { notification.setSeqNumber(notificationDto.getSecNum()); } else { // unicast notification notification.setUid(notificationDto.getId()); } return notification; }
private <T> Notification toNotification(UpdateNotificationDto<T> notification) { Notification thriftNotification = new Notification(); thriftNotification.setAppId(notification.getAppId()); thriftNotification.setAppSeqNumber(notification.getAppSeqNumber()); thriftNotification.setGroupId(notification.getGroupId()); thriftNotification.setGroupSeqNumber(notification.getGroupSeqNumber()); thriftNotification.setTopicId(notification.getTopicId()); thriftNotification.setOp(getOperation(notification.getChangeType())); T payload = notification.getPayload(); if (payload != null) { if (payload instanceof NotificationDto) { NotificationDto dto = (NotificationDto) payload; thriftNotification.setNotificationId(dto.getId()); } } return thriftNotification; }
String nid = up.getPayload().getId(); Assert.assertNotNull(nid); try {