1 package org.kuali.incubator;
2
3 import org.junit.Test;
4
5 import java.util.*;
6
7 import static junit.framework.Assert.assertNotNull;
8
9
10
11
12
13
14
15
16 public class SolrRequstResponseHandler_UT {
17
18 public void testGetSolrResponseBasedOnAuthorSearch() throws Exception {
19 SolrRequestReponseHandler solrQueryManager = new SolrRequestReponseHandler();
20 List list = solrQueryManager.retriveResults("Author_search:Peri");
21 assertNotNull(list);
22 printResults(list);
23 }
24
25
26
27 public void testGetSolrResponseBasedOnUUIDSearch() throws Exception {
28 System.setProperty("app.environment", "local");
29 SolrRequestReponseHandler solrQueryManager = new SolrRequestReponseHandler();
30
31 List list = solrQueryManager.retriveResults("id:8f739303-00a1-43cf-a3d8-026258fca60a");
32 assertNotNull(list);
33 printResults(list);
34 }
35
36
37
38
39
40 private void printResults(List list) {
41 for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
42 HashMap map = (HashMap) iterator.next();
43 Set keys = map.keySet();
44 for (Iterator iterator1 = keys.iterator(); iterator1.hasNext(); ) {
45 Object key = iterator1.next();
46 Object value = map.get(key);
47 if (value instanceof String) {
48 System.out.println(key+ ": " + value);
49 } else if (value instanceof List){
50 System.out.println(key+":");
51 List l = (ArrayList) value;
52 for (Iterator iterator2 = l.iterator(); iterator2.hasNext(); ) {
53 Object next = iterator2.next();
54 System.out.println("\t\t"+next);
55 }
56 }
57 }
58 System.out.println("***********************************************************");
59 }
60 }
61 }