use of org.motechproject.admin.messages.ActionType in project motech by motech.
the class NotificationRulesDataServiceBundleIT method shouldPerformCrudOperations.
@Test
public void shouldPerformCrudOperations() {
NotificationRule notificationRule = new NotificationRule("recip", ActionType.EMAIL, Level.CRITICAL, "admin");
NotificationRule notificationRule2 = new NotificationRule("recip2", ActionType.SMS, Level.INFO, "tasks");
dataService.create(notificationRule);
dataService.create(notificationRule2);
List<NotificationRule> notificationRules = dataService.retrieveAll();
List<String> actual = extract(notificationRules, on(NotificationRule.class).getRecipient());
assertThat(actual, hasItems("recip", "recip2"));
List<ActionType> actualActions = extract(notificationRules, on(NotificationRule.class).getActionType());
assertThat(actualActions, hasItems(ActionType.EMAIL, ActionType.SMS));
actual = extract(notificationRules, on(NotificationRule.class).getModuleName());
assertThat(actual, hasItems("admin", "tasks"));
List<Level> actualLevels = extract(notificationRules, on(NotificationRule.class).getLevel());
assertThat(actualLevels, hasItems(Level.CRITICAL, Level.INFO));
notificationRule.setRecipient("recip3");
dataService.update(notificationRule);
notificationRules = dataService.retrieveAll();
actual = extract(notificationRules, on(NotificationRule.class).getRecipient());
assertThat(actual, hasItems("recip3", "recip2"));
actualActions = extract(notificationRules, on(NotificationRule.class).getActionType());
assertThat(actualActions, hasItems(ActionType.EMAIL, ActionType.SMS));
dataService.delete(notificationRule);
notificationRules = dataService.retrieveAll();
assertEquals(asList("recip2"), extract(notificationRules, on(NotificationRule.class).getRecipient()));
assertEquals(asList(ActionType.SMS), extract(notificationRules, on(NotificationRule.class).getActionType()));
assertEquals(asList("tasks"), extract(notificationRules, on(NotificationRule.class).getModuleName()));
assertEquals(asList(Level.INFO), extract(notificationRules, on(NotificationRule.class).getLevel()));
}
Aggregations