Search in sources :

Example 1 with Serializer

use of com.hortonworks.streamline.streams.notification.store.hbase.Serializer in project streamline by hortonworks.

the class NotificationMapperTest method testTableMutations.

@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()));
}
Also used : HashMap(java.util.HashMap) Notification(com.hortonworks.streamline.streams.notification.Notification) Put(org.apache.hadoop.hbase.client.Put) Serializer(com.hortonworks.streamline.streams.notification.store.hbase.Serializer) Test(org.junit.Test)

Aggregations

Notification (com.hortonworks.streamline.streams.notification.Notification)1 Serializer (com.hortonworks.streamline.streams.notification.store.hbase.Serializer)1 HashMap (java.util.HashMap)1 Put (org.apache.hadoop.hbase.client.Put)1 Test (org.junit.Test)1