View Javadoc

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