InMemorySubscriptionManager implements SubscriptionManager { @Override public void unsubscribe(String tenant, String metricId, Subscription.SubscriptionOwner subscriptionOwner) { unsubscribe(tenant, metricId, Collections.singleton(subscriptionOwner)); } InMemorySubscriptionManager(MetricsClient metricsClient); @Override Set<Subscription> subscriptionsOfTenant(String tenant); @Override void setPredictionListener(PredictionListener predictionListener); @Override void subscribe(Subscription subscription); @Override void updateMetric(String tenant, String metricId, Metric.Update update); @Override void updateForecaster(String tenant, String metricId,
                                 org.hawkular.datamining.forecast.Forecaster.Update update); @Override void unsubscribeAll(String tenant, String metricId); @Override void unsubscribe(String tenant, String metricId, Subscription.SubscriptionOwner subscriptionOwner); @Override void unsubscribe(String tenant, String metricId, Set<Subscription.SubscriptionOwner> subscriptionOwners); @Override boolean isSubscribed(String tenant, String metricId); @Override Subscription subscription(String tenant, String metricId);  }
@Test public void testUnsubscribe() { SubscriptionManager subscriptionManager = new InMemorySubscriptionManager(new EmptyMetricsClient()); try { subscriptionManager.subscription(tenant, metricId); Assert.fail(); } catch (SubscriptionNotFoundException ex) { } Subscription expected = createSubscription(tenant, metricId); subscriptionManager.subscribe(expected); Subscription got = subscriptionManager.subscription(tenant, metricId); Assert.assertEquals(expected, got); subscriptionManager.unsubscribe(tenant, metricId, Subscription.SubscriptionOwner.getAllDefined()); Assert.assertFalse(subscriptionManager.isSubscribed(tenant, metricId)); try { subscriptionManager.subscription(tenant, metricId); Assert.fail(); } catch (SubscriptionNotFoundException ex) { } }