View Javadoc
1   package org.kuali.ole.deliver.notice;
2   
3   import org.junit.Test;
4   import org.kuali.ole.OLEConstants;
5   import org.kuali.ole.deliver.batch.OleNoticeBo;
6   import org.kuali.ole.deliver.notice.bo.OleNoticeContentConfigurationBo;
7   import org.kuali.ole.deliver.notice.bo.OleNoticeFieldLabelMapping;
8   import org.kuali.ole.deliver.service.NoticeMailContentFormatter;
9   import org.kuali.ole.deliver.service.OverdueNoticeEmailContentFormatter;
10  
11  import java.util.ArrayList;
12  import java.util.Date;
13  import java.util.List;
14  
15  import static junit.framework.TestCase.assertNotNull;
16  
17  /**
18   * Created by pvsubrah on 9/28/15.
19   */
20  public class OleNoticeContentHandlerTest {
21  
22  
23      @Test
24      public void generateNoticeHTML() throws Exception {
25          NoticeMailContentFormatter noticeMailContentFormatter =  new OverdueNoticeEmailContentFormatter();
26          OleNoticeBo oleNoticeBo = new OleNoticeBo();
27          oleNoticeBo.setPatronName("John Doe");
28          oleNoticeBo.setPatronAddress("123, High Street, MA - 201231");
29          oleNoticeBo.setPatronEmailAddress("j.doe@hotmail.com");
30          oleNoticeBo.setPatronPhoneNumber("712-123-2145");
31  
32          oleNoticeBo.setTitle("History of Mars");
33          oleNoticeBo.setAuthor("Mary Jane");
34          oleNoticeBo.setVolumeNumber("v1.0");
35          oleNoticeBo.setCopyNumber("C1.0");
36          oleNoticeBo.setEnumeration("E1");
37          oleNoticeBo.setChronology("CH1");
38          oleNoticeBo.setNoticeSpecificFooterContent("This is the test footer content for notice");
39          oleNoticeBo.setDueDateString(new Date().toString());
40          oleNoticeBo.setItemShelvingLocation("UC/JRL/GEN");
41          oleNoticeBo.setItemCallNumber("X-123");
42          oleNoticeBo.setItemId("1234");
43          oleNoticeBo.setNoticeSpecificContent("This is a test notice. Please ignore!!");
44          oleNoticeBo.setNoticeTitle("Overdue Notice");
45  
46          OleNoticeBo oleNoticeBo1 = (OleNoticeBo) oleNoticeBo.clone();
47          List<OleNoticeBo> oleNoticeBos = new ArrayList<>();
48          oleNoticeBos.add(oleNoticeBo);
49          oleNoticeBos.add(oleNoticeBo1);
50  
51          OleNoticeContentConfigurationBo oleNoticeContentConfigurationBo = new OleNoticeContentConfigurationBo();
52          oleNoticeContentConfigurationBo.setActive(true);
53          oleNoticeContentConfigurationBo.setNoticeName("Overdue Notice");
54          oleNoticeContentConfigurationBo.setNoticeTitle("Overdue Notice");
55          oleNoticeContentConfigurationBo.setNoticeType("Overdue Notice");
56  
57          ArrayList<OleNoticeFieldLabelMapping> oleNoticeFieldLabelMappings = new ArrayList<>();
58  
59          OleNoticeFieldLabelMapping patronName = new OleNoticeFieldLabelMapping();
60          patronName.setFieldLabel("Patron Full Name");
61          patronName.setFieldName(OLEConstants.PATRON_NAME);
62  
63  
64          OleNoticeFieldLabelMapping address = new OleNoticeFieldLabelMapping();
65          address.setFieldLabel("Patron Address");
66          address.setFieldName(OLEConstants.NOTICE_ADDRESS);
67  
68  
69          OleNoticeFieldLabelMapping phoneNumber = new OleNoticeFieldLabelMapping();
70          phoneNumber.setFieldLabel("Patron Phone Number:");
71          phoneNumber.setFieldName(OLEConstants.NOTICE_PHONE_NUMBER);
72  
73  
74  
75          OleNoticeFieldLabelMapping patronEmail = new OleNoticeFieldLabelMapping();
76          patronEmail.setFieldLabel("Valid Email Id:");
77          patronEmail.setFieldName(OLEConstants.NOTICE_EMAIL);
78  
79  
80          OleNoticeFieldLabelMapping itemCallNum = new OleNoticeFieldLabelMapping();
81          itemCallNum.setFieldLabel("Item Call Number:");
82          itemCallNum.setFieldName(OLEConstants.NOTICE_CALL_NUMBER);
83  
84          OleNoticeFieldLabelMapping title = new OleNoticeFieldLabelMapping();
85          title.setFieldLabel("Item Title:");
86          title.setFieldName(OLEConstants.NOTICE_TITLE);
87  
88          OleNoticeFieldLabelMapping author = new OleNoticeFieldLabelMapping();
89          author.setFieldLabel("Item Author:");
90          author.setFieldName(OLEConstants.NOTICE_AUTHOR);
91  
92          OleNoticeFieldLabelMapping itemBarcode = new OleNoticeFieldLabelMapping();
93          itemBarcode.setFieldLabel("Item Barcode:");
94          itemBarcode.setFieldName(OLEConstants.NOTICE_ITEM_BARCODE);
95  
96          OleNoticeFieldLabelMapping itemDue = new OleNoticeFieldLabelMapping();
97          itemDue.setFieldLabel("Item Due Date");
98          itemDue.setFieldName(OLEConstants.ITEM_WAS_DUE);
99  
100 
101         OleNoticeFieldLabelMapping shelvingLocation = new OleNoticeFieldLabelMapping();
102         shelvingLocation.setFieldLabel("Shelving Location");
103         shelvingLocation.setFieldName(OLEConstants.LIBRARY_SHELVING_LOCATION);
104 
105 
106 
107 
108 
109         oleNoticeFieldLabelMappings.add(patronName);
110         oleNoticeFieldLabelMappings.add(address);
111         oleNoticeFieldLabelMappings.add(phoneNumber);
112         oleNoticeFieldLabelMappings.add(patronEmail);
113         oleNoticeFieldLabelMappings.add(itemCallNum);
114         oleNoticeFieldLabelMappings.add(title);
115         oleNoticeFieldLabelMappings.add(author);
116         oleNoticeFieldLabelMappings.add(itemBarcode);
117         oleNoticeFieldLabelMappings.add(itemDue);
118         oleNoticeFieldLabelMappings.add(shelvingLocation);
119 
120         oleNoticeContentConfigurationBo.setOleNoticeFieldLabelMappings(oleNoticeFieldLabelMappings);
121 
122         String html = noticeMailContentFormatter.generateHTML(oleNoticeBos, oleNoticeContentConfigurationBo);
123         assertNotNull(html);
124         System.out.println(html);
125     }
126 
127 
128 }