@Test
  public void testGetAdminDashboard() throws Exception {

    int oneMonthUserCount = 5;
    int oneDayUserCount = 5;
    int oneWeekUserCount = 5;

    Date now = new Date();

    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(now);
    // set two weeks back

    cal.add(GregorianCalendar.DATE, -1);
    Date yesterday = cal.getTime();
    long yesterdayOffset = userDao.countByActiveAndCreatedAt(true, yesterday);
    cal.add(GregorianCalendar.DATE, -5);
    Date winOneWeek = cal.getTime();
    cal.add(GregorianCalendar.DATE, -1);
    Date oneWeek = cal.getTime();
    long oneWeekOffset = userDao.countByActiveAndCreatedAt(true, oneWeek);
    cal.add(GregorianCalendar.DATE, -22);
    Date winOneMonth = cal.getTime();

    cal.add(GregorianCalendar.DATE, -2);
    Date oneMonth = cal.getTime();
    cal.add(GregorianCalendar.YEAR, -20);
    Date effectivelyForever = cal.getTime();

    long oneMonthOffset = userDao.countByActiveAndCreatedAt(true, oneMonth);
    long foreverOffset = userDao.countByActiveAndCreatedAt(true, effectivelyForever);

    long baseMonthUsers = oneMonthUserCount + oneWeekUserCount + oneDayUserCount;
    long baseWeekUsers = oneWeekUserCount + oneDayUserCount;

    ArrayList<User> allUsers = new ArrayList<>();
    logger.info("oneMonthUserCount:" + winOneMonth.getTime());
    logger.info("oneWeekUserCount:" + winOneWeek.getTime());
    logger.info("oneDayUserCount:" + now.getTime());
    allUsers.addAll(
        createUsers(
            winOneMonth, "fakedomain1.com", "first", "last", "password", oneMonthUserCount));
    allUsers.addAll(
        createUsers(winOneWeek, "fakedomain2.com", "first", "last", "password", oneWeekUserCount));
    allUsers.addAll(
        createUsers(now, "fakedomain3.com", "first", "last", "password", oneDayUserCount));

    loginAdminUser();
    userDao.save(allUsers);
    for (User user : allUsers) {
      logger.info("oneMonthUserCount:" + winOneMonth + ",millis:" + winOneMonth.getTime());
      logger.info("oneWeekUserCount:" + winOneWeek + ",millis:" + winOneWeek.getTime());
      logger.info("oneDayUserCount:" + now + ",millis:" + now.getTime());
      logger.info(
          "user["
              + user.getUsername()
              + "] createdAt:"
              + user.getCreatedAt()
              + " , millis:"
              + user.getCreatedAt().getTime());
    }
    Region region = regionDao.findById(1L);

    /*
     * TRIALS SECTION
     */
    List<Product> productsForTrial = productDao.findByTrialsAvailable(true);
    ArrayList<Long> validTrialProductIds = new ArrayList<>();
    for (Product product : productsForTrial) {

      ProductVersion productVersion = pickOne(product.getProductVersions(), region, false);

      if (productVersion == null) {
        continue;
      }
      validTrialProductIds.add(product.getId());

      HashSet<Long> dates = new HashSet<>();

      for (User user : allUsers) {
        loginAdminUser();
        dates.add(user.getCreatedAt().getTime());
        activateTrial(user.getUsername(), product);
        DeployRequestDto deployRequestDto =
            this.getTrialRequestFor(user, productVersion, region, user.getCreatedAt());
        login(user.getUsername(), "password");

        DeploymentStackDto retDto =
            deploymentService.deployMultipleProducts(getRequestStub(), deployRequestDto);
        TrialInstance instance = trialInstanceDao.findById(retDto.getId());
        assertEquals(instance.getCreatedAt(), user.getCreatedAt());
      }
      assertEquals(3, dates.size());
    }
    // END TRIALS SECTION

    /*
     *
     * DO DEPLOYMENTS
     * SECTION
     */

    loginAdminUser();

    // need something there :)
    addAWSCredentials(allUsers);
    // NEED TO VARY.  For now, we will do this with all products for everyone
    List<Long[]> productAndVersionIdList =
        this.getDtoProdAndVersionList(productDao.findAll(), region);
    int badUsers = 0;
    for (User user : allUsers) {
      AmazonCredentials amazonCredentials =
          amazonCredentialsDao.findByUserAndName(user, "Dummy Key");
      if (amazonCredentials == null) {
        badUsers++;
        continue;
      }
      loginAdminUser();
      activateDeploys(user, productAndVersionIdList);
      login(user.getUsername(), "password");
      DeployRequestDto reqDto =
          this.getDeployRequestFor(
              user, productAndVersionIdList, region, amazonCredentials, user.getCreatedAt());
      DeploymentStackDto result =
          deploymentService.deployMultipleProducts(getRequestStub(), reqDto);
      DeploymentStack stack = deploymentStackDao.findById(result.getId());
      assertEquals(
          "User and stack created at times should be ==",
          user.getCreatedAt(),
          stack.getCreatedAt());
    }
    assertEquals(0, badUsers);

    // END DO DEPLOYMENTS SECTION

    /*
     * TESTING THE RETURN
     */
    loginAdminUser();
    DashboardDto dashboardDto = dashboardService.getAdminDashboard();
    assertEquals(
        "Compare what trial count should be",
        (long) (validTrialProductIds.size() * allUsers.size()),
        (long) dashboardDto.getActiveInfor24());
    assertEquals(
        "Compare all users", foreverOffset + allUsers.size(), (long) dashboardDto.getUsersTotal());
    assertEquals(
        "Compare all time deployment count",
        (long) allUsers.size(),
        (long) dashboardDto.getAllTimeAws());
    assertEquals(
        "Compare all time trial count",
        (long) (validTrialProductIds.size() * allUsers.size()),
        (long) dashboardDto.getAllTimeInfor24());
    for (Long[] ids : productAndVersionIdList) {

      // SPECIFIC day/week/month checks for products
      assertEquals(
          "Compare deploy counts for day/productId:" + ids[0],
          (long) oneDayUserCount,
          (long) dashboardDto.getDay().getAwsDeploymentsByProduct().get(ids[0]));
      assertEquals(
          "Compare deploy counts for week/productId:" + ids[0],
          baseWeekUsers,
          (long) dashboardDto.getWeek().getAwsDeploymentsByProduct().get(ids[0]));
      assertEquals(
          "Compare deploy counts for month/productId:" + ids[0],
          baseMonthUsers,
          (long) dashboardDto.getMonth().getAwsDeploymentsByProduct().get(ids[0]));
      assertEquals(
          "Compare all time deploy counts for productId:" + ids[0],
          (long) allUsers.size(),
          (long) dashboardDto.getActiveAwsByProduct().get(ids[0]));
    }

    List<ProductCountDto> prodCountDtos = trialInstanceDao.countByCreatedAtAfter(yesterday);
    for (ProductCountDto count : prodCountDtos) {
      logger.info("prod-id:" + count.getProductId() + ",count:" + count.getCount());
    }

    int processed = 0;
    for (Long productId : validTrialProductIds) {
      assertEquals(
          "Compare counts for productId:" + productId,
          (long) allUsers.size(),
          (long) dashboardDto.getActiveInfor24ByProduct().get(productId));
      // SPECIFIC day/week/month checks for products
      assertEquals(
          "Compare trial counts for day/productId:"
              + productId
              + ",shortName:"
              + productDao.findById(productId).getShortName()
              + ",processed already:"
              + processed,
          (long) oneDayUserCount,
          (long) dashboardDto.getDay().getInfor24DeploymentsByProduct().get(productId));
      assertEquals(
          "Compare trial counts for week/productId:" + productId,
          baseWeekUsers,
          (long) dashboardDto.getWeek().getInfor24DeploymentsByProduct().get(productId));
      assertEquals(
          "Compare trial counts for month/productId:" + productId,
          baseMonthUsers,
          (long) dashboardDto.getMonth().getInfor24DeploymentsByProduct().get(productId));
      processed++;
    }

    assertEquals(
        "Compare users added since day",
        yesterdayOffset + oneDayUserCount,
        (long) dashboardDto.getDay().getNewUsersCount());
    assertEquals(
        "Compare users added since week",
        oneWeekOffset + baseWeekUsers,
        (long) dashboardDto.getWeek().getNewUsersCount());
    assertEquals(
        "Compare users added since day",
        oneMonthOffset + baseMonthUsers,
        (long) dashboardDto.getMonth().getNewUsersCount());
  }