public void testCreateNew() throws Throwable {
   String result = this.executeNew("mainEditor", "");
   assertEquals("voidTypeCode", result);
   result = this.executeNew("mainEditor", "PER");
   assertEquals(Action.SUCCESS, result);
   UserNewMessageAction action = (UserNewMessageAction) this.getAction();
   Message message = action.getMessage();
   assertEquals("PER", message.getTypeCode());
 }
  public void testSend() throws Throwable {
    String result = this.executeNew(SystemConstants.GUEST_USER_NAME, "PER");
    assertEquals(Action.SUCCESS, result);
    Map<String, String> params = new HashMap<String, String>();
    result = this.executeSend(SystemConstants.GUEST_USER_NAME, params);
    assertEquals("expiredMessage", result);

    params.put("typeCode", "PER");
    result = this.executeSend(SystemConstants.GUEST_USER_NAME, params);
    assertEquals(Action.INPUT, result);
    UserNewMessageAction action = (UserNewMessageAction) this.getAction();
    Collection<String> fieldErrors = action.getFieldErrors().keySet();
    assertEquals(4, fieldErrors.size());
    assertTrue(fieldErrors.contains("Name"));
    assertTrue(fieldErrors.contains("Surname"));
    assertTrue(fieldErrors.contains("eMail"));
    assertTrue(fieldErrors.contains("Note"));

    params.put("Name", "MyName");
    params.put("Surname", "MySurname");
    params.put("Note", "MyNote");
    params.put("eMail", "*****@*****.**");
    result = this.executeSend(SystemConstants.GUEST_USER_NAME, params);
    assertEquals(Action.SUCCESS, result);
    List<String> messagesId = this._messageManager.loadMessagesId(null);
    assertEquals(1, messagesId.size());
    Message message = this._messageManager.getMessage(messagesId.get(0));
    assertEquals(SystemConstants.GUEST_USER_NAME, message.getUsername());

    params.put("eMail", "MyEmail");
    result = this.executeNew("mainEditor", "PER");
    assertEquals(Action.SUCCESS, result);
    result = this.executeSend(SystemConstants.GUEST_USER_NAME, params);
    assertEquals(Action.INPUT, result);
    fieldErrors = this.getAction().getFieldErrors().keySet();
    assertEquals(1, fieldErrors.size());
    assertTrue(fieldErrors.contains("eMail"));
    messagesId = this._messageManager.loadMessagesId(null);
    assertEquals(1, messagesId.size());

    result = this.executeNew("mainEditor", "PER");
    assertEquals(Action.SUCCESS, result);
    params.put("eMail", "*****@*****.**");
    result = this.executeSend("mainEditor", params);
    assertEquals(Action.SUCCESS, result);

    EntitySearchFilter[] filters =
        new EntitySearchFilter[] {
          new EntitySearchFilter(
              IMessageSearcherDAO.USERNAME_FILTER_KEY, false, "mainEditor", false)
        };
    messagesId = this._messageManager.loadMessagesId(filters);
    assertEquals(1, messagesId.size());
    message = this._messageManager.getMessage(messagesId.get(0));
    assertEquals("mainEditor", message.getUsername());
  }