@Test
  public void cacheAndReset() {

    Map<String, Integer> stats = service.getSummaryStats();

    assertThat(stats.get("approvalCount"), is(4));
    assertThat(stats.get("userCount"), is(2));
    assertThat(stats.get("clientCount"), is(3));

    Mockito.when(approvedSiteService.getAll())
        .thenReturn(Sets.newHashSet(ap1, ap2, ap3, ap4, ap5, ap6));

    Map<String, Integer> stats2 = service.getSummaryStats();

    // cache should remain the same due to memoized functions
    assertThat(stats2.get("approvalCount"), is(4));
    assertThat(stats2.get("userCount"), is(2));
    assertThat(stats2.get("clientCount"), is(3));

    // reset the cache and make sure the count goes up
    service.resetCache();

    Map<String, Integer> stats3 = service.getSummaryStats();

    assertThat(stats3.get("approvalCount"), is(6));
    assertThat(stats3.get("userCount"), is(2));
    assertThat(stats3.get("clientCount"), is(4));
  }
  @Test
  public void countForClientId() {

    assertThat(service.getCountForClientId(1L), is(2));
    assertThat(service.getCountForClientId(2L), is(1));
    assertThat(service.getCountForClientId(3L), is(1));
    assertThat(service.getCountForClientId(4L), is(0));
  }
  @Test
  public void calculateSummaryStats() {
    Map<String, Integer> stats = service.getSummaryStats();

    assertThat(stats.get("approvalCount"), is(4));
    assertThat(stats.get("userCount"), is(2));
    assertThat(stats.get("clientCount"), is(3));
  }
  @Test
  public void calculateByClientId() {

    Map<Long, Integer> stats = service.getByClientId();

    assertThat(stats.get(1L), is(2));
    assertThat(stats.get(2L), is(1));
    assertThat(stats.get(3L), is(1));
    assertThat(stats.get(4L), is(0));
  }
  @Test
  public void calculateSummaryStats_empty() {

    Mockito.when(approvedSiteService.getAll()).thenReturn(new HashSet<ApprovedSite>());

    Map<String, Integer> stats = service.getSummaryStats();

    assertThat(stats.get("approvalCount"), is(0));
    assertThat(stats.get("userCount"), is(0));
    assertThat(stats.get("clientCount"), is(0));
  }
  @Test
  public void calculateByClientId_empty() {

    Mockito.when(approvedSiteService.getAll()).thenReturn(new HashSet<ApprovedSite>());

    Map<Long, Integer> stats = service.getByClientId();

    assertThat(stats.get(1L), is(0));
    assertThat(stats.get(2L), is(0));
    assertThat(stats.get(3L), is(0));
    assertThat(stats.get(4L), is(0));
  }