View Javadoc
1   package org.kuali.ole.document.rdbms;
2   
3   import org.apache.commons.io.FileUtils;
4   import org.junit.Before;
5   import org.junit.Ignore;
6   import org.junit.Test;
7   import org.junit.runner.RunWith;
8   import org.kuali.ole.base.BaseTestCase;
9   import org.kuali.ole.docstore.document.DocumentManager;
10  import org.kuali.ole.docstore.model.xmlpojo.ingest.Request;
11  import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
12  import org.kuali.ole.docstore.model.xmlpojo.ingest.ResponseDocument;
13  import org.kuali.ole.docstore.model.xstream.ingest.RequestHandler;
14  import org.kuali.ole.docstore.service.BeanLocator;
15  import org.kuali.rice.krad.service.BusinessObjectService;
16  import org.kuali.rice.krad.service.KRADServiceLocator;
17  import org.kuali.rice.krad.service.impl.BusinessObjectServiceImpl;
18  import org.mockito.Mock;
19  import org.mockito.Mockito;
20  import org.mockito.MockitoAnnotations;
21  import org.springframework.test.context.ContextConfiguration;
22  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
23  
24  import java.io.File;
25  import java.util.List;
26  
27  
28  /**
29   * Created with IntelliJ IDEA.
30   * User: ?
31   * Date: 1/4/13
32   * Time: 12:14 PM
33   * To change this template use File | Settings | File Templates.
34   */
35  
36  @Ignore
37  @Deprecated
38  public class RdbmsWorkBibDocumentManager_UT extends BaseTestCase{
39      @Mock
40      private BusinessObjectService businessObjectService;
41  
42      @Before
43      public void setUp() throws Exception{
44          super.setUp();
45          MockitoAnnotations.initMocks(this);
46      }
47  
48  
49      private BusinessObjectService getBusinessObjectService(){
50          if(businessObjectService==null) {
51              businessObjectService = KRADServiceLocator.getBusinessObjectService();
52          }
53          return businessObjectService;
54      }
55    @Test
56    public void testIngest() throws Exception {
57  
58         File file = new File(getClass().getResource("/org/kuali/ole/docstore/discovery/request.xml").toURI());
59         String input = FileUtils.readFileToString(file);
60         RequestHandler rh = new RequestHandler();
61         Request request = rh.toObject(input);
62         List<RequestDocument> requestDocuments = request.getRequestDocuments();
63         RequestDocument requestDocument = requestDocuments.get(0);
64         DocumentManager documentManager=BeanLocator.getDocstoreFactory().getDocumentManager(
65                        requestDocument.getCategory(),requestDocument.getType(),requestDocument.getFormat());
66         ResponseDocument responseDocument=new ResponseDocument();
67        requestDocument.getAdditionalAttributes().getAttributeMap().put("dateEntered","2010-12-12 00:00:00");
68         documentManager.ingest(requestDocument,getBusinessObjectService(),responseDocument);
69  
70     }
71  
72  
73  }