001 package org.kuali.incubator; 002 003 import org.junit.Test; 004 005 import java.util.*; 006 007 import static junit.framework.Assert.assertNotNull; 008 009 /** 010 * Created by IntelliJ IDEA. 011 * User: pvsubrah 012 * Date: 10/21/11 013 * Time: 10:57 AM 014 * To change this template use File | Settings | File Templates. 015 */ 016 public class SolrRequstResponseHandler_UT { 017 @Test 018 public void testGetSolrResponseBasedOnAuthorSearch() throws Exception { 019 SolrRequestReponseHandler solrQueryManager = new SolrRequestReponseHandler(); 020 List list = solrQueryManager.retriveResults("Author_search:Peri"); 021 assertNotNull(list); 022 printResults(list); 023 } 024 025 026 @Test 027 public void testGetSolrResponseBasedOnUUIDSearch() throws Exception { 028 System.setProperty("app.environment", "local"); 029 SolrRequestReponseHandler solrQueryManager = new SolrRequestReponseHandler(); 030 // List list = solrQueryManager.retriveResults("020a:9091405183689"); 031 List list = solrQueryManager.retriveResults("id:8f739303-00a1-43cf-a3d8-026258fca60a"); 032 assertNotNull(list); 033 printResults(list); 034 } 035 036 037 038 039 040 private void printResults(List list) { 041 for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { 042 HashMap map = (HashMap) iterator.next(); 043 Set keys = map.keySet(); 044 for (Iterator iterator1 = keys.iterator(); iterator1.hasNext(); ) { 045 Object key = iterator1.next(); 046 Object value = map.get(key); 047 if (value instanceof String) { 048 System.out.println(key+ ": " + value); 049 } else if (value instanceof List){ 050 System.out.println(key+":"); 051 List l = (ArrayList) value; 052 for (Iterator iterator2 = l.iterator(); iterator2.hasNext(); ) { 053 Object next = iterator2.next(); 054 System.out.println("\t\t"+next); 055 } 056 } 057 } 058 System.out.println("***********************************************************"); 059 } 060 } 061 }