Ejemplo n.º 1
0
  @Test
  public void testRequestTrialApprove() {
    final MockHttpServletRequest requestStub = super.getRequestStub();

    List<ProductVersion> productVersions = new ArrayList<ProductVersion>();

    productVersions.add(
        productVersionDao.findByProductAndName(productDao.findByShortName("EAM"), "EAM-BC-3"));
    productVersions.add(
        productVersionDao.findByProductAndName(productDao.findByShortName("XM"), "XM-BC-3"));
    User user = userDao.findByUsername(testUserName);
    Region region = regionDao.findById(2L);
    Locale locale = Locale.US;
    String comment = "Test comment.";

    final NullEmailProvider emailProvider = new NullEmailProvider();
    trialEmailComponent.setEmailProvider(emailProvider);

    TrialRequest trialRequest =
        trialService.requestTrial(requestStub, productVersions, user, region, locale, comment);
    List<NullEmailProvider.EmailInfo> asyncEmails = emailProvider.getAsyncEmails();
    assertEquals("Verify email count", 2, asyncEmails.size());
    NullEmailProvider.EmailInfo emailInfo = asyncEmails.get(0);
    assertEquals(
        messageProvider.getMessage(
            StringDefs.MESSAGE_TRIAL_REQUEST_SUBJECT,
            trialEmailComponent.productNamesStrungForEmail(productVersions)),
        emailInfo.subject);
    assertTrue(
        emailInfo.text.contains(
            "Products: " + trialEmailComponent.productNamesStrungForEmail(productVersions)));
    assertTrue(emailInfo.text.contains("User: "******"Comment: " + comment));
    assertTrue(emailInfo.text.contains("Region: " + region.getName()));
    assertEquals(StringDefs.BC_LEADS_EMAIL, emailInfo.address);
    String done = trialService.approveTrialRequest(requestStub, trialRequest.getRequestKey());
    assertEquals("Done", done);

    try {
      trialService.deleteTrialRequest(trialRequest.getRequestKey());
      fail("Delete should fail, as it has already been deleted.");
    } catch (DataAccessException dae) {
      // eat.
    }
  }
Ejemplo n.º 2
0
  @Test
  public void testRequestTrialSize() {

    final MockHttpServletRequest requestStub = super.getRequestStub();
    List<ProductVersion> productVersions = new ArrayList<ProductVersion>();
    productVersions.add(
        productVersionDao.findByProductAndName(productDao.findByShortName("EAM"), "EAM-BC-3"));
    User user = userDao.findByUsername(testUserName);
    Region region = regionDao.findById(1L);
    Locale locale = Locale.US;
    String comment = "Test comment.";

    final NullEmailProvider emailProvider = new NullEmailProvider();
    trialEmailComponent.setEmailProvider(emailProvider);

    TrialRequest trialRequest =
        trialService.requestTrial(requestStub, productVersions, user, region, locale, comment);

    List<NullEmailProvider.EmailInfo> asyncEmails = emailProvider.getAsyncEmails();
    assertEquals(2, asyncEmails.size());
    NullEmailProvider.EmailInfo emailInfo = asyncEmails.get(0);
    assertEquals(
        messageProvider.getMessage(
            StringDefs.MESSAGE_TRIAL_REQUEST_SUBJECT,
            trialEmailComponent.productNamesStrungForEmail(productVersions)),
        emailInfo.subject);
    assertTrue(
        emailInfo.text.contains(
            "Products: " + trialEmailComponent.productNamesStrungForEmail(productVersions)));
    assertTrue(emailInfo.text.contains("User: "******"Comment: " + comment));
    assertTrue(emailInfo.text.contains("Region: " + region.getName()));
    logger.debug("\n----- EMAIL BODY --- \n" + emailInfo.text + "\n---------------");

    loginAdminUser();

    assertEquals(1, trialService.getTrialRequests().size());
    trialService.deleteTrialRequest(trialRequest.getRequestKey());
    assertEquals(0, trialService.getTrialRequests().size());
  }