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; }
@Test public void testToDto() { NotificationDto expected = generateNotifications(null, null, null, 1, NotificationTypeDto.USER).get(0); Assert.assertEquals(expected, new CassandraNotification(expected).toDto()); } }
@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); }