001package org.kuali.ole.deliver.service; 002 003import org.junit.Before; 004import org.junit.Test; 005import org.kuali.ole.OLEConstants; 006import org.kuali.ole.OLEParameterConstants; 007import org.kuali.ole.deliver.bo.OLEDeliverNotice; 008import org.kuali.ole.deliver.bo.OleLoanDocument; 009import org.kuali.ole.deliver.bo.OlePatronDocument; 010import org.kuali.rice.kim.impl.identity.entity.EntityBo; 011import org.kuali.rice.kim.impl.identity.name.EntityNameBo; 012import org.kuali.rice.kim.impl.identity.type.EntityTypeContactInfoBo; 013import org.kuali.rice.krad.service.BusinessObjectService; 014import org.mockito.Mock; 015import org.mockito.Mockito; 016import org.mockito.MockitoAnnotations; 017 018import java.text.SimpleDateFormat; 019import java.util.ArrayList; 020import java.util.List; 021 022import static org.junit.Assert.*; 023 024/** 025 * Created by pvsubrah on 4/6/15. 026 */ 027public class NoticeMailContentFormatterTest { 028 029 @Mock 030 private ParameterValueResolver parameterValueResolver; 031 032 @Mock 033 private OleDeliverRequestDocumentHelperServiceImpl oleDeliverRequestDocumentHelperService; 034 035 @Mock 036 private BusinessObjectService businessObjectService; 037 038 @Before 039 public void setUp() throws Exception { 040 MockitoAnnotations.initMocks(this); 041 } 042 043 044 @Test 045 public void testGenerateMailContent() throws Exception { 046 NoticeMailContentFormatter noticeMailContentFormatter = new MockNoticeMailContentFormatter(); 047 048 Mockito.when(parameterValueResolver.getParameter(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString() 049 )).thenReturn("TITLE"); 050 Mockito.when(parameterValueResolver.getParameter(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) 051 .thenReturn 052 ("CONTENT"); 053 noticeMailContentFormatter.setParameterValueResolver(parameterValueResolver); 054 noticeMailContentFormatter.setOleDeliverRequestDocumentHelperService(oleDeliverRequestDocumentHelperService); 055 noticeMailContentFormatter.setBusinessObjectService(businessObjectService); 056 057 058 OleLoanDocument oleLoanDocument = new OleLoanDocument(); 059 060 OlePatronDocument olePatron = new OlePatronDocument(); 061 olePatron.setBarcode("123125"); 062 EntityBo entity = new EntityBo(); 063 ArrayList<EntityNameBo> entityNameBos = new ArrayList<EntityNameBo>(); 064 EntityNameBo entityNameBo = new EntityNameBo(); 065 entityNameBo.setFirstName("FirtName"); 066 entityNameBos.add(entityNameBo); 067 entity.setNames(entityNameBos); 068 ArrayList<EntityTypeContactInfoBo> entityTypeContactInfos = new ArrayList<EntityTypeContactInfoBo>(); 069 entityTypeContactInfos.add(new EntityTypeContactInfoBo()); 070 entity.setEntityTypeContactInfos(entityTypeContactInfos); 071 olePatron.setEntity(entity); 072 073 oleLoanDocument.setOlePatron(olePatron); 074 075// String mailContent = noticeMailContentFormatter.generateMailContentForPatron(oleLoanDocument); 076 String mailContent = null; 077 System.out.println(mailContent); 078 079 } 080 081 public class MockNoticeMailContentFormatter extends NoticeMailContentFormatter { 082 @Override 083 protected SimpleDateFormat getSimpleDateFormat() { 084 return new SimpleDateFormat(); 085 } 086 087 @Override 088 protected String generateCustomHTML(OleLoanDocument oleLoanDocument) { 089 return ""; 090 } 091 } 092}