1 package org.kuali.incubator;
2
3 import org.junit.Test;
4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory;
6
7 import java.util.*;
8
9 import static junit.framework.Assert.assertNotNull;
10
11
12
13
14
15
16
17
18 public class SolrRequstResponseHandler_UT {
19
20 public static final Logger LOG = LoggerFactory.getLogger(SolrRequstResponseHandler_UT.class);
21
22 public void testGetSolrResponseBasedOnAuthorSearch() throws Exception {
23 SolrRequestReponseHandler solrQueryManager = new SolrRequestReponseHandler();
24 List list = solrQueryManager.retriveResults("Author_search:Peri");
25 assertNotNull(list);
26 printResults(list);
27 }
28
29
30 public void testGetSolrResponseBasedOnUUIDSearch() throws Exception {
31 System.setProperty("app.environment", "local");
32 SolrRequestReponseHandler solrQueryManager = new SolrRequestReponseHandler();
33
34 List list = solrQueryManager.retriveResults("id:8f739303-00a1-43cf-a3d8-026258fca60a");
35 assertNotNull(list);
36 printResults(list);
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 LOG.info(key + ": " + value);
49 } else if (value instanceof List) {
50 LOG.info(key + ":");
51 List l = (ArrayList) value;
52 for (Iterator iterator2 = l.iterator(); iterator2.hasNext(); ) {
53 Object next = iterator2.next();
54 LOG.info("\t\t" + next);
55 }
56 }
57 }
58 LOG.info("***********************************************************");
59 }
60 }
61 }