001package org.kuali.ole.document.rdbms; 002 003import org.apache.commons.io.FileUtils; 004import org.junit.Before; 005import org.junit.Ignore; 006import org.junit.Test; 007import org.junit.runner.RunWith; 008import org.kuali.ole.base.BaseTestCase; 009import org.kuali.ole.docstore.document.DocumentManager; 010import org.kuali.ole.docstore.model.xmlpojo.ingest.Request; 011import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument; 012import org.kuali.ole.docstore.model.xmlpojo.ingest.ResponseDocument; 013import org.kuali.ole.docstore.model.xstream.ingest.RequestHandler; 014import org.kuali.ole.docstore.service.BeanLocator; 015import org.kuali.rice.krad.service.BusinessObjectService; 016import org.kuali.rice.krad.service.KRADServiceLocator; 017import org.kuali.rice.krad.service.impl.BusinessObjectServiceImpl; 018import org.mockito.Mock; 019import org.mockito.Mockito; 020import org.mockito.MockitoAnnotations; 021import org.springframework.test.context.ContextConfiguration; 022import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 023 024import java.io.File; 025import java.util.List; 026 027 028/** 029 * Created with IntelliJ IDEA. 030 * User: ? 031 * Date: 1/4/13 032 * Time: 12:14 PM 033 * To change this template use File | Settings | File Templates. 034 */ 035 036@Ignore 037@Deprecated 038public class RdbmsWorkBibDocumentManager_UT extends BaseTestCase{ 039 @Mock 040 private BusinessObjectService businessObjectService; 041 042 @Before 043 public void setUp() throws Exception{ 044 super.setUp(); 045 MockitoAnnotations.initMocks(this); 046 } 047 048 049 private BusinessObjectService getBusinessObjectService(){ 050 if(businessObjectService==null) { 051 businessObjectService = KRADServiceLocator.getBusinessObjectService(); 052 } 053 return businessObjectService; 054 } 055 @Test 056 public void testIngest() throws Exception { 057 058 File file = new File(getClass().getResource("/org/kuali/ole/docstore/discovery/request.xml").toURI()); 059 String input = FileUtils.readFileToString(file); 060 RequestHandler rh = new RequestHandler(); 061 Request request = rh.toObject(input); 062 List<RequestDocument> requestDocuments = request.getRequestDocuments(); 063 RequestDocument requestDocument = requestDocuments.get(0); 064 DocumentManager documentManager=BeanLocator.getDocstoreFactory().getDocumentManager( 065 requestDocument.getCategory(),requestDocument.getType(),requestDocument.getFormat()); 066 ResponseDocument responseDocument=new ResponseDocument(); 067 requestDocument.getAdditionalAttributes().getAttributeMap().put("dateEntered","2010-12-12 00:00:00"); 068 documentManager.ingest(requestDocument,getBusinessObjectService(),responseDocument); 069 070 } 071 072 073}