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