コード例 #1
0
  @Test
  public void executeFromManageItems() throws ServletException, IOException {
    final Site site = TestUtil.createSite();
    TestUtil.createUserAndUserOnSiteRightAndLogin(site, SiteAccessLevel.ADMINISTRATOR);

    final ContactUs contactUs = TestUtil.createContactUs(site);

    final CreateContactUsWidgetRequest request = new CreateContactUsWidgetRequest();
    request.setContactUsName("name");
    request.setDisplayHeader(true);
    request.setEmail("[email protected]");
    request.setHeader("header");
    request.setContactUsId(contactUs.getId());

    DraftFormItem item = new DraftFormItem();
    item.setPosition(0);
    item.setRequired(true);
    item.setFormItemName(FormItemName.FIRST_NAME);
    ServiceLocator.getPersistance().putFormItem(item);
    List<DraftFormItem> items = new ArrayList<DraftFormItem>();
    items.add(item);
    request.setFormItems(items);

    final FunctionalWidgetInfo response = service.execute(request);

    Assert.assertNotNull(response);
    Assert.assertNull(response.getWidget());
    Assert.assertEquals("name", contactUs.getName());
    Assert.assertEquals("header", contactUs.getDescription());
    Assert.assertTrue(contactUs.isShowDescription());
    Assert.assertEquals(FormType.CONTACT_US, contactUs.getType());
  }
コード例 #2
0
  @Test(expected = InvalidContactUsEmailException.class)
  public void executeWithoutEmail() throws ServletException, IOException {
    final Site site = TestUtil.createSite();
    TestUtil.createUserAndUserOnSiteRightAndLogin(site, SiteAccessLevel.ADMINISTRATOR);

    final ContactUs contactUs = TestUtil.createContactUs(site);

    final CreateContactUsWidgetRequest request = new CreateContactUsWidgetRequest();
    request.setContactUsName("name");
    request.setDisplayHeader(true);
    request.setEmail(null);
    request.setHeader("header");
    request.setContactUsId(contactUs.getId());

    DraftFormItem item = new DraftFormItem();
    item.setPosition(0);
    item.setRequired(true);
    item.setFormItemName(FormItemName.FIRST_NAME);
    ServiceLocator.getPersistance().putFormItem(item);
    List<DraftFormItem> items = new ArrayList<DraftFormItem>();
    items.add(item);
    request.setFormItems(items);

    service.execute(request);
  }