1 package org.kuali.ole.deliver.loan;
2
3 import org.junit.After;
4 import org.junit.Before;
5 import org.junit.Test;
6 import org.junit.runner.RunWith;
7 import org.kuali.incubator.SolrRequestReponseHandler;
8 import org.kuali.ole.deliver.loan.bo.OleLoanFastAdd;
9 import org.kuali.ole.docstore.model.xmlpojo.work.instance.oleml.Item;
10 import org.kuali.ole.deliver.loan.LoanProcessor;
11 import org.kuali.ole.pojo.bib.BibliographicRecord;
12 import org.kuali.ole.service.OleDeliveryDocstoreService;
13 import org.kuali.ole.service.impl.OleDeliveryDocstoreServiceImpl;
14 import org.kuali.rice.krad.UserSession;
15 import org.kuali.rice.krad.util.GlobalVariables;
16 import org.springframework.test.context.ContextConfiguration;
17 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
18 import org.springframework.test.context.transaction.TransactionConfiguration;
19
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23
24 import static junit.framework.Assert.assertNotNull;
25 import static junit.framework.Assert.assertNull;
26
27
28
29
30
31
32
33
34
35 @ContextConfiguration(locations = {"classpath:/SpringBeans.xml"})
36 @RunWith(value = SpringJUnit4ClassRunner.class)
37 @TransactionConfiguration(defaultRollback = true)
38 public class OleDeliveryDocstoreService_UT {
39
40 private SolrRequestReponseHandler solrRequestReponseHandler;
41 private OleDeliveryDocstoreService oleDeliveryDocstoreService;
42 private LoanProcessor loanProcessor;
43
44 @After
45 public void tearDown() throws Exception {
46 oleDeliveryDocstoreService = null;
47 loanProcessor = null;
48 }
49
50 @Before
51 public void setUp() throws Exception {
52 oleDeliveryDocstoreService = new OleDeliveryDocstoreServiceImpl();
53 loanProcessor = new LoanProcessor();
54 GlobalVariables.setUserSession(new UserSession("admin"));
55 GlobalVariables.getUserSession().getPrincipalId();
56 }
57
58 @Test
59 public void getOleItemSearchList() throws Exception {
60
61 BibliographicRecord bibliographicRecord=getBibliographicRecord();
62 assertNotNull(bibliographicRecord);
63 Item itemRecord=getItem();
64 assertNotNull(itemRecord);
65 String result = oleDeliveryDocstoreService.persistNewToDocstoreForIngest(bibliographicRecord, itemRecord);
66 assertNotNull(result);
67
68 Map searchCriteria = new HashMap();
69 searchCriteria.put("itemBarCode","123456789");
70 searchCriteria.put("title","Asd");
71 searchCriteria.put("author","");
72 searchCriteria.put("publisher","");
73 searchCriteria.put("callNumber","");
74 searchCriteria.put("itemType","");
75 assertNotNull(searchCriteria);
76
77 List results = oleDeliveryDocstoreService.getOleItemSearchList(searchCriteria);
78 assertNotNull(results);
79 }
80
81 @Test
82 public void persistNewToDocstoreForIngest() throws Exception{
83
84
85 BibliographicRecord bibliographicRecord=getBibliographicRecord();
86 assertNotNull(bibliographicRecord);
87 Item itemRecord=getItem();
88 assertNotNull(itemRecord);
89 String result = oleDeliveryDocstoreService.persistNewToDocstoreForIngest(bibliographicRecord, itemRecord);
90 assertNotNull(result);
91 }
92
93 public Item getItem(){
94
95 OleLoanFastAdd oleLoanFastAdd = new OleLoanFastAdd();
96 oleLoanFastAdd.setCirculationLocation("Fort Wayne Library");
97 oleLoanFastAdd.setShelvingLocation("Stacks");
98 oleLoanFastAdd.setItemType("BOOK");
99 oleLoanFastAdd.setCallNumber("123456");
100 oleLoanFastAdd.setCallNumberType("Test");
101 oleLoanFastAdd.setCopyNumber("54321");
102 oleLoanFastAdd.setEnumeration("2345678");
103 oleLoanFastAdd.setCheckinNote("Test Check Note");
104 oleLoanFastAdd.setNote("Test Note");
105 oleLoanFastAdd.setBarcode("123456789");
106 oleLoanFastAdd.setItemStatus("Available");
107 oleLoanFastAdd.setCopyNumber("44444444");
108
109 assertNotNull(oleLoanFastAdd);
110
111 Item itemRecord = loanProcessor.getItemRecord(oleLoanFastAdd);
112 return itemRecord;
113 }
114
115 public BibliographicRecord getBibliographicRecord(){
116
117 String title = "The Legend";
118 assertNotNull(title);
119 BibliographicRecord bibliographicRecord = loanProcessor.getBibliographicRecord(title);
120
121 return bibliographicRecord;
122
123 }
124 }