View Javadoc
1   package org.kuali.ole.describe.service;
2   
3   import org.junit.Before;
4   import org.junit.Ignore;
5   import org.junit.Test;
6   import org.kuali.incubator.SolrRequestReponseHandler;
7   import org.kuali.ole.ingest.ISBNUtil;
8   import org.mockito.Mock;
9   import org.mockito.Mockito;
10  import org.mockito.MockitoAnnotations;
11  
12  import java.util.Arrays;
13  import java.util.HashMap;
14  import java.util.List;
15  
16  import static junit.framework.Assert.assertNotNull;
17  
18  /**
19   * Created by IntelliJ IDEA.
20   * User: pvsubrah
21   * Date: 4/7/12
22   * Time: 7:34 PM
23   * To change this template use File | Settings | File Templates.
24   */
25  public class DiscoveryHelperService_UT {
26      @Mock
27      private SolrRequestReponseHandler mockSolrRequestResponseHandler;
28      
29      @Before
30      public void setUp() throws Exception {
31          MockitoAnnotations.initMocks(this);
32      }
33      
34      @Test
35      public void testGetResponseFromSOLR() throws Exception {
36  
37          HashMap<String, String> map = new HashMap<String, String>();
38          map.put("author_display", "mock_author");
39          map.put("title_display", "mock_title");
40          map.put("uuid", "mock_uuid");
41          Mockito.when(mockSolrRequestResponseHandler.retriveResults("020a:9091405183689")).thenReturn(Arrays.asList(map));
42          
43          DiscoveryHelperService discoveryHelperService = new DiscoveryHelperService();
44          discoveryHelperService.setSolrRequestReponseHandler(mockSolrRequestResponseHandler);
45          ISBNUtil isbnUtil = new ISBNUtil();
46          String normalizedISBN = isbnUtil.normalizeISBN("9091405183689");
47          List responseFromSOLR = discoveryHelperService.getResponseFromSOLR("020a", normalizedISBN);
48          assertNotNull(responseFromSOLR);
49      }
50  
51  
52      /*@Test
53      //Test to go against a dev or a test server depending on -Dapp.environment value
54      public void testGetResponseFromSOLR_AT() throws Exception {
55          System.setProperty("app.environment", "dev");
56          DiscoveryHelperService discoveryHelperService = new DiscoveryHelperService();
57          ISBNUtil isbnUtil = new ISBNUtil();
58          String normalizedISBN = isbnUtil.normalizeISBN("0152038655");
59          List responseFromSOLR = discoveryHelperService.getResponseFromSOLR("020a", normalizedISBN);
60          assertNotNull(responseFromSOLR);
61      }*/
62  
63      /*
64      @Test
65      //Test to go against a dev or a test server depending on -Dapp.environment value
66      public void testGetBibInfoFromSolr_AT() throws Exception {
67          System.setProperty("app.environment", "dev");
68          DiscoveryHelperService discoveryHelperService = new DiscoveryHelperService();
69          List responseFromSOLR = discoveryHelperService.getBibInformationFromInsatnceId("14080f4a-d05b-473b-8806-03a5bfe72ef0");
70          assertNotNull(responseFromSOLR);
71      }*/
72  }