View Javadoc

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