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