View Javadoc
1   package org.kuali.ole.deliver.service;
2   
3   import org.junit.Before;
4   import org.junit.Test;
5   import org.kuali.ole.OLEConstants;
6   import org.kuali.ole.OLEParameterConstants;
7   import org.kuali.ole.deliver.bo.OLEDeliverNotice;
8   import org.kuali.ole.deliver.bo.OleLoanDocument;
9   import org.kuali.ole.deliver.bo.OlePatronDocument;
10  import org.kuali.rice.kim.impl.identity.entity.EntityBo;
11  import org.kuali.rice.kim.impl.identity.name.EntityNameBo;
12  import org.kuali.rice.kim.impl.identity.type.EntityTypeContactInfoBo;
13  import org.kuali.rice.krad.service.BusinessObjectService;
14  import org.mockito.Mock;
15  import org.mockito.Mockito;
16  import org.mockito.MockitoAnnotations;
17  
18  import java.text.SimpleDateFormat;
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import static org.junit.Assert.*;
23  
24  /**
25   * Created by pvsubrah on 4/6/15.
26   */
27  public class NoticeMailContentFormatterTest {
28  
29      @Mock
30      private ParameterValueResolver parameterValueResolver;
31  
32      @Mock
33      private OleDeliverRequestDocumentHelperServiceImpl oleDeliverRequestDocumentHelperService;
34  
35      @Mock
36      private BusinessObjectService businessObjectService;
37  
38      @Before
39      public void setUp() throws Exception {
40          MockitoAnnotations.initMocks(this);
41      }
42  
43  
44      @Test
45      public void testGenerateMailContent() throws Exception {
46          NoticeMailContentFormatter noticeMailContentFormatter = new MockNoticeMailContentFormatter();
47  
48          Mockito.when(parameterValueResolver.getParameter(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString()
49          )).thenReturn("TITLE");
50          Mockito.when(parameterValueResolver.getParameter(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString()))
51                  .thenReturn
52                          ("CONTENT");
53          noticeMailContentFormatter.setParameterValueResolver(parameterValueResolver);
54          noticeMailContentFormatter.setOleDeliverRequestDocumentHelperService(oleDeliverRequestDocumentHelperService);
55          noticeMailContentFormatter.setBusinessObjectService(businessObjectService);
56  
57  
58          OleLoanDocument oleLoanDocument = new OleLoanDocument();
59  
60          OlePatronDocument olePatron = new OlePatronDocument();
61          olePatron.setBarcode("123125");
62          EntityBo entity = new EntityBo();
63          ArrayList<EntityNameBo> entityNameBos = new ArrayList<EntityNameBo>();
64          EntityNameBo entityNameBo = new EntityNameBo();
65          entityNameBo.setFirstName("FirtName");
66          entityNameBos.add(entityNameBo);
67          entity.setNames(entityNameBos);
68          ArrayList<EntityTypeContactInfoBo> entityTypeContactInfos = new ArrayList<EntityTypeContactInfoBo>();
69          entityTypeContactInfos.add(new EntityTypeContactInfoBo());
70          entity.setEntityTypeContactInfos(entityTypeContactInfos);
71          olePatron.setEntity(entity);
72  
73          oleLoanDocument.setOlePatron(olePatron);
74  
75  //        String mailContent = noticeMailContentFormatter.generateMailContentForPatron(oleLoanDocument);
76          String mailContent = null;
77          System.out.println(mailContent);
78  
79      }
80  
81      public class MockNoticeMailContentFormatter extends NoticeMailContentFormatter {
82          @Override
83          protected SimpleDateFormat getSimpleDateFormat() {
84              return  new SimpleDateFormat();
85          }
86  
87          @Override
88          protected String generateCustomHTML(OleLoanDocument oleLoanDocument) {
89              return "";
90          }
91      }
92  }