use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class HBaseNotificationStoreIntegrationTest method testGetNotification.
@Test
public void testGetNotification() throws IOException {
Notification notification = NotificationTestObjectFactory.getOne();
// covered by testStoreNotification()
sut.store(notification);
Notification fetchedNotification = sut.getNotification(notification.getId());
assertEquals(notification, fetchedNotification);
}
use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class HBaseNotificationStoreIntegrationTest method testStoreNotification.
@Test
public void testStoreNotification() throws IOException {
Notification notification = NotificationTestObjectFactory.getOne();
sut.store(notification);
// rely on result of tableMutations() to avoid checking manually
// didn't check each cell's value but comparing will be covered by testGetNotification()
List<TableMutation> expectedMutations = notificationMapper.tableMutations(notification);
checkMutationsReflectToHBase(expectedMutations);
}
use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class HBaseNotificationStoreIntegrationTest method testUpdateNotificationStatus.
@Test
public void testUpdateNotificationStatus() throws Exception {
Notification notification = NotificationTestObjectFactory.getOne();
sut.store(notification);
Notification.Status newStatus = Notification.Status.FAILED;
Notification fetchedNotification = sut.updateNotificationStatus(notification.getId(), newStatus);
assertEquals(fetchedNotification.getId(), notification.getId());
assertEquals(fetchedNotification.getStatus(), newStatus);
// rely on result of status() to avoid checking manually
List<TableMutation> expectedMutations = notificationMapper.status(notification, newStatus);
checkMutationsReflectToHBase(expectedMutations);
}
use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class HBaseScanConfigBuilderTest method testGetScanConfigWithTs.
@Test
public void testGetScanConfigWithTs() throws Exception {
final List<Criteria.Field> fr = new ArrayList<>();
fr.add(new CriteriaImpl.FieldImpl("notifierName", "test_notifier"));
fr.add(new CriteriaImpl.FieldImpl("status", "NEW"));
final long ts = System.currentTimeMillis();
final long endts = ts + 100;
final List<byte[]> nnList = Arrays.asList("s".getBytes(CHARSET), "qs".getBytes(CHARSET), "NEW".getBytes(CHARSET));
new Expectations() {
{
mockNotificationCriteria.clazz();
times = 1;
result = Notification.class;
mockNotificationCriteria.fieldRestrictions();
times = 1;
result = fr;
mockIndexMapper.getIndexedFieldNames();
times = 1;
result = Arrays.asList("notifierName");
mockNotificationCriteria.numRows();
times = 1;
result = 5;
mockIndexMapper.mapMemberValue("status", "NEW");
times = 1;
result = nnList;
mockNotificationCriteria.startTs();
result = ts;
mockNotificationCriteria.endTs();
result = endts;
}
};
hBaseScanConfigBuilder = new HBaseScanConfigBuilder();
hBaseScanConfigBuilder.addMappers(Notification.class, Arrays.asList(mockIndexMapper));
Criteria<Notification> eventCriteria = new CriteriaImpl<>(Notification.class);
HBaseScanConfig<Notification> notificationScanConfig = hBaseScanConfigBuilder.getScanConfig(mockNotificationCriteria);
System.out.println(notificationScanConfig);
assertEquals(mockIndexMapper, notificationScanConfig.getMapper());
assertArrayEquals(("test_notifier|" + ts).getBytes(CHARSET), notificationScanConfig.getStartRow());
assertArrayEquals(("test_notifier|" + endts).getBytes(CHARSET), notificationScanConfig.getStopRow());
assertEquals(2, notificationScanConfig.filterList().getFilters().size());
// column filter should be first
Filter firstFilter = notificationScanConfig.filterList().getFilters().get(0);
assertEquals(SingleColumnValueFilter.class, firstFilter.getClass());
// page filter should be last
Filter secondFilter = notificationScanConfig.filterList().getFilters().get(1);
assertEquals(PageFilter.class, secondFilter.getClass());
}
use of com.hortonworks.streamline.streams.notification.Notification 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()));
}
Aggregations