Coverage Report - org.paneris.jammyjoes.controller.Competition
 
Classes in this File Line Coverage Branch Coverage Complexity
Competition
0%
0/22
0%
0/2
3
 
 1  
 package org.paneris.jammyjoes.controller;
 2  
 
 3  
 import org.melati.Melati;
 4  
 import org.melati.servlet.Form;
 5  
 import org.melati.template.ServletTemplateContext;
 6  
 import org.melati.util.Email;
 7  
 import org.paneris.jammyjoes.model.JammyjoesDatabase;
 8  
 import org.paneris.jammyjoes.model.User;
 9  
 import org.paneris.jammyjoes.servlet.JammyJoesMelatiServlet;
 10  
 
 11  0
 public class Competition extends JammyJoesMelatiServlet {
 12  
 
 13  
   private static final long serialVersionUID = 1L;
 14  
 
 15  
   protected String jammyjoesRequest(Melati melati, ServletTemplateContext context)
 16  
       throws Exception {
 17  
         
 18  0
     JammyjoesDatabase db = (JammyjoesDatabase) melati.getDatabase();
 19  0
     ServletTemplateContext tc = melati.getServletTemplateContext();
 20  0
     String template = "view/CompetitionSuccess.wm";
 21  0
     String email = Form.getFormNulled(tc,"email");
 22  0
     String wantspam = Form.getFormNulled(tc,"wantspam");
 23  0
     User admin = (User)db.getUserTable().administratorUser();
 24  0
     String message = email + " would like to be entered for the competition.\n\n";
 25  0
     String custMessage = "Thank you for entering the competition to win a Zingy Pingy Bee.";
 26  0
     custMessage += "  You will be notified if you have won in early August.\n\n";
 27  0
     if (wantspam != null) {
 28  0
       message += "They would also like to receive occasional emails from JammyJoes.\n";
 29  0
       custMessage += "You will also receive occasional emails from JammyJoes.\n";
 30  
     } else {
 31  0
       message += "They would NOT like to receive occasional emails from JammyJoes.\n";
 32  0
       custMessage += "You will NOT receive any further emails from JammyJoes (unless you win :).\n";
 33  
     }
 34  0
     custMessage += "\nGood luck.\n\nJenny and Dee\n";
 35  
     try {
 36  0
       Email.send(db.getSettingTable().get(Email.SMTPSERVER), email, admin.getEmail(), "", "JammyJoes Competition", message);
 37  0
       Email.send(db.getSettingTable().get(Email.SMTPSERVER), admin.getEmail(), email, "", "JammyJoes Competition", custMessage);
 38  0
     } catch (Exception e) {
 39  0
       context.put("error","Sorry! I couldn't send this email because: " + e);
 40  0
     }
 41  0
     return template;
 42  
   }
 43  
  }