@Test public void testTableMutations() throws Exception { Map<String, Object> fieldAndValues = new HashMap<>(); fieldAndValues.put("one", "A"); Notification notification = new NotificationImpl.Builder(fieldAndValues) .id("notification-id") .dataSourceIds(Arrays.asList("dsrcid-1")) .eventIds(Arrays.asList("eventid-1")) .notifierName("test-notifier") .ruleId("rule-1") .build(); List<TableMutation> tms = notificationMapper.tableMutations(notification); System.out.println(tms); assertEquals(1, tms.size()); TableMutation tm = tms.get(0); assertEquals("Notification", tm.tableName()); assertEquals(1, tm.updates().size()); Put put = tm.updates().get(0); assertTrue(put.has("f".getBytes(), "one".getBytes(), new Serializer().serialize("A"))); assertTrue(put.has("d".getBytes(), "dsrcid-1".getBytes(), "1".getBytes())); assertTrue(put.has("e".getBytes(), "eventid-1".getBytes(), "1".getBytes())); assertTrue(put.has("nn".getBytes(), "test-notifier".getBytes(), "1".getBytes())); assertTrue(put.has("r".getBytes(), "rule-1".getBytes(), "1".getBytes())); assertTrue(put.has("s".getBytes(), "qs".getBytes(), "NEW".getBytes())); }
@Override public List<TableMutation> tableMutations(Notification notification) { List<TableMutation> tableMutations = super.tableMutations(notification); for (NotificationIndexMapper im : indexMappers) { tableMutations.addAll(im.tableMutations(notification)); } LOG.trace("Notification {}, tableMutations {}", notification, tableMutations); return tableMutations; }
NotificationMapper extends AbstractNotificationMapper { @Override public List<TableMutation> tableMutations(Notification notification) { List<TableMutation> tableMutations = super.tableMutations(notification); for (NotificationIndexMapper im : indexMappers) { tableMutations.addAll(im.tableMutations(notification)); } LOG.trace("Notification {}, tableMutations {}", notification, tableMutations); return tableMutations; } }
NotificationMapper extends AbstractNotificationMapper { @Override public List<TableMutation> tableMutations(Notification notification) { List<TableMutation> tableMutations = super.tableMutations(notification); for (NotificationIndexMapper im : indexMappers) { tableMutations.addAll(im.tableMutations(notification)); } LOG.trace("Notification {}, tableMutations {}", notification, tableMutations); return tableMutations; } NotificationMapper();  NotificationMapper(List<NotificationIndexMapper> indexMappers); }
NotificationMapper extends AbstractNotificationMapper { @Override public List<TableMutation> tableMutations(Notification notification) { List<TableMutation> tableMutations = super.tableMutations(notification); for (NotificationIndexMapper im : indexMappers) { tableMutations.addAll(im.tableMutations(notification)); } LOG.trace("Notification {}, tableMutations {}", notification, tableMutations); return tableMutations; } NotificationMapper();  NotificationMapper(List<NotificationIndexMapper> indexMappers); @Override List<TableMutation> tableMutations(Notification notification); List<TableMutation> status(Notification notification, Notification.Status status); @Override String getTableName(); }
NotificationMapper extends AbstractNotificationMapper { @Override public List<TableMutation> tableMutations(Notification notification) { List<TableMutation> tableMutations = super.tableMutations(notification); for (NotificationIndexMapper im : indexMappers) { tableMutations.addAll(im.tableMutations(notification)); } LOG.trace("Notification {}, tableMutations {}", notification, tableMutations); return tableMutations; } NotificationMapper();  NotificationMapper(List<NotificationIndexMapper> indexMappers); @Override List<TableMutation> tableMutations(Notification notification); List<TableMutation> status(Notification notification, Notification.Status status); @Override String getTableName();  }