@Test
  public void getDaysToExpiryOnPerpetualLicense() {
    mockLicense.setExpiryDate(null);
    mockLicense.setEvaluation(false);

    assertEquals(Integer.MAX_VALUE, licenseDetails.getDaysToLicenseExpiry());
  }
 @Test
 public void testGetLicenseExpiryStatusMessageForNonExpiredEvaluation() {
   mockLicense.setEvaluation(true);
   mockLicense.setExpiryDate(tenSecondsFromNow);
   mockLicense.setExpired(false);
   assertExpiryMessageContains("admin.license.expiresin");
 }
 @Test
 public void testGetLicenseStatusMessageEvaluationNotAlmostExpired() {
   // not expired
   mockLicense.setEvaluation(true);
   mockLicense.setExpiryDate(tenDaysFromNow);
   assertNull(licenseDetails.getLicenseStatusMessage(fred, ""));
 }
  @Test
  public void getDaysToExpiryOnEvaluationLicense() {
    mockLicense.setExpiryDate(tenDaysFromNow);
    mockLicense.setEvaluation(true);

    // License expires in exactly 10 days.
    assertEquals(10, licenseDetails.getDaysToLicenseExpiry());

    // License expires in exactly 10 days + 1 ms.
    mockLicense.setExpiryDate(new Date(tenDaysFromNow.getTime() + 1));
    assertEquals(10, licenseDetails.getDaysToLicenseExpiry());

    // License expires in exactly 10 days - 1 ms.
    mockLicense.setExpiryDate(new Date(tenDaysFromNow.getTime() - 1));
    assertEquals(9, licenseDetails.getDaysToLicenseExpiry());

    // License expires now.
    mockLicense.setExpiryDate(now);
    assertEquals(0, licenseDetails.getDaysToLicenseExpiry());

    // License expires 1ms into the future.
    mockLicense.setExpiryDate(new Date(now.getTime() + 1));
    assertEquals(0, licenseDetails.getDaysToLicenseExpiry());

    // License expired 1ms ago.
    mockLicense.setExpiryDate(new Date(now.getTime() - 1));
    assertEquals(-1, licenseDetails.getDaysToLicenseExpiry());

    // License expired a long time ago.
    mockLicense.setExpiryDate(twentyFourDaysAgo);
    mockLicense.setEvaluation(true);

    // License expired exactly 24 days ago.
    assertEquals(-24, licenseDetails.getDaysToLicenseExpiry());

    // License expired exactly 1ms later than 24 days ago.
    mockLicense.setExpiryDate(new Date(twentyFourDaysAgo.getTime() + 1));
    assertEquals(-24, licenseDetails.getDaysToLicenseExpiry());

    // License expired exactly 1ms earlier than 24 days ago.
    mockLicense.setExpiryDate(new Date(twentyFourDaysAgo.getTime() - 1));
    assertEquals(-25, licenseDetails.getDaysToLicenseExpiry());
  }
 @Test
 public void testGetLicenseStatusMessageEvaluationAlmostExpired() {
   // almost expired
   mockLicense.setEvaluation(true);
   mockLicense.setExpiryDate(tenSecondsFromNow);
   assertTrue(
       licenseDetails
           .getLicenseStatusMessage(fred, "")
           .contains("admin.license.evaluation.almost.expired"));
 }
  @Test
  public void testGetLicenseExpiryStatusMessageForExpiredEvaluation() {
    mockLicense.setEvaluation(true);
    mockLicense.setExpiryDate(now);
    mockLicense.setExpired(true);

    applicationProperties.setOption(APKeys.JIRA_CONFIRMED_INSTALL_WITH_OLD_LICENSE, true);

    assertExpiryMessageContains("admin.license.expired");
  }
  @Test
  public void testGetLicenseStatusMessageEvaluation() {
    mockLicense.setEvaluation(true);
    mockLicense.setExpiryDate(now);
    mockLicense.setExpired(true);

    // expired
    assertTrue(
        licenseDetails
            .getLicenseStatusMessage(fred, "")
            .contains("admin.license.evaluation.expired"));
  }
 @Test
 public void testIsNotAlmostExpiredEvaluation() throws Exception {
   mockLicense.setEvaluation(true);
   mockLicense.setExpiryDate(tenDaysFromNow);
   assertFalse(licenseDetails.isLicenseAlmostExpired());
 }
 @Test
 public void testGetMaintenanceEndStringEvaluation() {
   mockLicense.setEvaluation(true);
   mockLicense.setExpiryDate(now);
   assertEquals(now.toString(), licenseDetails.getMaintenanceEndString(OUTLOOK_DATE));
 }
 @Test
 public void testGetBriefMaintenanceStatusMessageForExpiredEvaluationLicense() {
   mockLicense.setEvaluation(true);
   mockLicense.setExpired(true);
   assertBriefMaintenanceMessageContains("supported.expired");
 }