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
20
21
22
23
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 }