1 package org.kuali.ole.deliver.util;
2
3 import org.junit.Before;
4 import org.junit.Test;
5 import org.kuali.ole.deliver.api.OlePatronDefinition;
6 import org.kuali.ole.deliver.api.OlePatronDefintionHelper;
7 import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
8 import org.kuali.ole.deliver.bo.OlePatronDocument;
9 import org.kuali.ole.deliver.service.CircDeskLocationResolver;
10 import org.kuali.ole.service.OlePatronService;
11 import org.kuali.ole.service.OlePatronServiceImpl;
12 import org.kuali.rice.kim.impl.identity.address.EntityAddressBo;
13 import org.kuali.rice.kim.impl.identity.entity.EntityBo;
14 import org.kuali.rice.kim.impl.identity.name.EntityNameBo;
15 import org.kuali.rice.kim.impl.identity.phone.EntityPhoneBo;
16 import org.kuali.rice.kim.impl.identity.type.EntityTypeContactInfoBo;
17 import org.mockito.Mock;
18 import org.mockito.Mockito;
19 import org.mockito.MockitoAnnotations;
20
21 import java.util.*;
22
23 import static junit.framework.Assert.assertNotNull;
24 import static org.junit.Assert.*;
25
26
27
28
29 public class OnHoldCourtesyNoticeUtilTest {
30
31 @Mock
32 private OlePatronDocument mockOlePatronDocument;
33 @Mock
34 private CircDeskLocationResolver mockCircDeskLocationResolver;
35
36 @Before
37 public void setUp() throws Exception {
38 MockitoAnnotations.initMocks(this);
39
40 }
41
42 @Test
43 public void testGenerateRequestMailContentForPatron() throws Exception {
44 EntityBo entityBo = new EntityBo();
45
46 EntityTypeContactInfoBo entityTypeContactInfoBo = new EntityTypeContactInfoBo();
47
48 EntityAddressBo entityAddressBo = new EntityAddressBo();
49 entityAddressBo.setCity("Chennai");
50 entityAddressBo.setCountryCode("India");
51 entityAddressBo.setLine1("MEPZ");
52 entityAddressBo.setLine2("Sanatoriam");
53 entityAddressBo.setLine3("Tambaram");
54 entityAddressBo.setActive(true);
55 entityAddressBo.setDefaultValue(true);
56 List<EntityAddressBo> addresses = new ArrayList<>();
57 addresses.add(entityAddressBo);
58 entityTypeContactInfoBo.setAddresses(addresses);
59
60 EntityPhoneBo entityPhoneBo = new EntityPhoneBo();
61 entityPhoneBo.setExtensionNumber("123456");
62 entityPhoneBo.setPhoneNumber("654321");
63 entityPhoneBo.setPhoneTypeCode("HM");
64 entityPhoneBo.setActive(true);
65 entityPhoneBo.setDefaultValue(true);
66 List<EntityPhoneBo> entityPhoneBos = new ArrayList<>();
67 entityPhoneBos.add(entityPhoneBo);
68 entityTypeContactInfoBo.setPhoneNumbers(entityPhoneBos);
69
70 EntityNameBo entityNameBo = new EntityNameBo();
71 entityNameBo.setFirstName("First Name");
72 entityNameBo.setMiddleName("Middle Name");
73 entityNameBo.setLastName("Last Name");
74 entityNameBo.setActive(true);
75 entityNameBo.setDefaultValue(true);
76 List<EntityNameBo> names = new ArrayList<>();
77 names.add(entityNameBo);
78
79 entityBo.setNames(names);
80
81 entityBo.setEntityTypeContactInfos(Collections.singletonList(entityTypeContactInfoBo));
82
83 Mockito.when(mockOlePatronDocument.getEntity()).thenReturn(entityBo);
84 Mockito.when(mockOlePatronDocument.getOlePatronId()).thenReturn("10001");
85 Mockito.when(mockOlePatronDocument.getBarcode()).thenReturn("60000123");
86 Mockito.when(mockOlePatronDocument.getPatronName()).thenReturn("lastName,FirstName");
87 OlePatronService olePatronService = new OlePatronServiceImpl();
88 OnHoldCourtesyNoticeUtil onHoldCourtesyNoticeUtil = new OnHoldCourtesyNoticeUtil();
89 OleDeliverRequestBo oleDeliverRequestBo = new OleDeliverRequestBo();
90 oleDeliverRequestBo.setRequestId("1");
91 oleDeliverRequestBo.setItemId("101");
92
93 oleDeliverRequestBo.setBorrowerId("100001");
94 oleDeliverRequestBo.setBorrowerBarcode("60000123");
95 oleDeliverRequestBo.setOlePatron(mockOlePatronDocument);
96
97 Map<String,String> fieldLabelMap = new HashMap<>();
98 fieldLabelMap.put("noticeTitle","OnHoldNotice");
99 fieldLabelMap.put("noticeBody"," The following requested item(s) is ready for pick-up and will be held until the expiration date at the location shown below.");
100
101 String mailContent = onHoldCourtesyNoticeUtil.generateRequestMailContentForPatron(oleDeliverRequestBo, fieldLabelMap);
102 assertNotNull(mailContent);
103 System.out.println("Mail Content : \n" + mailContent);
104
105
106 }
107 }