@Test @Disabled("time-based, non-deterministic") void deregisterQueryTest() throws InterruptedException { try { QueryRegistry queryRegistry = new QueryRegistry.Builder().build(); fail(); } catch (IllegalArgumentException ignored) { } QueryRegistry queryRegistry = new QueryRegistry.Builder().withClientIdPrefix("myPrefix").build(); String targetApp = "myapp"; try { queryRegistry.registerQuery(targetApp, null, "true"); fail(); } catch (Exception ignored) { } try { queryRegistry.registerQuery(targetApp, "subId", null); fail(); } catch (Exception ignored) { } queryRegistry.registerQuery(targetApp, "subId", "true"); List<MantisServerSubscription> currentSubs = queryRegistry.getCurrentSubscriptionsForApp(targetApp); assertEquals(1, currentSubs.size()); queryRegistry.deregisterQuery(targetApp, "subId", "true"); Thread.sleep(500); currentSubs = queryRegistry.getCurrentSubscriptionsForApp(QueryRegistry.ANY); assertEquals(0, currentSubs.size()); }
public boolean deregisterQuery(String targetApp, String subId, String query) { appToSubscriptionMap.computeIfPresent(targetApp, (k, v) -> { v.deregisterQuery(subId, query); return v; }); return true; }
QueryRegistry { public boolean deregisterQuery(String targetApp, String subId, String query) { appToSubscriptionMap.computeIfPresent(targetApp, (k, v) -> { v.deregisterQuery(subId, query); return v; }); return true; } }
QueryRegistry { public boolean deregisterQuery(String targetApp, String subId, String query) { appToSubscriptionMap.computeIfPresent(targetApp, (k, v) -> { v.deregisterQuery(subId, query); return v; }); return true; } private  QueryRegistry(String clientIdPrefix); }
QueryRegistry { public boolean deregisterQuery(String targetApp, String subId, String query) { appToSubscriptionMap.computeIfPresent(targetApp, (k, v) -> { v.deregisterQuery(subId, query); return v; }); return true; } private  QueryRegistry(String clientIdPrefix); void registerQuery(String targetApp, String subId, String query); void registerQuery(String targetApp, String subId, String query, Map<String, String> additionalParams, boolean validateQueryAsGroovy); boolean deregisterQuery(String targetApp, String subId, String query); List<MantisServerSubscription> getCurrentSubscriptionsForApp(String app); List<MantisServerSubscription> getCurrentSubscriptions(Map<String, List<String>> queryParams); Map<String, List<MantisServerSubscription>> getAllSubscriptions(); }
QueryRegistry { public boolean deregisterQuery(String targetApp, String subId, String query) { appToSubscriptionMap.computeIfPresent(targetApp, (k, v) -> { v.deregisterQuery(subId, query); return v; }); return true; } private  QueryRegistry(String clientIdPrefix); void registerQuery(String targetApp, String subId, String query); void registerQuery(String targetApp, String subId, String query, Map<String, String> additionalParams, boolean validateQueryAsGroovy); boolean deregisterQuery(String targetApp, String subId, String query); List<MantisServerSubscription> getCurrentSubscriptionsForApp(String app); List<MantisServerSubscription> getCurrentSubscriptions(Map<String, List<String>> queryParams); Map<String, List<MantisServerSubscription>> getAllSubscriptions(); static final String ANY; }