@Override
 public void process(ActionMessage msg) throws Exception {
   try {
     if (!isConnected()) {
       connect(msg.getAction().getProperties());
     }
     send(msg.getAction(), Boolean.parseBoolean(detail));
     msgLog.infoActionReceived("irc", msg.toString());
     Action successAction = msg.getAction();
     successAction.setResult(MESSAGE_PROCESSED);
     sendResult(successAction);
   } catch (Exception e) {
     Action failedAction = msg.getAction();
     failedAction.setResult(MESSAGE_FAILED);
     sendResult(failedAction);
   }
 }
  @Test
  public void writeOpenEmailTest() throws Exception {
    Alert openAlert = WebContainerPendingRequestsData.getOpenAlert();

    Action openAction = new Action(openAlert.getTriggerId(), "email", "email-to-test", openAlert);

    openAction.setProperties(properties);
    ActionMessage openMessage = new TestActionMessage(openAction);

    Message email = plugin.createMimeMessage(openMessage);
    assertNotNull(email);
    writeEmailFile(email, this.getClass().getSimpleName() + "-1-open.eml");

    plugin.process(openMessage);
    // Test generates 2 messages on the mail server
    assertEquals(2, server.getReceivedMessages().length);
  }
 private void send(Action action, boolean detail) {
   Event e = action.getEvent();
   if (e != null) {
     StringBuilder msg = new StringBuilder();
     msg.append(e.getEventType());
     msg.append(" ");
     msg.append(e.getId());
     msg.append(" at ");
     msg.append(new Date(e.getCtime()).toString());
     conn.doPrivmsg(channel, msg.toString());
     if (detail) {
       conn.doPrivmsg(channel, JsonUtil.toJson(e));
     }
   }
 }