### Question:
QueryRegistry { public void registerQuery(String targetApp, String subId, String query) { registerQuery(targetApp, subId, query, this.emptyMap, false); } 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; }### Answer:
@Test void registerQueryTest() { try { QueryRegistry queryRegistry = new QueryRegistry.Builder().build(); fail(); } catch (IllegalArgumentException ignored) { } QueryRegistry queryRegistry = new QueryRegistry.Builder().withClientIdPrefix("myPrefix").build(); String targetApp = QueryRegistry.ANY; try { queryRegistry.registerQuery(targetApp, null, "true"); fail(); } catch (Exception ignored) { } try { queryRegistry.registerQuery(targetApp, "subId", null); fail(); } catch (Exception ignored) { } queryRegistry.registerQuery("myApp", "subId", "true"); queryRegistry.registerQuery("myApp2", "subId", "false"); List<MantisServerSubscription> currentSubs = queryRegistry.getCurrentSubscriptionsForApp("myApp"); assertEquals(1, currentSubs.size()); List<MantisServerSubscription> currentSubs2 = queryRegistry.getCurrentSubscriptionsForApp("myApp2"); assertEquals(1, currentSubs2.size()); Map<String, List<MantisServerSubscription>> allSubscriptions = queryRegistry.getAllSubscriptions(); assertEquals(2, allSubscriptions.size()); assertTrue(allSubscriptions.containsKey("myApp")); assertTrue(allSubscriptions.containsKey("myApp2")); }