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.bo.diagnostics.OleSRUDiagnostics;
8 import org.kuali.ole.service.OleCQLQueryParserService;
9 import org.kuali.ole.service.OleSearchRetrieveOperationService;
10 import org.kuali.ole.serviceimpl.OleCQLQueryParserServiceImpl;
11 import org.kuali.ole.serviceimpl.OleSearchRetrieveOperationServiceImpl;
12 import org.kuali.rice.core.api.config.property.Config;
13 import org.milyn.container.MockApplicationContext;
14 import org.mockito.Mock;
15 import org.mockito.Mockito;
16 import org.mockito.MockitoAnnotations;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 import java.util.HashMap;
21 import java.util.Map;
22
23 import static junit.framework.Assert.assertNotNull;
24
25
26
27
28
29
30
31 public class OleSearchRetrieveOperationService_UT extends BaseTestCase {
32 private static Logger LOG = LoggerFactory.getLogger(OleSearchRetrieveOperationService_UT.class);
33 private OleSearchRetrieveOperationService oleSearchRetrieveOperationService=new OleSearchRetrieveOperationServiceImpl();
34
35 @Mock
36 private Config mockConfig;
37
38 @Before
39 public void setUp() throws Exception {
40 MockitoAnnotations.initMocks(this);
41 Mockito.when(mockConfig.getProperty(OleSRUConstants.INVALID_QUERY_DIAGNOSTIC_MSG)).thenReturn("");
42 ((OleSearchRetrieveOperationServiceImpl) oleSearchRetrieveOperationService).setCurrentContextConfig(mockConfig);
43 }
44
45 @Ignore
46 @Test
47 public void testPerformOperationTypeService() throws Exception{
48 CQLResponseBO cqlParseBO=getCQLResponseBOObject();
49 String opacXml=oleSearchRetrieveOperationService.getSearchRetriveResponse(getReqParameters(),cqlParseBO);
50 assertNotNull(opacXml);
51 }
52
53 private CQLResponseBO getCQLResponseBOObject() throws Exception{
54 OleCQLQueryParserService oleCQLQueryParserService=new OleCQLQueryParserServiceImpl();
55 String parserXml=oleCQLQueryParserService.parseCQLQuery("Title=HTC");
56 CQLResponseBO cQLResponseBO=oleCQLQueryParserService.getCQLResponseObject(parserXml);
57 return cQLResponseBO;
58 }
59
60 public Map getReqParameters() {
61
62 HashMap reqParamMap=new HashMap();
63 reqParamMap.put(OleSRUConstants.OperationType,OleSRUConstants.SEARCH_RETRIEVE);
64 reqParamMap.put(OleSRUConstants.VERSION,"1.1");
65 reqParamMap.put(OleSRUConstants.QUERY,"title=HTC");
66 reqParamMap.put(OleSRUConstants.START_RECORD,"1");
67 reqParamMap.put(OleSRUConstants.MAXIMUM_RECORDS,"10");
68 reqParamMap.put(OleSRUConstants.RECORD_PACKING,"xml");
69
70 return reqParamMap;
71
72 }
73 }