/** * Convert unicast notification. * * @param unicastNotification the unicast notification * @return the notification dto */ private NotificationDto convertUnicastNotification(EndpointNotificationDto unicastNotification) { NotificationDto dto = unicastNotification.getNotificationDto(); dto.setId(unicastNotification.getId()); return dto; }
/** * Create new instance of <code>MongoEndpointNotification</code>. * @param dto data transfer object contain data that * assign on fields of new instance */ public MongoEndpointNotification(EndpointNotificationDto dto) { this.id = dto.getId(); this.endpointKeyHash = getArrayCopy(dto.getEndpointKeyHash()); this.notification = dto.getNotificationDto() != null ? new MongoNotification(dto.getNotificationDto()) : null; }
/** * Create new instance of <code>CassandraTopicListEntry</code>. * * @param dto data transfer object contain data that assign on fields of new instance */ public CassandraEndpointNotification(EndpointNotificationDto dto) { this.endpointKeyHash = ByteBuffer.wrap(dto.getEndpointKeyHash()); NotificationDto notificationDto = dto.getNotificationDto(); if (notificationDto != null) { this.seqNum = notificationDto.getSecNum(); this.type = notificationDto.getType(); this.applicationId = notificationDto.getApplicationId(); this.schemaId = notificationDto.getSchemaId(); this.nfVersion = notificationDto.getNfVersion(); this.lastModifyTime = notificationDto.getLastTimeModify(); this.body = getByteBuffer(notificationDto.getBody()); this.expiredAt = notificationDto.getExpiredAt(); this.topicId = notificationDto.getTopicId(); } this.id = dto.getId() != null ? dto.getId() : generateId(); }
@Test public void testRemoveUnicastNotificationById() { TopicDto topicDto = generateTopicDto(null, null); EndpointProfileDto profile = generateEndpointProfileDto(topicDto.getApplicationId(), Arrays.asList(topicDto.getId())); byte[] keyHash = profile.getEndpointKeyHash(); EndpointNotificationDto notification = generateUnicastNotificationDto(null, topicDto.getId(), keyHash); Assert.assertTrue(isNotBlank(notification.getId())); notificationService.removeUnicastNotificationById(notification.getId()); EndpointNotificationDto notif = notificationService.findUnicastNotificationById(notification.getId()); Assert.assertNull(notif); }
for (EndpointNotificationDto unicastNotification : unicastNotifications) { LOG.debug("[{}] detected new unicast notification: {} ", endpointId, unicastNotification.getId()); LOG.trace("[{}] detected new unicast notification: {} ", endpointId, unicastNotification); NotificationDto notificationDto = unicastNotification.getNotificationDto(); LOG.trace("[{}] notification expiration time is {}({}) which is later then {}", endpointId, date.getTime(), date, now); notificationDto.setId(unicastNotification.getId()); notifications.add(notificationDto);
@Test public void testFindUnicastNotificationById() { TopicDto topicDto = generateTopicDto(null, null); EndpointProfileDto profile = generateEndpointProfileDto(topicDto.getApplicationId(), Arrays.asList(topicDto.getId())); byte[] keyHash = profile.getEndpointKeyHash(); EndpointNotificationDto notification = generateUnicastNotificationDto(null, topicDto.getId(), keyHash); Assert.assertTrue(isNotBlank(notification.getId())); EndpointNotificationDto found = notificationService.findUnicastNotificationById(notification.getId()); Assert.assertEquals(notification, found); }
@Test public void testRemoveUnicastNotificationsByKeyHash() { TopicDto topicDto = generateTopicDto(null, null); EndpointProfileDto profile = generateEndpointProfileDto(topicDto.getApplicationId(), Arrays.asList(topicDto.getId())); byte[] keyHash = profile.getEndpointKeyHash(); EndpointNotificationDto notification = generateUnicastNotificationDto(null, topicDto.getId(), keyHash); Assert.assertTrue(isNotBlank(notification.getId())); notificationService.removeUnicastNotificationsByKeyHash(keyHash); List<EndpointNotificationDto> notifications = notificationService.findUnicastNotificationsByKeyHash(keyHash); Assert.assertTrue(notifications.isEmpty()); }
nf.setNotificationId(notificationDto.getId()); if (LOG.isTraceEnabled()) { LOG.trace("Sending message {} to [{}]",