SubscriptionsManager { @UiThread public void addSubscription(String type, String subType, String id) { try { latch.await(); final Map<String, Set<String>> typeMap = getType(type); final Set<String> values = getSet(typeMap, subType); values.add(id); saveSubscriptions(); } catch (InterruptedException e) { e.printStackTrace(); } } SubscriptionsManager(Context context); @UiThread void addSubscription(String type, String subType, String id); @UiThread void removeSubscription(String type, String subType, String id); boolean isSubscribed(String type, String subtype, String value); @UiThread void resetSubscriptions();  }
@Test(timeout = 10000L) public void itStoresTheSubscriptions() throws InterruptedException, IOException { final String subscriptionLine = String.format(Locale.US, "%s|%s|%s", SOCCER, TEAM, TEAM_ID); mSubscriptionsManager.addSubscription(SOCCER, TEAM, TEAM_ID); while (true) { try { assertTrue(SUBSCRIPTIONS_FILE.exists()); break; } catch (AssertionError e) { Thread.sleep(200); } } final BufferedReader reader = new BufferedReader(new FileReader(SUBSCRIPTIONS_FILE)); final String line = reader.readLine(); Utils.close(reader); assertNotNull(line); assertEquals(subscriptionLine, line); }