@Override protected NotificationDto newEntity() { NotificationDto dto = new NotificationDto(); dto.setApplicationId(applicationId); dto.setTopicId(topicId); dto.setType(NotificationTypeDto.USER); return dto; }
protected List<NotificationDto> generateNotifications(String topicId, String appId, String schemaId, int count, NotificationTypeDto type) { List<NotificationDto> notifications = new ArrayList<>(count); NotificationDto notification; for (int i = 0; i < count; i++) { notification = new NotificationDto(); notification.setApplicationId(appId != null ? appId : UUID.randomUUID().toString()); notification.setSchemaId(schemaId != null ? schemaId : UUID.randomUUID().toString()); notification.setTopicId(topicId != null ? topicId : UUID.randomUUID().toString()); notification.setType(type != null ? type : NotificationTypeDto.USER); notification.setSecNum(i); notification.setBody(UUID.randomUUID().toString().getBytes()); notification.setLastTimeModify(new Date(System.currentTimeMillis())); notification.setNfVersion(1); notification.setExpiredAt(new Date(System.currentTimeMillis() + 7 * 24 * 3600 * 1000)); notifications.add(notificationDao.save(notification).toDto()); } return notifications; }
dto.setNfVersion(schema.getVersion()); dto.setApplicationId(schema.getApplicationId()); dto.setType(schema.getType()); } else { throw new DatabaseProcessingException("Can't find notification schema by id " + schemaId);
@Override public NotificationDto toDto() { NotificationDto dto = new NotificationDto(); dto.setId(id); dto.setApplicationId(applicationId); dto.setSchemaId(schemaId); dto.setTopicId(topicId); dto.setLastTimeModify(lastModifyTime); dto.setNfVersion(nfVersion); dto.setType(type); dto.setBody(getArrayCopy(body)); dto.setExpiredAt(expiredAt); dto.setSecNum(secNum); return dto; } }
@Override public EndpointNotificationDto toDto() { EndpointNotificationDto dto = new EndpointNotificationDto(); dto.setId(id != null ? id : generateId()); dto.setEndpointKeyHash(endpointKeyHash != null ? endpointKeyHash.array() : null); NotificationDto notificationDto = new NotificationDto(); notificationDto.setSecNum(seqNum); notificationDto.setType(type); notificationDto.setApplicationId(applicationId); notificationDto.setSchemaId(schemaId); notificationDto.setNfVersion(nfVersion); notificationDto.setLastTimeModify(lastModifyTime); notificationDto.setBody(getBytes(body)); notificationDto.setExpiredAt(expiredAt); notificationDto.setTopicId(topicId); dto.setNotificationDto(notificationDto); return dto; } }
notification.setType(type != null ? type : NotificationTypeDto.USER); byte[] body = null; try {
@Override public NotificationDto toDto() { NotificationDto dto = new NotificationDto(); dto.setId(getStringId()); dto.setApplicationId(applicationId); dto.setSchemaId(schemaId); dto.setTopicId(topicId); dto.setLastTimeModify(lastModifyTime); dto.setNfVersion(nfVersion); dto.setType(type); dto.setBody(body != null ? getBytes(body) : null); dto.setExpiredAt(expiredAt); dto.setSecNum(seqNum); return dto; }
notificationDto.setNfVersion(schema.getVersion()); notificationDto.setApplicationId(schema.getApplicationId()); notificationDto.setType(schema.getType()); try { notificationDto.setBody(serializeNotificationBody(notificationDto, schema));
protected EndpointNotificationDto generateUnicastNotificationDto(String schemaId, String topicId, byte[] keyHash) { EndpointNotificationDto endpointNotification = new EndpointNotificationDto(); endpointNotification.setEndpointKeyHash(keyHash); NotificationDto notification = new NotificationDto(); NotificationSchemaDto schema; if (isBlank(schemaId)) { schema = generateNotificationSchemaDto(null, NotificationTypeDto.USER); } else { schema = notificationService.findNotificationSchemaById(schemaId); } if (isBlank(topicId)) { topicId = generateTopicDto(schema.getApplicationId(), null).getId(); } notification.setTopicId(topicId); notification.setApplicationId(schema.getApplicationId()); notification.setSchemaId(schema.getId()); notification.setType(NotificationTypeDto.USER); byte[] body = null; try { body = readSchemaFileAsString("dao/schema/testBaseData.json").getBytes(Charset.forName("UTF-8")); } catch (IOException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } notification.setBody(body); endpointNotification.setNotificationDto(notification); UpdateNotificationDto<EndpointNotificationDto> update = notificationService.saveUnicastNotification(endpointNotification); return update.getPayload(); }