Issue #2506 BandwidthManagers now sends notifications for Subscription/BandwidthSubscription creates and deletes.

Amend: Separate update from create notifications in LifecycleManagerImpl.
       Refactored notification sending in EdexBandwidthManager.
       Fixed error in LifecycleManagerImpl refactor.
       Added comment to isRecurringSubscription.

Change-Id: Idc9e8544b156fed40d6aed41511c07138f302f77

Former-commit-id: 7684f7bd51770a41e68700f1d4408a6aad5cd877
This commit is contained in:
Brad Gonzales 2013-11-11 08:20:44 -06:00
parent 3f86a3735e
commit 8f70fb1d0c
13 changed files with 139 additions and 62 deletions

View file

@ -143,6 +143,7 @@ import com.raytheon.viz.ui.presenter.components.ComboBoxConf;
* Oct 23, 2013 2484 dhladky Unique ID for subscriptions updated. * Oct 23, 2013 2484 dhladky Unique ID for subscriptions updated.
* Oct 21, 2013 2292 mpduff Close dialog on OK. * Oct 21, 2013 2292 mpduff Close dialog on OK.
* Nov 07, 2013 2291 skorolev Used showText() method for "Unable to Create Subscription" message. * Nov 07, 2013 2291 skorolev Used showText() method for "Unable to Create Subscription" message.
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is updated and created.
* *
* </pre> * </pre>
* *
@ -1179,12 +1180,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
public void done(final IJobChangeEvent event) { public void done(final IJobChangeEvent event) {
try { try {
final IStatus status = event.getResult(); final IStatus status = event.getResult();
final boolean subscriptionCreated = status.isOK(); final boolean subscriptionCreated = status.isOK();
if (subscriptionCreated) {
sendSubscriptionNotification(subscription,
username);
}
if (!Strings.isNullOrEmpty(status.getMessage())) { if (!Strings.isNullOrEmpty(status.getMessage())) {
guiThreadTaskExecutor.runAsync(new Runnable() { guiThreadTaskExecutor.runAsync(new Runnable() {
@ -1286,10 +1282,6 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
return false; return false;
} }
subscriptionNotificationService
.sendUpdatedSubscriptionNotification(subscription,
username);
} catch (RegistryHandlerException e) { } catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Unable to update subscription.", e); "Unable to update subscription.", e);

View file

@ -67,6 +67,7 @@ import com.raytheon.viz.ui.presenter.components.WidgetConf;
* Apr 08, 2013 1826 djohnson Remove delivery options. * Apr 08, 2013 1826 djohnson Remove delivery options.
* May 14, 2013 1040 mpduff Changed to add office Id rather than setting it. * May 14, 2013 1040 mpduff Changed to add office Id rather than setting it.
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription. * May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is created.
* *
* </pre> * </pre>
* *
@ -279,9 +280,6 @@ public class GroupAddDlg extends CaveSWTDialog {
return false; return false;
} }
subscriptionNotificationService.sendCreatedSubscriptionNotification(
subscription, username);
// refresh table // refresh table
callback.handleRefresh(); callback.handleRefresh();

View file

@ -142,6 +142,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Sep 25. 2013 2409 mpduff Add check for widget disposed after calling configuration. * Sep 25. 2013 2409 mpduff Add check for widget disposed after calling configuration.
* Oct 25, 2013 2292 mpduff Move overlap checks to edex. * Oct 25, 2013 2292 mpduff Move overlap checks to edex.
* Nov 06, 2013 2358 mpduff Resurrected file management code. * Nov 06, 2013 2358 mpduff Resurrected file management code.
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is deleted.
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
@ -1330,12 +1331,6 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
.get(ISubscriptionHandler.class); .get(ISubscriptionHandler.class);
try { try {
handler.delete(username, subscriptions); handler.delete(username, subscriptions);
for (Subscription subscription : subscriptions) {
subscriptionNotificationService
.sendDeletedSubscriptionNotification(subscription,
username);
}
} catch (RegistryHandlerException e) { } catch (RegistryHandlerException e) {
exceptions.add(e); exceptions.add(e);
} }

View file

@ -34,6 +34,7 @@ import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
* Dec 11, 2012 1403 djohnson Adhoc subscriptions no longer go to the registry. * Dec 11, 2012 1403 djohnson Adhoc subscriptions no longer go to the registry.
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription. * May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
* Oct 11, 2013 2460 dhladky Restored Adhoc to registry store, WFO only. * Oct 11, 2013 2460 dhladky Restored Adhoc to registry store, WFO only.
* Nov 12, 2013 2506 bgonzale Added is recurring subscription method.
* *
* </pre> * </pre>
* *
@ -65,4 +66,19 @@ public final class DataDeliveryRegistryObjectTypes {
public static final String PROVIDER = RegistryUtil public static final String PROVIDER = RegistryUtil
.getObjectType(Provider.class); .getObjectType(Provider.class);
/**
* Is the object type a recurring subscription type, excluding adhoc
* subscriptions.
*
* @param objectType
* @return true if the objectType is a recurring subscription type; false
* otherwise.
*/
public static final boolean isRecurringSubscription(String objectType) {
return DataDeliveryRegistryObjectTypes.SHARED_SUBSCRIPTION
.equals(objectType)
|| DataDeliveryRegistryObjectTypes.SITE_SUBSCRIPTION
.equals(objectType);
}
} }

View file

@ -9,3 +9,4 @@ Export-Package: com.raytheon.uf.common.registry.event
Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174", Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.event;bundle-version="1.0.0", com.raytheon.uf.common.event;bundle-version="1.0.0",
com.raytheon.uf.common.stats;bundle-version="1.0.0" com.raytheon.uf.common.stats;bundle-version="1.0.0"
Import-Package: oasis.names.tc.ebxml.regrep.xsd.rim.v4

View file

@ -20,6 +20,8 @@ package com.raytheon.uf.common.registry.event;
* further licensing information. * further licensing information.
**/ **/
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/** /**
@ -33,7 +35,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Mar 16, 2012 jsanchez Initial creation * Mar 16, 2012 jsanchez Initial creation
* Nov 08, 2013 2506 bgonzale Added constructors. * Nov 08, 2013 2506 bgonzale Added constructors. Added object deleted field.
* Added RegistryObjectType field.
* *
* </pre> * </pre>
* *
@ -47,13 +50,17 @@ public class RemoveRegistryEvent extends RegistryEvent {
private String username; private String username;
private RegistryObjectType removedObject;
public RemoveRegistryEvent() { public RemoveRegistryEvent() {
} }
public RemoveRegistryEvent(String username, String id) { public RemoveRegistryEvent(String username, String id,
RegistryObjectType removedObject) {
super(id, null, null, Action.DELETE); super(id, null, null, Action.DELETE);
this.username = username; this.username = username;
this.removedObject = removedObject;
} }
public String getUsername() { public String getUsername() {
@ -64,6 +71,21 @@ public class RemoveRegistryEvent extends RegistryEvent {
this.username = username; this.username = username;
} }
/**
* @return the removedObject
*/
public RegistryObjectType getRemovedObject() {
return removedObject;
}
/**
* @param removedObject
* the removedObject to set
*/
public void setRemovedObject(RegistryObjectType removedObject) {
this.removedObject = removedObject;
}
@Override @Override
public String toString() { public String toString() {
return "Remove " + super.toString(); return "Remove " + super.toString();

View file

@ -16,5 +16,6 @@ Require-Bundle: com.raytheon.uf.common.datadelivery.bandwidth;bundle-version="1.
com.raytheon.uf.common.status;bundle-version="1.12.1174", com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.google.guava;bundle-version="1.0.0", com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.edex.core;bundle-version="1.12.1174", com.raytheon.uf.edex.core;bundle-version="1.12.1174",
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0" com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.service;bundle-version="1.0.0"
Import-Package: com.raytheon.edex.site Import-Package: com.raytheon.edex.site

View file

@ -19,6 +19,8 @@
**/ **/
package com.raytheon.uf.edex.datadelivery.bandwidth; package com.raytheon.uf.edex.datadelivery.bandwidth;
import static com.raytheon.uf.common.registry.ebxml.encoder.RegistryEncoders.Type.JAXB;
import java.text.ParseException; import java.text.ParseException;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -37,6 +39,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.eventbus.AllowConcurrentEvents; import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.raytheon.edex.site.SiteUtil;
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest; import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType; import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription; import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
@ -53,8 +56,11 @@ import com.raytheon.uf.common.datadelivery.registry.handlers.IDataSetMetaDataHan
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler; import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService; import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.event.EventBus; import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.registry.ebxml.encoder.RegistryEncoders;
import com.raytheon.uf.common.registry.event.InsertRegistryEvent; import com.raytheon.uf.common.registry.event.InsertRegistryEvent;
import com.raytheon.uf.common.registry.event.RegistryEvent;
import com.raytheon.uf.common.registry.event.RemoveRegistryEvent; import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
import com.raytheon.uf.common.registry.event.UpdateRegistryEvent;
import com.raytheon.uf.common.registry.handler.IRegistryObjectHandler; import com.raytheon.uf.common.registry.handler.IRegistryObjectHandler;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException; import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.serialization.SerializationException;
@ -100,6 +106,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc * 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
* Nov 04, 2013 2506 bgonzale Added removeBandwidthSubscriptions method. * Nov 04, 2013 2506 bgonzale Added removeBandwidthSubscriptions method.
* Added subscriptionNotificationService field. * Added subscriptionNotificationService field.
* Send notifications.
* *
* </pre> * </pre>
* *
@ -325,6 +332,17 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
+ event.getId() + "]"); + event.getId() + "]");
removeBandwidthSubscriptions(event.getId()); removeBandwidthSubscriptions(event.getId());
try {
Subscription<T, C> sub = (Subscription<T, C>) RegistryEncoders
.ofType(JAXB).decodeObject(
((RemoveRegistryEvent) event).getRemovedObject());
sendSubscriptionNotificationEvent(event, sub);
} catch (SerializationException e) {
statusHandler
.handle(Priority.PROBLEM,
"Failed to retrieve deleted object from RemoveRegistryEvent",
e);
}
} }
} }
} }
@ -368,6 +386,59 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
+ "]"); + "]");
} }
} }
Subscription<T, C> sub = getRegistryObjectById(subscriptionHandler,
re.getId());
sendSubscriptionNotificationEvent(re, sub);
}
/**
* Create a hook into the EDEX Notification sub-system to receive
* UpdateRegistryEvents. Filter for subscription specific events.
*
* @param event
*/
@Subscribe
@AllowConcurrentEvents
public void registryEventListener(UpdateRegistryEvent event) {
Subscription<T, C> sub = getRegistryObjectById(subscriptionHandler,
event.getId());
sendSubscriptionNotificationEvent(event, sub);
}
private void sendSubscriptionNotificationEvent(RegistryEvent event,
Subscription<T, C> sub) {
final String objectType = event.getObjectType();
if (DataDeliveryRegistryObjectTypes.isRecurringSubscription(objectType)) {
if (sub != null) {
boolean isApplicableForTheLocalSite = sub.getOfficeIDs()
.contains(SiteUtil.getSite());
if (isApplicableForTheLocalSite) {
switch (event.getAction()) {
case UPDATE:
subscriptionNotificationService
.sendUpdatedSubscriptionNotification(sub,
sub.getOwner());
break;
case INSERT:
subscriptionNotificationService
.sendCreatedSubscriptionNotification(sub,
sub.getOwner());
break;
case DELETE:
subscriptionNotificationService
.sendDeletedSubscriptionNotification(sub,
sub.getOwner());
break;
default:
statusHandler.handle(
Priority.PROBLEM,
"Invalid RegistryEvent action: "
+ event.getAction());
}
}
}
}
} }
private DataSetMetaData<T> getDataSetMetaData(String id) { private DataSetMetaData<T> getDataSetMetaData(String id) {

View file

@ -18,7 +18,6 @@
<bean id="groupDefinitionServiceHandler" <bean id="groupDefinitionServiceHandler"
class="com.raytheon.uf.edex.datadelivery.service.services.GroupDefinitionServiceHandler"> class="com.raytheon.uf.edex.datadelivery.service.services.GroupDefinitionServiceHandler">
<constructor-arg ref="subscriptionNotificationService" />
</bean> </bean>
<bean factory-bean="handlerRegistry" factory-method="register"> <bean factory-bean="handlerRegistry" factory-method="register">

View file

@ -29,7 +29,6 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers; import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler; import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.service.IGroupDefinitionService; import com.raytheon.uf.common.datadelivery.service.IGroupDefinitionService;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException; import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.util.CollectionUtil; import com.raytheon.uf.common.util.CollectionUtil;
import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler; import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
@ -45,6 +44,7 @@ import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 18, 2013 1441 djohnson Initial creation * Jan 18, 2013 1441 djohnson Initial creation
* Nov 12, 2013 2506 bgonzale Refactored out notification service.
* *
* </pre> * </pre>
* *
@ -55,17 +55,13 @@ import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
public class GroupDefinitionServiceHandler extends public class GroupDefinitionServiceHandler extends
AbstractPrivilegedRequestHandler<GroupDefinitionServiceRequest> { AbstractPrivilegedRequestHandler<GroupDefinitionServiceRequest> {
private final ISubscriptionNotificationService notificationService;
/** /**
* Constructor. * Constructor.
* *
* @param notificationService * @param notificationService
* the subscription notification service * the subscription notification service
*/ */
public GroupDefinitionServiceHandler( public GroupDefinitionServiceHandler() {
ISubscriptionNotificationService notificationService) {
this.notificationService = notificationService;
} }
/** /**
@ -104,14 +100,6 @@ public class GroupDefinitionServiceHandler extends
for (Subscription sub : subsForGroup) { for (Subscription sub : subsForGroup) {
sub.setGroupName(GroupDefinition.NO_GROUP); sub.setGroupName(GroupDefinition.NO_GROUP);
handler.update(sub); handler.update(sub);
// TODO: Would be nice to use a subset of the
// SubscriptionService functionality here so we didn't have to
// manually send the subscription updated notification
String username = user != null ? user.uniqueId().toString()
: "none";
notificationService.sendUpdatedSubscriptionNotification(sub,
username);
} }
} }

View file

@ -65,6 +65,7 @@ import com.raytheon.uf.common.registry.event.InsertRegistryEvent;
import com.raytheon.uf.common.registry.event.RegistryEvent.Action; import com.raytheon.uf.common.registry.event.RegistryEvent.Action;
import com.raytheon.uf.common.registry.event.RegistryStatisticsEvent; import com.raytheon.uf.common.registry.event.RegistryStatisticsEvent;
import com.raytheon.uf.common.registry.event.RemoveRegistryEvent; import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
import com.raytheon.uf.common.registry.event.UpdateRegistryEvent;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.time.util.TimeUtil;
@ -103,6 +104,8 @@ import com.raytheon.uf.edex.registry.ebxml.util.xpath.RegistryXPathProcessor;
* 8/1/2013 1693 bphillip Added check references and refactored submit objects to conform to EBXML 4.0 spec * 8/1/2013 1693 bphillip Added check references and refactored submit objects to conform to EBXML 4.0 spec
* 9/11/2013 2254 bphillip Cleaned up creation of auditable events * 9/11/2013 2254 bphillip Cleaned up creation of auditable events
* 10/23/2013 1538 bphillip Changed QueryRequest constructor call * 10/23/2013 1538 bphillip Changed QueryRequest constructor call
* Nov 08, 2013 2506 bgonzale Added RegistryObjectType to RemoveRegistryEvent.
* Separate update from create notifications.
* *
* *
* </pre> * </pre>
@ -300,7 +303,7 @@ public class LifecycleManagerImpl implements LifecycleManager {
if (objectType != null if (objectType != null
&& !objectType.equals(RegistryObjectTypes.ASSOCIATION)) { && !objectType.equals(RegistryObjectTypes.ASSOCIATION)) {
RemoveRegistryEvent event = new RemoveRegistryEvent( RemoveRegistryEvent event = new RemoveRegistryEvent(
request.getUsername(), obj.getId()); request.getUsername(), obj.getId(), obj);
event.setAction(Action.DELETE); event.setAction(Action.DELETE);
event.setLid(obj.getLid()); event.setLid(obj.getLid());
event.setObjectType(objectType); event.setObjectType(objectType);
@ -485,10 +488,9 @@ public class LifecycleManagerImpl implements LifecycleManager {
// gives a close estimate to amount taken on each object // gives a close estimate to amount taken on each object
// individually, this will be millis in most cases, hopefully // individually, this will be millis in most cases, hopefully
long avTimePerRecord = 0; long avTimePerRecord = objs.isEmpty() ? 0 : totalTime / objs.size();
if (!objs.isEmpty()) { if (!objsCreated.isEmpty()) {
avTimePerRecord = totalTime / objs.size(); for (RegistryObjectType obj : objsCreated) {
for (RegistryObjectType obj : objs) {
EventBus.publish(new InsertRegistryEvent(obj.getId(), obj EventBus.publish(new InsertRegistryEvent(obj.getId(), obj
.getLid(), obj.getObjectType())); .getLid(), obj.getObjectType()));
EventBus.publish(new RegistryStatisticsEvent(obj EventBus.publish(new RegistryStatisticsEvent(obj
@ -496,6 +498,15 @@ public class LifecycleManagerImpl implements LifecycleManager {
avTimePerRecord)); avTimePerRecord));
} }
} }
if (!objsUpdated.isEmpty()) {
for (RegistryObjectType obj : objsUpdated) {
EventBus.publish(new UpdateRegistryEvent(obj.getId(), obj
.getLid(), obj.getObjectType()));
EventBus.publish(new RegistryStatisticsEvent(obj
.getObjectType(), obj.getStatus(), obj.getOwner(),
avTimePerRecord));
}
}
return response; return response;
} }

View file

@ -107,6 +107,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
* Sept 25, 2013 1797 dhladky separated time from gridded time * Sept 25, 2013 1797 dhladky separated time from gridded time
* Oct 10, 2013 1797 bgonzale Refactored registry Time objects. * Oct 10, 2013 1797 bgonzale Refactored registry Time objects.
* Oct 21, 2013 2292 mpduff Implement multiple data types * Oct 21, 2013 2292 mpduff Implement multiple data types
* Nov 08, 2013 2506 bgonzale Added RegistryObjectType to RemoveRegistryEvent.
* *
* </pre> * </pre>
* *
@ -1000,7 +1001,7 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
private void sendDeletedSubscriptionEvent(Subscription subscription) { private void sendDeletedSubscriptionEvent(Subscription subscription) {
RemoveRegistryEvent event = new RemoveRegistryEvent( RemoveRegistryEvent event = new RemoveRegistryEvent(
subscription.getOwner(), subscription.getId()); subscription.getOwner(), subscription.getId(), null);
event.setObjectType(DataDeliveryRegistryObjectTypes.SITE_SUBSCRIPTION); event.setObjectType(DataDeliveryRegistryObjectTypes.SITE_SUBSCRIPTION);
bandwidthManager.subscriptionRemoved(event); bandwidthManager.subscriptionRemoved(event);
} }

View file

@ -23,11 +23,6 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.emptyCollectionOf; import static org.hamcrest.Matchers.emptyCollectionOf;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.rmi.RemoteException; import java.rmi.RemoteException;
@ -40,7 +35,6 @@ import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription; import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBuilder; import com.raytheon.uf.common.datadelivery.registry.SubscriptionBuilder;
import com.raytheon.uf.common.datadelivery.service.GroupDefinitionService; import com.raytheon.uf.common.datadelivery.service.GroupDefinitionService;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException; import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil; import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
import com.raytheon.uf.edex.datadelivery.service.services.GroupDefinitionServiceHandler; import com.raytheon.uf.edex.datadelivery.service.services.GroupDefinitionServiceHandler;
@ -58,6 +52,7 @@ import com.raytheon.uf.edex.datadelivery.service.services.GroupDefinitionService
* Feb 26, 2013 1643 djohnson Change exception type thrown. * Feb 26, 2013 1643 djohnson Change exception type thrown.
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription. * Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
* Jun 24, 2013 2106 djohnson RegistryManager is gone. * Jun 24, 2013 2106 djohnson RegistryManager is gone.
* Nov 12, 2013 2506 bgonzale Refactored out notification service.
* *
* </pre> * </pre>
* *
@ -73,14 +68,11 @@ public class GroupDefinitionServiceTest {
private IGroupDefinitionHandler groupHandler; private IGroupDefinitionHandler groupHandler;
private final ISubscriptionNotificationService subscriptionNotificationService = mock(ISubscriptionNotificationService.class);
private final GroupDefinitionService service = new GroupDefinitionService() { private final GroupDefinitionService service = new GroupDefinitionService() {
@Override @Override
protected Object getResponseFromServer( protected Object getResponseFromServer(
GroupDefinitionServiceRequest request) throws Exception { GroupDefinitionServiceRequest request) throws Exception {
return new GroupDefinitionServiceHandler( return new GroupDefinitionServiceHandler().handleRequest(request);
subscriptionNotificationService).handleRequest(request);
} }
}; };
@ -116,16 +108,6 @@ public class GroupDefinitionServiceTest {
is(emptyCollectionOf(Subscription.class))); is(emptyCollectionOf(Subscription.class)));
} }
@Test
public void deletingAGroupNotifiesOfSubscriptionUpdates()
throws RemoteException, RegistryHandlerException {
service.deleteGroupDefinition(group);
verify(subscriptionNotificationService, times(2))
.sendUpdatedSubscriptionNotification(any(Subscription.class),
anyString());
}
@Test @Test
public void deletingAGroupDeletesTheGroup() throws RemoteException, public void deletingAGroupDeletesTheGroup() throws RemoteException,
RegistryHandlerException { RegistryHandlerException {