use of org.ovirt.engine.core.common.businessentities.EventSubscriber in project ovirt-engine by oVirt.
the class EventDaoTest method testGetAllForSubscriber.
/**
* Ensures that all subscriptions are returned.
*/
@Test
public void testGetAllForSubscriber() {
List<EventSubscriber> result = dao.getAllForSubscriber(existingSubscriber);
assertNotNull(result);
assertFalse(result.isEmpty());
for (EventSubscriber subscription : result) {
assertEquals(existingSubscriber, subscription.getSubscriberId());
}
}
use of org.ovirt.engine.core.common.businessentities.EventSubscriber in project ovirt-engine by oVirt.
the class EventDaoTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
dao = dbFacade.getEventDao();
existingSubscriber = new Guid("9bf7c640-b620-456f-a550-0348f366544a");
newSubscriber = new Guid("9bf7c640-b620-456f-a550-0348f366544b");
newSubscription = new EventSubscriber();
newSubscription.setSubscriberId(newSubscriber);
newSubscription.setEventNotificationMethod(EventNotificationMethod.SMTP);
newSubscription.setEventUpName("TestRun");
newSubscription.setTagName("farkle");
newHistory = new EventNotificationHist();
newHistory.setAuditLogId(FREE_AUDIT_LOG_ID);
newHistory.setEventName("Failure");
newHistory.setMethodType("Email");
newHistory.setReason("Dunno");
newHistory.setSentAt(new Date());
newHistory.setStatus(false);
newHistory.setSubscriberId(existingSubscriber);
}
use of org.ovirt.engine.core.common.businessentities.EventSubscriber in project ovirt-engine by oVirt.
the class EventDaoTest method testSubscribe.
/**
* Ensures that subscribing a user works as expected.
*/
@Test
public void testSubscribe() {
dao.subscribe(newSubscription);
List<EventSubscriber> result = dao.getAllForSubscriber(newSubscription.getSubscriberId());
assertNotNull(result);
assertFalse(result.isEmpty());
for (EventSubscriber subscription : result) {
assertEquals(newSubscriber, subscription.getSubscriberId());
}
}
use of org.ovirt.engine.core.common.businessentities.EventSubscriber in project ovirt-engine by oVirt.
the class EventDaoTest method testUnsubscribe.
/**
* Ensures that unsubscribing a user works as expected.
*/
@Test
public void testUnsubscribe() {
List<EventSubscriber> before = dao.getAllForSubscriber(existingSubscriber);
// ensure we have subscriptions
assertFalse(before.isEmpty());
for (EventSubscriber subscriber : before) {
dao.unsubscribe(subscriber);
}
List<EventSubscriber> after = dao.getAllForSubscriber(existingSubscriber);
assertNotNull(after);
assertTrue(after.isEmpty());
}
use of org.ovirt.engine.core.common.businessentities.EventSubscriber in project ovirt-engine by oVirt.
the class UserEventNotifierListModel method onSave.
public void onSave() {
EventNotificationModel model = (EventNotificationModel) getWindow();
if (!model.validate()) {
return;
}
ArrayList<ActionParametersBase> toAddList = new ArrayList<>();
ArrayList<ActionParametersBase> toRemoveList = new ArrayList<>();
// var selected = model.EventGroupModels.SelectMany(a => a.Children).Where(a => a.IsSelected == true);
ArrayList<SelectionTreeNodeModel> selected = new ArrayList<>();
for (SelectionTreeNodeModel node : model.getEventGroupModels()) {
for (SelectionTreeNodeModel child : node.getChildren()) {
if (child.getIsSelectedNullable() != null && child.getIsSelectedNullable().equals(true)) {
selected.add(child);
}
}
}
Collection<EventSubscriber> existing = getItems() != null ? getItems() : new ArrayList<EventSubscriber>();
ArrayList<SelectionTreeNodeModel> added = new ArrayList<>();
ArrayList<EventSubscriber> removed = new ArrayList<>();
// check what has been added:
for (SelectionTreeNodeModel selectedEvent : selected) {
boolean selectedInExisting = false;
for (EventSubscriber existingEvent : existing) {
if (selectedEvent.getTitle().equals(existingEvent.getEventUpName())) {
selectedInExisting = true;
break;
}
}
if (!selectedInExisting) {
added.add(selectedEvent);
}
}
// check what has been deleted:
for (EventSubscriber existingEvent : existing) {
boolean existingInSelected = false;
for (SelectionTreeNodeModel selectedEvent : selected) {
if (selectedEvent.getTitle().equals(existingEvent.getEventUpName())) {
existingInSelected = true;
break;
}
}
if (!existingInSelected) {
removed.add(existingEvent);
}
}
if (!StringHelper.isNullOrEmpty(model.getOldEmail()) && !model.getOldEmail().equals(model.getEmail().getEntity())) {
for (EventSubscriber a : existing) {
toRemoveList.add(new EventSubscriptionParametesBase(new EventSubscriber(a.getEventUpName(), EventNotificationMethod.SMTP, a.getMethodAddress(), a.getSubscriberId(), ""), // $NON-NLS-1$ //$NON-NLS-2$
""));
}
for (SelectionTreeNodeModel a : selected) {
toAddList.add(new EventSubscriptionParametesBase(new EventSubscriber(a.getTitle(), EventNotificationMethod.SMTP, model.getEmail().getEntity(), getEntity().getId(), ""), // $NON-NLS-1$ //$NON-NLS-2$
""));
}
} else {
for (SelectionTreeNodeModel a : added) {
toAddList.add(new EventSubscriptionParametesBase(new EventSubscriber(a.getTitle(), EventNotificationMethod.SMTP, model.getEmail().getEntity(), getEntity().getId(), ""), // $NON-NLS-1$ //$NON-NLS-2$
""));
}
for (EventSubscriber a : removed) {
toRemoveList.add(new EventSubscriptionParametesBase(new EventSubscriber(a.getEventUpName(), EventNotificationMethod.SMTP, a.getMethodAddress(), a.getSubscriberId(), ""), // $NON-NLS-1$ //$NON-NLS-2$
""));
}
}
if (toRemoveList.size() > 0) {
EventSubscriptionFrontendActionAsyncCallback callback = new EventSubscriptionFrontendActionAsyncCallback(toAddList, toRemoveList);
for (ActionParametersBase param : toRemoveList) {
Frontend.getInstance().runAction(ActionType.RemoveEventSubscription, param, callback);
}
} else if (toAddList.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.AddEventSubscription, toAddList);
}
cancel();
}
Aggregations