View Javadoc

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   * Created by IntelliJ IDEA.
11   * User: pvsubrah
12   * Date: 10/21/11
13   * Time: 10:57 AM
14   * To change this template use File | Settings | File Templates.
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  //        List list = solrQueryManager.retriveResults("020a:9091405183689");
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  }