001package org.kuali.ole.describe.service; 002 003import org.junit.Before; 004import org.junit.Ignore; 005import org.junit.Test; 006import org.kuali.incubator.SolrRequestReponseHandler; 007import org.kuali.ole.ingest.ISBNUtil; 008import org.mockito.Mock; 009import org.mockito.Mockito; 010import org.mockito.MockitoAnnotations; 011 012import java.util.Arrays; 013import java.util.HashMap; 014import java.util.List; 015 016import static junit.framework.Assert.assertNotNull; 017 018/** 019 * Created by IntelliJ IDEA. 020 * User: pvsubrah 021 * Date: 4/7/12 022 * Time: 7:34 PM 023 * To change this template use File | Settings | File Templates. 024 */ 025public class DiscoveryHelperService_UT { 026 @Mock 027 private SolrRequestReponseHandler mockSolrRequestResponseHandler; 028 029 @Before 030 public void setUp() throws Exception { 031 MockitoAnnotations.initMocks(this); 032 } 033 034 @Test 035 public void testGetResponseFromSOLR() throws Exception { 036 037 HashMap<String, String> map = new HashMap<String, String>(); 038 map.put("author_display", "mock_author"); 039 map.put("title_display", "mock_title"); 040 map.put("uuid", "mock_uuid"); 041 Mockito.when(mockSolrRequestResponseHandler.retriveResults("020a:9091405183689")).thenReturn(Arrays.asList(map)); 042 043 DiscoveryHelperService discoveryHelperService = new DiscoveryHelperService(); 044 discoveryHelperService.setSolrRequestReponseHandler(mockSolrRequestResponseHandler); 045 ISBNUtil isbnUtil = new ISBNUtil(); 046 String normalizedISBN = isbnUtil.normalizeISBN("9091405183689"); 047 List responseFromSOLR = discoveryHelperService.getResponseFromSOLR("020a", normalizedISBN); 048 assertNotNull(responseFromSOLR); 049 } 050 051 052 /*@Test 053 //Test to go against a dev or a test server depending on -Dapp.environment value 054 public void testGetResponseFromSOLR_AT() throws Exception { 055 System.setProperty("app.environment", "dev"); 056 DiscoveryHelperService discoveryHelperService = new DiscoveryHelperService(); 057 ISBNUtil isbnUtil = new ISBNUtil(); 058 String normalizedISBN = isbnUtil.normalizeISBN("0152038655"); 059 List responseFromSOLR = discoveryHelperService.getResponseFromSOLR("020a", normalizedISBN); 060 assertNotNull(responseFromSOLR); 061 }*/ 062 063 /* 064 @Test 065 //Test to go against a dev or a test server depending on -Dapp.environment value 066 public void testGetBibInfoFromSolr_AT() throws Exception { 067 System.setProperty("app.environment", "dev"); 068 DiscoveryHelperService discoveryHelperService = new DiscoveryHelperService(); 069 List responseFromSOLR = discoveryHelperService.getBibInformationFromInsatnceId("14080f4a-d05b-473b-8806-03a5bfe72ef0"); 070 assertNotNull(responseFromSOLR); 071 }*/ 072}