View Javadoc
1   package org.kuali.ole;
2   
3   import org.junit.Before;
4   import org.junit.Ignore;
5   import org.junit.Test;
6   import org.kuali.ole.bo.cql.CQLResponseBO;
7   import org.kuali.ole.service.OleCQLQueryParserService;
8   import org.kuali.ole.service.OleRequestOperationTypeService;
9   import org.kuali.ole.service.OleSearchRetrieveOperationService;
10  import org.kuali.ole.serviceimpl.*;
11  import org.kuali.rice.core.api.config.property.Config;
12  import org.mockito.Mock;
13  import org.mockito.Mockito;
14  import org.mockito.MockitoAnnotations;
15  import org.slf4j.Logger;
16  import org.slf4j.LoggerFactory;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import static junit.framework.Assert.assertNotNull;
22  
23  /**
24   * Created with IntelliJ IDEA.
25   * User: ?
26   * Date: 7/19/12
27   * Time: 6:43 PM
28   * To change this template use File | Settings | File Templates.
29   */
30  public class OleRequestOperationTypeService_UT extends BaseTestCase{
31  
32      private static Logger LOG = LoggerFactory.getLogger(OleRequestOperationTypeService_UT.class);
33      private OleRequestOperationTypeService oleRequestOperationTypeService=new OleRequestOperationTypeServiceImpl();
34      private OleSearchRetrieveOperationService oleSearchRetrieveOperationService=new OleSearchRetrieveOperationServiceImpl();
35  
36      @Mock
37      private Config mockConfig;
38  
39      @Before
40      public void setUp() throws Exception {
41          MockitoAnnotations.initMocks(this);
42          Mockito.when(mockConfig.getProperty(OleSRUConstants.INVALID_QUERY_DIAGNOSTIC_MSG)).thenReturn("");
43          ((OleSearchRetrieveOperationServiceImpl) oleSearchRetrieveOperationService).setCurrentContextConfig(mockConfig);
44          ((OleRequestOperationTypeServiceImpl)oleRequestOperationTypeService).setOleSearchRetrieveOperationService(oleSearchRetrieveOperationService);
45  
46      }
47  
48      @Ignore
49      @Test
50      public void testPerformOperationTypeService() throws Exception{
51  
52          CQLResponseBO cQLResponseBO=getCQLResponseBOObject();
53          String resXML=oleRequestOperationTypeService.performOperationTypeService(getReqParameters(),cQLResponseBO);
54          assertNotNull(resXML);
55  
56      }
57  
58      private CQLResponseBO getCQLResponseBOObject() throws Exception{
59          OleCQLQueryParserService oleCQLQueryParserService=new OleCQLQueryParserServiceImpl();
60          String parserXml=oleCQLQueryParserService.parseCQLQuery("Title=HTC");
61          CQLResponseBO cQLResponseBO=oleCQLQueryParserService.getCQLResponseObject(parserXml);
62          return cQLResponseBO;
63      }
64  
65      public Map getReqParameters() {
66  
67          HashMap reqParamMap=new HashMap();
68          reqParamMap.put(OleSRUConstants.OPERATION_TYPE,OleSRUConstants.SEARCH_RETRIEVE);
69          reqParamMap.put(OleSRUConstants.VERSION,"1.1");
70          reqParamMap.put(OleSRUConstants.QUERY,"title=HTC");
71          reqParamMap.put(OleSRUConstants.START_RECORD,"1");
72          reqParamMap.put(OleSRUConstants.MAXIMUM_RECORDS,"10");
73          reqParamMap.put(OleSRUConstants.RECORD_PACKING,"xml");
74  
75          return reqParamMap;
76  
77      }
78  }