From 38643894d1f8caadc4f4fa5deaeb209a2e399e68 Mon Sep 17 00:00:00 2001 From: Erick Erickson Date: Wed, 27 Nov 2013 15:24:24 +0000 Subject: [PATCH] SOLR-5488: Changing Facets testing to use DOM rather than string operations git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1546074 13f79535-47bb-0310-9956-ffa450edef68 --- .../facet/AbstractAnalyticsFacetTest.java | 143 ++-- .../analytics/facet/FieldFacetExtrasTest.java | 65 +- .../solr/analytics/facet/FieldFacetTest.java | 669 +++++++----------- .../solr/analytics/facet/QueryFacetTest.java | 22 +- .../solr/analytics/facet/RangeFacetTest.java | 94 +-- 5 files changed, 433 insertions(+), 560 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/analytics/facet/AbstractAnalyticsFacetTest.java b/solr/core/src/test/org/apache/solr/analytics/facet/AbstractAnalyticsFacetTest.java index f8af2967772..dba19a8aaa9 100644 --- a/solr/core/src/test/org/apache/solr/analytics/facet/AbstractAnalyticsFacetTest.java +++ b/solr/core/src/test/org/apache/solr/analytics/facet/AbstractAnalyticsFacetTest.java @@ -17,8 +17,10 @@ package org.apache.solr.analytics.facet; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -35,6 +37,18 @@ import org.apache.solr.request.SolrQueryRequest; import com.google.common.collect.ObjectArrays; import org.apache.solr.util.ExternalPaths; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; @SuppressCodecs({"Lucene3x","Lucene40","Lucene41","Lucene42","Appending","Asserting"}) public class AbstractAnalyticsFacetTest extends SolrTestCaseJ4 { @@ -42,24 +56,84 @@ public class AbstractAnalyticsFacetTest extends SolrTestCaseJ4 { protected String latestType = ""; - public String getFacetXML(String response, String requestName, String facetType, String facet) { - String cat = "\n "; - String begin = " \n"; - String end = "\n "; - int beginInt = response.indexOf(begin, response.indexOf(cat))+begin.length(); - int endInt = response.indexOf(end, beginInt); - String fieldStr = response.substring(beginInt, endInt); - begin = " "; - end = "\n "; - beginInt = fieldStr.indexOf(begin); - endInt = fieldStr.indexOf(end, beginInt); - String facetStr = ""; - if (beginInt>=0) { - facetStr = fieldStr.substring(beginInt+begin.length(),endInt); - } - return facetStr+" "; + private static Document doc; + private static XPathFactory xPathFact = XPathFactory.newInstance(); + private static String rawResponse; + + protected static void setResponse(String response) throws ParserConfigurationException, IOException, SAXException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); // never forget this! + DocumentBuilder builder = factory.newDocumentBuilder(); + doc = builder.parse(new InputSource(new ByteArrayInputStream(response.getBytes("UTF-8")))); + xPathFact = XPathFactory.newInstance(); + rawResponse = response; } - + + protected String getRawResponse() { + return rawResponse; + } + + protected Node getNode(String xPath) throws XPathExpressionException { + return (Node)xPathFact.newXPath().compile(xPath).evaluate(doc, XPathConstants.NODE); + } + private NodeList getNodes(String n1, String n2, String n3, String element, String n4) throws XPathExpressionException { + // Construct the XPath expression. The form better not change or all these will fail. + StringBuilder sb = new StringBuilder("/response/lst[@name='stats']/lst[@name='").append(n1).append("']"); + sb.append("/lst[@name='").append(n2).append("']"); + sb.append("/lst[@name='").append(n3).append("']"); + sb.append("//").append(element).append("[@name='").append(n4).append("']"); + return (NodeList)xPathFact.newXPath().compile(sb.toString()).evaluate(doc, XPathConstants.NODESET); + + } + protected ArrayList getStringList(String n1, String n2, String n3, String element, String n4) + throws XPathExpressionException { + ArrayList ret = new ArrayList(); + NodeList nodes = getNodes(n1, n2, n3, element, n4); + for (int idx = 0; idx < nodes.getLength(); ++idx) { + ret.add(nodes.item(idx).getTextContent()); + } + return ret; + } + + protected ArrayList getIntegerList(String n1, String n2, String n3, String element, String n4) + throws XPathExpressionException { + ArrayList ret = new ArrayList(); + NodeList nodes = getNodes(n1, n2, n3, element, n4); + for (int idx = 0; idx < nodes.getLength(); ++idx) { + ret.add(Integer.parseInt(nodes.item(idx).getTextContent())); + } + return ret; + } + protected ArrayList getLongList(String n1, String n2, String n3, String element, String n4) + throws XPathExpressionException { + ArrayList ret = new ArrayList(); + NodeList nodes = getNodes(n1, n2, n3, element, n4); + for (int idx = 0; idx < nodes.getLength(); ++idx) { + ret.add(Long.parseLong(nodes.item(idx).getTextContent())); + } + return ret; + } + protected ArrayList getFloatList(String n1, String n2, String n3, String element, String n4) + throws XPathExpressionException { + ArrayList ret = new ArrayList(); + NodeList nodes = getNodes(n1, n2, n3, element, n4); + for (int idx = 0; idx < nodes.getLength(); ++idx) { + ret.add(Float.parseFloat(nodes.item(idx).getTextContent())); + } + return ret; + } + + protected ArrayList getDoubleList(String n1, String n2, String n3, String element, String n4) + throws XPathExpressionException { + ArrayList ret = new ArrayList(); + NodeList nodes = getNodes(n1, n2, n3, element, n4); + for (int idx = 0; idx < nodes.getLength(); ++idx) { + ret.add(Double.parseDouble(nodes.item(idx).getTextContent())); + } + return ret; + } + + public static void increment(List list, int idx){ Long i = list.remove(idx); list.add(idx, i+1); @@ -84,41 +158,6 @@ public class AbstractAnalyticsFacetTest extends SolrTestCaseJ4 { this.latestType = latestType; } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public ArrayList xmlToList(String facit, String type, String name) { - ArrayList list; - if (type.equals("double")) { - list = new ArrayList(); - } else if (type.equals("int")) { - list = new ArrayList(); - } else if (type.equals("long")) { - list = new ArrayList(); - } else if (type.equals("float")) { - list = new ArrayList(); - } else { - list = new ArrayList(); - } - String find = "<"+type+" name=\""+name+"\">"; - String endS = ""; - int findAt = facit.indexOf(find)+find.length(); - while (findAt>find.length()) { - int end = facit.indexOf(endS, findAt); - if (type.equals("double")) { - list.add(Double.parseDouble(facit.substring(findAt, end))); - } else if (type.equals("int")) { - list.add(Integer.parseInt(facit.substring(findAt, end))); - } else if (type.equals("long")) { - list.add(Long.parseLong(facit.substring(findAt, end))); - } else if (type.equals("float")) { - list.add(Float.parseFloat(facit.substring(findAt, end))); - } else { - list.add(facit.substring(findAt, end)); - } - findAt = facit.indexOf(find, end)+find.length(); - } - return list; - } - @SuppressWarnings({ "unchecked", "rawtypes" }) public > ArrayList calculateNumberStat(ArrayList> lists, String stat) { ArrayList result; diff --git a/solr/core/src/test/org/apache/solr/analytics/facet/FieldFacetExtrasTest.java b/solr/core/src/test/org/apache/solr/analytics/facet/FieldFacetExtrasTest.java index 3c915555515..7c9d740be75 100644 --- a/solr/core/src/test/org/apache/solr/analytics/facet/FieldFacetExtrasTest.java +++ b/solr/core/src/test/org/apache/solr/analytics/facet/FieldFacetExtrasTest.java @@ -45,8 +45,6 @@ public class FieldFacetExtrasTest extends AbstractAnalyticsFacetTest { static ArrayList> intDoubleTestStart; static ArrayList> intStringTestStart; - static String response; - @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-basic.xml","schema-analytics.xml"); @@ -106,85 +104,72 @@ public class FieldFacetExtrasTest extends AbstractAnalyticsFacetTest { } assertU(commit()); - response = h.query(request(fileToStringArr(fileName))); + setResponse(h.query(request(fileToStringArr(fileName)))); } @SuppressWarnings("unchecked") @Test public void limitTest() throws Exception { - String longLimit = getFacetXML(response, "lr", "fieldFacets", "long_ld"); - Collection lon = (ArrayList)xmlToList(longLimit, "double", "mean"); - assertEquals(lon.size(),5); - String floatLimit = getFacetXML(response, "lr", "fieldFacets", "float_fd"); - Collection flo = (ArrayList)xmlToList(floatLimit, "double", "median"); - assertEquals(flo.size(),3); - String doubleLimit = getFacetXML(response, "lr", "fieldFacets", "double_dd"); - Collection doub = (ArrayList)xmlToList(doubleLimit, "long", "count"); - assertEquals(doub.size(),7); - String stringLimit = getFacetXML(response, "lr", "fieldFacets", "string_sd"); - Collection string = (ArrayList)xmlToList(stringLimit, "int", "percentile_20"); - assertEquals(string.size(),1); + Collection lon = getDoubleList("lr", "fieldFacets", "long_ld", "double", "mean"); + assertEquals(getRawResponse(), lon.size(),5); + Collection flo = getDoubleList("lr", "fieldFacets", "float_fd", "double", "median"); + assertEquals(getRawResponse(), flo.size(),3); + Collection doub = getLongList("lr", "fieldFacets", "double_dd", "long", "count"); + assertEquals(getRawResponse(), doub.size(),7); + Collection string = getIntegerList("lr", "fieldFacets", "string_sd", "int", "percentile_20"); + assertEquals(getRawResponse(), string.size(),1); } @SuppressWarnings("unchecked") @Test public void offsetTest() throws Exception { - String xml; Collection lon; List all = new ArrayList(); - xml = getFacetXML(response, "off0", "fieldFacets", "long_ld"); - lon = (ArrayList)xmlToList(xml, "double", "mean"); - assertEquals(lon.size(),2); + lon = getDoubleList("off0", "fieldFacets", "long_ld", "double", "mean"); + assertEquals(getRawResponse(), lon.size(),2); assertArrayEquals(new Double[]{ 1.5, 2.0 }, lon.toArray(new Double[0])); all.addAll(lon); - xml = getFacetXML(response, "off1", "fieldFacets", "long_ld"); - lon = (ArrayList)xmlToList(xml, "double", "mean"); - assertEquals(lon.size(),2); + lon = getDoubleList("off1", "fieldFacets", "long_ld", "double", "mean"); + assertEquals(getRawResponse(), lon.size(),2); assertArrayEquals(new Double[]{ 3.0, 4.0 }, lon.toArray(new Double[0])); all.addAll(lon); - xml = getFacetXML(response, "off2", "fieldFacets", "long_ld"); - lon = (ArrayList)xmlToList(xml, "double", "mean"); - assertEquals(lon.size(),3); + lon = getDoubleList("off2", "fieldFacets", "long_ld", "double", "mean"); + assertEquals(getRawResponse(), lon.size(),3); assertArrayEquals(new Double[]{ 5.0, 5.75, 6.0 }, lon.toArray(new Double[0])); all.addAll(lon); - xml = getFacetXML(response, "offAll", "fieldFacets", "long_ld"); - lon = (ArrayList)xmlToList(xml, "double", "mean"); - assertEquals(lon.size(),7); + lon = getDoubleList("offAll", "fieldFacets", "long_ld", "double", "mean"); + assertEquals(getRawResponse(), lon.size(),7); assertArrayEquals(all.toArray(new Double[0]), lon.toArray(new Double[0])); } @SuppressWarnings("unchecked") @Test public void sortTest() throws Exception { - String longSort = getFacetXML(response, "sr", "fieldFacets", "long_ld"); - Collection lon = (ArrayList)xmlToList(longSort, "double", "mean"); + Collection lon = getDoubleList("sr", "fieldFacets", "long_ld", "double", "mean"); ArrayList longTest = calculateNumberStat(intLongTestStart, "mean"); Collections.sort(longTest); - assertEquals(longTest,lon); + assertEquals(getRawResponse(), longTest,lon); - String floatSort = getFacetXML(response, "sr", "fieldFacets", "float_fd"); - Collection flo = (ArrayList)xmlToList(floatSort, "double", "median"); + Collection flo = getDoubleList("sr", "fieldFacets", "float_fd", "double", "median"); ArrayList floatTest = calculateNumberStat(intFloatTestStart, "median"); Collections.sort(floatTest,Collections.reverseOrder()); - assertEquals(floatTest,flo); + assertEquals(getRawResponse(), floatTest,flo); - String doubleSort = getFacetXML(response, "sr", "fieldFacets", "double_dd"); - Collection doub = (ArrayList)xmlToList(doubleSort, "long", "count"); + Collection doub = getLongList("sr", "fieldFacets", "double_dd", "long", "count"); ArrayList doubleTest = (ArrayList)calculateStat(intDoubleTestStart, "count"); Collections.sort(doubleTest); - assertEquals(doubleTest,doub); + assertEquals(getRawResponse(), doubleTest,doub); - String stringSort = getFacetXML(response, "sr", "fieldFacets", "string_sd"); - Collection string = (ArrayList)xmlToList(stringSort, "int", "percentile_20"); + Collection string = getIntegerList("sr", "fieldFacets", "string_sd", "int", "percentile_20"); ArrayList stringTest = (ArrayList)calculateStat(intStringTestStart, "perc_20"); Collections.sort(stringTest,Collections.reverseOrder()); - assertEquals(stringTest,string); + assertEquals(getRawResponse(), stringTest,string); } } diff --git a/solr/core/src/test/org/apache/solr/analytics/facet/FieldFacetTest.java b/solr/core/src/test/org/apache/solr/analytics/facet/FieldFacetTest.java index 895c43b6546..38a3c16e815 100644 --- a/solr/core/src/test/org/apache/solr/analytics/facet/FieldFacetTest.java +++ b/solr/core/src/test/org/apache/solr/analytics/facet/FieldFacetTest.java @@ -85,8 +85,6 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{ private static ArrayList> multiDateTestStart; private static ArrayList multiDateTestMissing; - static String response; - @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-basic.xml","schema-analytics.xml"); @@ -390,533 +388,445 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{ } assertU(commit()); - response = h.query(request(fileToStringArr(fileName))); + setResponse(h.query(request(fileToStringArr(fileName)))); } @SuppressWarnings("unchecked") @Test public void sumTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "sum","fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "double", "int"); + Collection intDate = getDoubleList("sum","fieldFacets", "date_dtd", "double", "int"); ArrayList intDateTest = calculateNumberStat(intDateTestStart, "sum"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "sum","fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "double", "int"); + Collection intString = getDoubleList("sum","fieldFacets", "string_sd", "double", "int"); ArrayList intStringTest = calculateNumberStat(intStringTestStart, "sum"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "sum","fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "double", "long"); + Collection longDate = getDoubleList("sum","fieldFacets", "date_dtd", "double", "long"); ArrayList longDateTest = calculateNumberStat(longDateTestStart, "sum"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "sum","fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "double", "long"); + Collection longString = getDoubleList("sum","fieldFacets", "string_sd", "double", "long"); ArrayList longStringTest = calculateNumberStat(longStringTestStart, "sum"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "sum","fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "double", "float"); + Collection floatDate = getDoubleList("sum","fieldFacets", "date_dtd", "double", "float"); ArrayList floatDateTest = calculateNumberStat(floatDateTestStart, "sum"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "sum","fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "double", "float"); + Collection floatString = getDoubleList("sum","fieldFacets", "string_sd", "double", "float"); ArrayList floatStringTest = calculateNumberStat(floatStringTestStart, "sum"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "sum","fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + Collection doubleDate = getDoubleList("sum","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = calculateNumberStat(doubleDateTestStart, "sum"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "sum","fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + Collection doubleString = getDoubleList("sum","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = calculateNumberStat(doubleStringTestStart, "sum"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); } @SuppressWarnings("unchecked") @Test public void meanTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "mean","fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "double", "int"); + Collection intDate = getDoubleList("mean","fieldFacets", "date_dtd", "double", "int"); ArrayList intDateTest = calculateNumberStat(intDateTestStart, "mean"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "mean","fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "double", "int"); + Collection intString = getDoubleList("mean","fieldFacets", "string_sd", "double", "int"); ArrayList intStringTest = calculateNumberStat(intStringTestStart, "mean"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "mean","fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "double", "long"); + Collection longDate = getDoubleList("mean","fieldFacets", "date_dtd", "double", "long"); ArrayList longDateTest = calculateNumberStat(longDateTestStart, "mean"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "mean","fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "double", "long"); + Collection longString = getDoubleList("mean","fieldFacets", "string_sd", "double", "long"); ArrayList longStringTest = calculateNumberStat(longStringTestStart, "mean"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "mean","fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "double", "float"); + Collection floatDate = getDoubleList("mean","fieldFacets", "date_dtd", "double", "float"); ArrayList floatDateTest = calculateNumberStat(floatDateTestStart, "mean"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "mean","fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "double", "float"); + Collection floatString = getDoubleList("mean","fieldFacets", "string_sd", "double", "float"); ArrayList floatStringTest = calculateNumberStat(floatStringTestStart, "mean"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "mean","fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + Collection doubleDate = getDoubleList("mean","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = calculateNumberStat(doubleDateTestStart, "mean"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "mean","fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + Collection doubleString = getDoubleList("mean","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = calculateNumberStat(doubleStringTestStart, "mean"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); } @SuppressWarnings("unchecked") @Test public void sumOfSquaresFacetAscTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "sumOfSquares","fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "double", "int"); + Collection intDate = getDoubleList("sumOfSquares","fieldFacets", "date_dtd", "double", "int"); ArrayList intDateTest = calculateNumberStat(intDateTestStart, "sumOfSquares"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "sumOfSquares","fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "double", "int"); + Collection intString = getDoubleList("sumOfSquares","fieldFacets", "string_sd", "double", "int"); ArrayList intStringTest = calculateNumberStat(intStringTestStart, "sumOfSquares"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "sumOfSquares","fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "double", "long"); + Collection longDate = getDoubleList("sumOfSquares","fieldFacets", "date_dtd", "double", "long"); ArrayList longDateTest = calculateNumberStat(longDateTestStart, "sumOfSquares"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "sumOfSquares","fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "double", "long"); + Collection longString = getDoubleList("sumOfSquares","fieldFacets", "string_sd", "double", "long"); ArrayList longStringTest = calculateNumberStat(longStringTestStart, "sumOfSquares"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "sumOfSquares","fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "double", "float"); + Collection floatDate = getDoubleList("sumOfSquares","fieldFacets", "date_dtd", "double", "float"); ArrayList floatDateTest = calculateNumberStat(floatDateTestStart, "sumOfSquares"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "sumOfSquares","fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "double", "float"); + Collection floatString = getDoubleList("sumOfSquares","fieldFacets", "string_sd", "double", "float"); ArrayList floatStringTest = calculateNumberStat(floatStringTestStart, "sumOfSquares"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "sumOfSquares","fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + Collection doubleDate = getDoubleList("sumOfSquares","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = calculateNumberStat(doubleDateTestStart, "sumOfSquares"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "sumOfSquares","fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + Collection doubleString = getDoubleList("sumOfSquares","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = calculateNumberStat(doubleStringTestStart, "sumOfSquares"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); } @SuppressWarnings("unchecked") @Test public void stddevFacetAscTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "stddev","fieldFacets", "date_dtd"); - ArrayList intDate = (ArrayList)xmlToList(intDateFacet, "double", "int"); + ArrayList intDate = getDoubleList("stddev","fieldFacets", "date_dtd", "double", "int"); ArrayList intDateTest = calculateNumberStat(intDateTestStart, "stddev"); - assertTrue(checkStddevs(intDate,intDateTest)); + checkStddevs(intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "stddev","fieldFacets", "string_sd"); - ArrayList intString = (ArrayList)xmlToList(intStringFacet, "double", "int"); + ArrayList intString = getDoubleList("stddev","fieldFacets", "string_sd", "double", "int"); ArrayList intStringTest = calculateNumberStat(intStringTestStart, "stddev"); - assertTrue(checkStddevs(intString,intStringTest)); + checkStddevs(intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "stddev","fieldFacets", "date_dtd"); - ArrayList longDate = (ArrayList)xmlToList(longDateFacet, "double", "long"); + ArrayList longDate = getDoubleList("stddev","fieldFacets", "date_dtd", "double", "long"); ArrayList longDateTest = calculateNumberStat(longDateTestStart, "stddev"); - assertTrue(checkStddevs(longDate,longDateTest)); + checkStddevs(longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "stddev","fieldFacets", "string_sd"); - ArrayList longString = (ArrayList)xmlToList(longStringFacet, "double", "long"); + ArrayList longString = getDoubleList("stddev","fieldFacets", "string_sd", "double", "long"); ArrayList longStringTest = calculateNumberStat(longStringTestStart, "stddev"); - assertTrue(checkStddevs(longString,longStringTest)); + checkStddevs(longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "stddev","fieldFacets", "date_dtd"); - ArrayList floatDate = (ArrayList)xmlToList(floatDateFacet, "double", "float"); + ArrayList floatDate = getDoubleList("stddev","fieldFacets", "date_dtd", "double", "float"); ArrayList floatDateTest = calculateNumberStat(floatDateTestStart, "stddev"); - assertTrue(checkStddevs(floatDate,floatDateTest)); + checkStddevs(floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "stddev","fieldFacets", "string_sd"); - ArrayList floatString = (ArrayList)xmlToList(floatStringFacet, "double", "float"); + ArrayList floatString = getDoubleList("stddev","fieldFacets", "string_sd", "double", "float"); ArrayList floatStringTest = calculateNumberStat(floatStringTestStart, "stddev"); - assertTrue(checkStddevs(floatString,floatStringTest)); + checkStddevs(floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "stddev","fieldFacets", "date_dtd"); - ArrayList doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + ArrayList doubleDate = getDoubleList("stddev","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = calculateNumberStat(doubleDateTestStart, "stddev"); - assertTrue(checkStddevs(doubleDate,doubleDateTest)); + checkStddevs(doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "stddev","fieldFacets", "string_sd"); - ArrayList doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + ArrayList doubleString = getDoubleList("stddev","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = calculateNumberStat(doubleStringTestStart, "stddev"); - assertTrue(checkStddevs(doubleString,doubleStringTest)); + checkStddevs(doubleString,doubleStringTest); } @SuppressWarnings("unchecked") @Test public void medianFacetAscTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "median","fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "double", "int"); + Collection intDate = getDoubleList( "median","fieldFacets", "date_dtd", "double", "int"); ArrayList intDateTest = calculateNumberStat(intDateTestStart, "median"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "median","fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "double", "int"); + Collection intString = getDoubleList("median","fieldFacets", "string_sd", "double", "int"); ArrayList intStringTest = calculateNumberStat(intStringTestStart, "median"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "median","fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "double", "long"); + Collection longDate = getDoubleList("median","fieldFacets", "date_dtd", "double", "long"); ArrayList longDateTest = calculateNumberStat(longDateTestStart, "median"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "median","fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "double", "long"); + Collection longString = getDoubleList("median","fieldFacets", "string_sd", "double", "long"); ArrayList longStringTest = calculateNumberStat(longStringTestStart, "median"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "median","fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "double", "float"); + Collection floatDate = getDoubleList("median","fieldFacets", "date_dtd", "double", "float"); ArrayList floatDateTest = calculateNumberStat(floatDateTestStart, "median"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "median","fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "double", "float"); + Collection floatString = getDoubleList("median","fieldFacets", "string_sd", "double", "float"); ArrayList floatStringTest = calculateNumberStat(floatStringTestStart, "median"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "median","fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + Collection doubleDate = getDoubleList("median","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = calculateNumberStat(doubleDateTestStart, "median"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "median","fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + Collection doubleString = getDoubleList("median","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = calculateNumberStat(doubleStringTestStart, "median"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); } @SuppressWarnings("unchecked") @Test public void perc20Test() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "percentile_20n","fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "int", "int"); + Collection intDate = getIntegerList("percentile_20n","fieldFacets", "date_dtd", "int", "int"); ArrayList intDateTest = (ArrayList)calculateStat(intDateTestStart, "perc_20"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "percentile_20n","fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "int", "int"); + Collection intString = getIntegerList("percentile_20n","fieldFacets", "string_sd", "int", "int"); ArrayList intStringTest = (ArrayList)calculateStat(intStringTestStart, "perc_20"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "percentile_20n","fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "long", "long"); + Collection longDate = getLongList("percentile_20n","fieldFacets", "date_dtd", "long", "long"); ArrayList longDateTest = (ArrayList)calculateStat(longDateTestStart, "perc_20"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "percentile_20n","fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "long", "long"); + Collection longString = getLongList("percentile_20n","fieldFacets", "string_sd", "long", "long"); ArrayList longStringTest = (ArrayList)calculateStat(longStringTestStart, "perc_20"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "percentile_20n","fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "float", "float"); + Collection floatDate = getFloatList("percentile_20n","fieldFacets", "date_dtd", "float", "float"); ArrayList floatDateTest = (ArrayList)calculateStat(floatDateTestStart, "perc_20"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "percentile_20n","fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "float", "float"); + Collection floatString = getFloatList("percentile_20n","fieldFacets", "string_sd", "float", "float"); ArrayList floatStringTest = (ArrayList)calculateStat(floatStringTestStart, "perc_20"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "percentile_20n","fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + Collection doubleDate = getDoubleList("percentile_20n","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = (ArrayList)calculateStat(doubleDateTestStart, "perc_20"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "percentile_20n","fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + Collection doubleString = getDoubleList("percentile_20n","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = (ArrayList)calculateStat(doubleStringTestStart, "perc_20"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); //Date Int - String dateIntFacet = getFacetXML(response, "percentile_20","fieldFacets", "int_id"); - Collection dateInt = (ArrayList)xmlToList(dateIntFacet, "date", "date"); + Collection dateInt = getStringList("percentile_20","fieldFacets", "int_id", "date", "date"); ArrayList dateIntTest = (ArrayList)calculateStat(dateIntTestStart, "perc_20"); - assertEquals(dateInt,dateIntTest); + assertEquals(getRawResponse(),dateInt,dateIntTest); //Date Long - String dateStringFacet = getFacetXML(response, "percentile_20","fieldFacets", "long_ld"); - Collection dateString = (ArrayList)xmlToList(dateStringFacet, "date", "date"); + Collection dateString = getStringList("percentile_20","fieldFacets", "long_ld", "date", "date"); ArrayList dateLongTest = (ArrayList)calculateStat(dateLongTestStart, "perc_20"); - assertEquals(dateString,dateLongTest); + assertEquals(getRawResponse(),dateString,dateLongTest); //String Int - String stringIntFacet = getFacetXML(response, "percentile_20","fieldFacets", "int_id"); - Collection stringInt = (ArrayList)xmlToList(stringIntFacet, "str", "str"); + Collection stringInt = getStringList("percentile_20","fieldFacets", "int_id", "str", "str"); ArrayList stringIntTest = (ArrayList)calculateStat(stringIntTestStart, "perc_20"); - assertEquals(stringInt,stringIntTest); + assertEquals(getRawResponse(),stringInt,stringIntTest); //String Long - String stringLongFacet = getFacetXML(response, "percentile_20","fieldFacets", "long_ld"); - Collection stringLong = (ArrayList)xmlToList(stringLongFacet, "str", "str"); + Collection stringLong = getStringList("percentile_20","fieldFacets", "long_ld", "str", "str"); ArrayList stringLongTest = (ArrayList)calculateStat(stringLongTestStart, "perc_20"); - assertEquals(stringLong,stringLongTest); + assertEquals(getRawResponse(),stringLong,stringLongTest); } @SuppressWarnings("unchecked") @Test public void perc60Test() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "percentile_60n","fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "int", "int"); + Collection intDate = getIntegerList("percentile_60n","fieldFacets", "date_dtd", "int", "int"); ArrayList intDateTest = (ArrayList)calculateStat(intDateTestStart, "perc_60"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "percentile_60n","fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "int", "int"); + Collection intString = getIntegerList("percentile_60n","fieldFacets", "string_sd", "int", "int"); ArrayList intStringTest = (ArrayList)calculateStat(intStringTestStart, "perc_60"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "percentile_60n","fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "long", "long"); + Collection longDate = getLongList("percentile_60n","fieldFacets", "date_dtd", "long", "long"); ArrayList longDateTest = (ArrayList)calculateStat(longDateTestStart, "perc_60"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "percentile_60n","fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "long", "long"); + Collection longString = getLongList("percentile_60n","fieldFacets", "string_sd", "long", "long"); ArrayList longStringTest = (ArrayList)calculateStat(longStringTestStart, "perc_60"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "percentile_60n","fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "float", "float"); + Collection floatDate = getFloatList("percentile_60n","fieldFacets", "date_dtd", "float", "float"); ArrayList floatDateTest = (ArrayList)calculateStat(floatDateTestStart, "perc_60"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "percentile_60n","fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "float", "float"); + Collection floatString = getFloatList("percentile_60n","fieldFacets", "string_sd", "float", "float"); ArrayList floatStringTest = (ArrayList)calculateStat(floatStringTestStart, "perc_60"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "percentile_60n","fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + Collection doubleDate = getDoubleList("percentile_60n","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = (ArrayList)calculateStat(doubleDateTestStart, "perc_60"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "percentile_60n","fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + Collection doubleString = getDoubleList("percentile_60n","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = (ArrayList)calculateStat(doubleStringTestStart, "perc_60"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); //Date Int - String dateIntFacet = getFacetXML(response, "percentile_60","fieldFacets", "int_id"); - Collection dateInt = (ArrayList)xmlToList(dateIntFacet, "date", "date"); + Collection dateInt = getStringList("percentile_60","fieldFacets", "int_id", "date", "date"); ArrayList dateIntTest = (ArrayList)calculateStat(dateIntTestStart, "perc_60"); - assertEquals(dateInt,dateIntTest); + assertEquals(getRawResponse(),dateInt,dateIntTest); //Date Long - String dateStringFacet = getFacetXML(response, "percentile_60","fieldFacets", "long_ld"); - Collection dateString = (ArrayList)xmlToList(dateStringFacet, "date", "date"); + Collection dateString = getStringList("percentile_60","fieldFacets", "long_ld", "date", "date"); ArrayList dateLongTest = (ArrayList)calculateStat(dateLongTestStart, "perc_60"); - assertEquals(dateString,dateLongTest); + assertEquals(getRawResponse(),dateString,dateLongTest); //String Int - String stringIntFacet = getFacetXML(response, "percentile_60","fieldFacets", "int_id"); - Collection stringInt = (ArrayList)xmlToList(stringIntFacet, "str", "str"); + Collection stringInt = getStringList("percentile_60","fieldFacets", "int_id", "str", "str"); ArrayList stringIntTest = (ArrayList)calculateStat(stringIntTestStart, "perc_60"); - assertEquals(stringInt,stringIntTest); + assertEquals(getRawResponse(),stringInt,stringIntTest); //String Long - String stringLongFacet = getFacetXML(response, "percentile_60","fieldFacets", "long_ld"); - Collection stringLong = (ArrayList)xmlToList(stringLongFacet, "str", "str"); + Collection stringLong = getStringList("percentile_60","fieldFacets", "long_ld", "str", "str"); ArrayList stringLongTest = (ArrayList)calculateStat(stringLongTestStart, "perc_60"); - assertEquals(stringLong,stringLongTest); + assertEquals(getRawResponse(),stringLong,stringLongTest); } @SuppressWarnings("unchecked") @Test public void minTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "minn","fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "int", "int"); + Collection intDate = getIntegerList("minn","fieldFacets", "date_dtd", "int", "int"); ArrayList intDateTest = (ArrayList)calculateStat(intDateTestStart, "min"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "minn","fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "int", "int"); + Collection intString = getIntegerList("minn","fieldFacets", "string_sd", "int", "int"); ArrayList intStringTest = (ArrayList)calculateStat(intStringTestStart, "min"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "minn","fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "long", "long"); + Collection longDate = getLongList("minn","fieldFacets", "date_dtd", "long", "long"); ArrayList longDateTest = (ArrayList)calculateStat(longDateTestStart, "min"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "minn","fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "long", "long"); + Collection longString = getLongList("minn","fieldFacets", "string_sd", "long", "long"); ArrayList longStringTest = (ArrayList)calculateStat(longStringTestStart, "min"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "minn","fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "float", "float"); + Collection floatDate = getFloatList("minn","fieldFacets", "date_dtd", "float", "float"); ArrayList floatDateTest = (ArrayList)calculateStat(floatDateTestStart, "min"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "minn","fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "float", "float"); + Collection floatString = getFloatList("minn","fieldFacets", "string_sd", "float", "float"); ArrayList floatStringTest = (ArrayList)calculateStat(floatStringTestStart, "min"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "minn","fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + Collection doubleDate = getDoubleList("minn","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = (ArrayList)calculateStat(doubleDateTestStart, "min"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "minn","fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + Collection doubleString = getDoubleList("minn","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = (ArrayList)calculateStat(doubleStringTestStart, "min"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); //Date Int - String dateIntFacet = getFacetXML(response, "min","fieldFacets", "int_id"); - Collection dateInt = (ArrayList)xmlToList(dateIntFacet, "date", "date"); + Collection dateInt = getStringList("min","fieldFacets", "int_id", "date", "date"); ArrayList dateIntTest = (ArrayList)calculateStat(dateIntTestStart, "min"); - assertEquals(dateInt,dateIntTest); + assertEquals(getRawResponse(),dateInt,dateIntTest); //Date Long - String dateStringFacet = getFacetXML(response, "min","fieldFacets", "long_ld"); - Collection dateString = (ArrayList)xmlToList(dateStringFacet, "date", "date"); + Collection dateString = getStringList("min","fieldFacets", "long_ld", "date", "date"); ArrayList dateLongTest = (ArrayList)calculateStat(dateLongTestStart, "min"); - assertEquals(dateString,dateLongTest); + assertEquals(getRawResponse(),dateString,dateLongTest); //String Int - String stringIntFacet = getFacetXML(response, "min","fieldFacets", "int_id"); - Collection stringInt = (ArrayList)xmlToList(stringIntFacet, "str", "str"); + Collection stringInt = getStringList("min","fieldFacets", "int_id", "str", "str"); ArrayList stringIntTest = (ArrayList)calculateStat(stringIntTestStart, "min"); - assertEquals(stringInt,stringIntTest); + assertEquals(getRawResponse(),stringInt,stringIntTest); //String Long - String stringLongFacet = getFacetXML(response, "min","fieldFacets", "long_ld"); - Collection stringLong = (ArrayList)xmlToList(stringLongFacet, "str", "str"); + Collection stringLong = getStringList("min","fieldFacets", "long_ld", "str", "str"); ArrayList stringLongTest = (ArrayList)calculateStat(stringLongTestStart, "min"); - assertEquals(stringLong,stringLongTest); + assertEquals(getRawResponse(),stringLong,stringLongTest); } @SuppressWarnings("unchecked") @Test public void maxTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "maxn","fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "int", "int"); + Collection intDate = getIntegerList("maxn","fieldFacets", "date_dtd", "int", "int"); ArrayList intDateTest = (ArrayList)calculateStat(intDateTestStart, "max"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "maxn","fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "int", "int"); + Collection intString = getIntegerList("maxn","fieldFacets", "string_sd", "int", "int"); ArrayList intStringTest = (ArrayList)calculateStat(intStringTestStart, "max"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "maxn","fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "long", "long"); + Collection longDate = getLongList("maxn","fieldFacets", "date_dtd", "long", "long"); ArrayList longDateTest = (ArrayList)calculateStat(longDateTestStart, "max"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "maxn","fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "long", "long"); + Collection longString = getLongList("maxn","fieldFacets", "string_sd", "long", "long"); ArrayList longStringTest = (ArrayList)calculateStat(longStringTestStart, "max"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "maxn","fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "float", "float"); + Collection floatDate = getFloatList("maxn","fieldFacets", "date_dtd", "float", "float"); ArrayList floatDateTest = (ArrayList)calculateStat(floatDateTestStart, "max"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "maxn","fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "float", "float"); + Collection floatString = getFloatList("maxn","fieldFacets", "string_sd", "float", "float"); ArrayList floatStringTest = (ArrayList)calculateStat(floatStringTestStart, "max"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "maxn","fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "double", "double"); + Collection doubleDate = getDoubleList("maxn","fieldFacets", "date_dtd", "double", "double"); ArrayList doubleDateTest = (ArrayList)calculateStat(doubleDateTestStart, "max"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "maxn","fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "double", "double"); + Collection doubleString = getDoubleList("maxn","fieldFacets", "string_sd", "double", "double"); ArrayList doubleStringTest = (ArrayList)calculateStat(doubleStringTestStart, "max"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); //String Int - String stringIntFacet = getFacetXML(response, "max","fieldFacets", "int_id"); - Collection stringInt = (ArrayList)xmlToList(stringIntFacet, "str", "str"); + Collection stringInt = getStringList("max","fieldFacets", "int_id", "str", "str"); ArrayList stringIntTest = (ArrayList)calculateStat(stringIntTestStart, "max"); - assertEquals(stringInt,stringIntTest); + assertEquals(getRawResponse(),stringInt,stringIntTest); //String Long - String stringLongFacet = getFacetXML(response, "max","fieldFacets", "long_ld"); - Collection stringLong = (ArrayList)xmlToList(stringLongFacet, "str", "str"); + Collection stringLong = getStringList("max","fieldFacets", "long_ld", "str", "str"); ArrayList stringLongTest = (ArrayList)calculateStat(stringLongTestStart, "max"); - assertEquals(stringLong,stringLongTest); + assertEquals(getRawResponse(),stringLong,stringLongTest); //Date Int - String dateIntFacet = getFacetXML(response, "max","fieldFacets", "int_id"); - Collection dateInt = (ArrayList)xmlToList(dateIntFacet, "date", "date"); + Collection dateInt = getStringList("max","fieldFacets", "int_id", "date", "date"); ArrayList dateIntTest = (ArrayList)calculateStat(dateIntTestStart, "max"); - assertEquals(dateInt,dateIntTest); + assertEquals(getRawResponse(),dateInt,dateIntTest); //Date Long - String dateStringFacet = getFacetXML(response, "max","fieldFacets", "long_ld"); - Collection dateString = (ArrayList)xmlToList(dateStringFacet, "date", "date"); + Collection dateString = getStringList("max","fieldFacets", "long_ld", "date", "date"); ArrayList dateLongTest = (ArrayList)calculateStat(dateLongTestStart, "max"); - assertEquals(dateString,dateLongTest); + assertEquals(getRawResponse(),dateString,dateLongTest); } @@ -924,274 +834,237 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{ @Test public void uniqueTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "uniquen", "fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "long", "int"); + Collection intDate = getLongList("uniquen", "fieldFacets", "date_dtd", "long", "int"); ArrayList intDateTest = (ArrayList)calculateStat(intDateTestStart, "unique"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "uniquen", "fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "long", "int"); + Collection intString = getLongList("uniquen", "fieldFacets", "string_sd", "long", "int"); ArrayList intStringTest = (ArrayList)calculateStat(intStringTestStart, "unique"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "uniquen", "fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "long", "long"); + Collection longDate = getLongList("uniquen", "fieldFacets", "date_dtd", "long", "long"); ArrayList longDateTest = (ArrayList)calculateStat(longDateTestStart, "unique"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "uniquen", "fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "long", "long"); + Collection longString = getLongList("uniquen", "fieldFacets", "string_sd", "long", "long"); ArrayList longStringTest = (ArrayList)calculateStat(longStringTestStart, "unique"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "uniquen", "fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "long", "float"); + Collection floatDate = getLongList("uniquen", "fieldFacets", "date_dtd", "long", "float"); ArrayList floatDateTest = (ArrayList)calculateStat(floatDateTestStart, "unique"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "uniquen", "fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "long", "float"); + Collection floatString = getLongList("uniquen", "fieldFacets", "string_sd", "long", "float"); ArrayList floatStringTest = (ArrayList)calculateStat(floatStringTestStart, "unique"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "uniquen", "fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "long", "double"); + Collection doubleDate = getLongList("uniquen", "fieldFacets", "date_dtd", "long", "double"); ArrayList doubleDateTest = (ArrayList)calculateStat(doubleDateTestStart, "unique"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "uniquen", "fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "long", "double"); + Collection doubleString = getLongList("uniquen", "fieldFacets", "string_sd", "long", "double"); ArrayList doubleStringTest = (ArrayList)calculateStat(doubleStringTestStart, "unique"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); //Date Int - String dateIntFacet = getFacetXML(response, "unique", "fieldFacets", "int_id"); - Collection dateInt = (ArrayList)xmlToList(dateIntFacet, "long", "date"); + Collection dateInt = getLongList("unique", "fieldFacets", "int_id", "long", "date"); ArrayList dateIntTest = (ArrayList)calculateStat(dateIntTestStart, "unique"); - assertEquals(dateInt,dateIntTest); + assertEquals(getRawResponse(),dateInt,dateIntTest); //Date Long - String dateStringFacet = getFacetXML(response, "unique", "fieldFacets", "long_ld"); - Collection dateString = (ArrayList)xmlToList(dateStringFacet, "long", "date"); + Collection dateString = getLongList("unique", "fieldFacets", "long_ld", "long", "date"); ArrayList dateLongTest = (ArrayList)calculateStat(dateLongTestStart, "unique"); - assertEquals(dateString,dateLongTest); + assertEquals(getRawResponse(),dateString,dateLongTest); //String Int - String stringIntFacet = getFacetXML(response, "unique", "fieldFacets", "int_id"); - Collection stringInt = (ArrayList)xmlToList(stringIntFacet, "long", "str"); + Collection stringInt = getLongList("unique", "fieldFacets", "int_id", "long", "str"); ArrayList stringIntTest = (ArrayList)calculateStat(stringIntTestStart, "unique"); - assertEquals(stringInt,stringIntTest); + assertEquals(getRawResponse(),stringInt,stringIntTest); //String Long - String stringLongFacet = getFacetXML(response, "unique", "fieldFacets", "long_ld"); - Collection stringLong = (ArrayList)xmlToList(stringLongFacet, "long", "str"); + Collection stringLong = getLongList("unique", "fieldFacets", "long_ld", "long", "str"); ArrayList stringLongTest = (ArrayList)calculateStat(stringLongTestStart, "unique"); - assertEquals(stringLong,stringLongTest); + assertEquals(getRawResponse(),stringLong,stringLongTest); } @SuppressWarnings("unchecked") @Test public void countTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "countn", "fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "long", "int"); + Collection intDate = getLongList("countn", "fieldFacets", "date_dtd", "long", "int"); ArrayList intDateTest = (ArrayList)calculateStat(intDateTestStart, "count"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); //Int String - String intStringFacet = getFacetXML(response, "countn", "fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "long", "int"); + Collection intString = getLongList("countn", "fieldFacets", "string_sd", "long", "int"); ArrayList intStringTest = (ArrayList)calculateStat(intStringTestStart, "count"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(),intString,intStringTest); //Long Date - String longDateFacet = getFacetXML(response, "countn", "fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "long", "long"); + Collection longDate = getLongList("countn", "fieldFacets", "date_dtd", "long", "long"); ArrayList longDateTest = (ArrayList)calculateStat(longDateTestStart, "count"); - assertEquals(longDate,longDateTest); + assertEquals(getRawResponse(),longDate,longDateTest); //Long String - String longStringFacet = getFacetXML(response, "countn", "fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "long", "long"); + Collection longString = getLongList("countn", "fieldFacets", "string_sd", "long", "long"); ArrayList longStringTest = (ArrayList)calculateStat(longStringTestStart, "count"); - assertEquals(longString,longStringTest); + assertEquals(getRawResponse(),longString,longStringTest); //Float Date - String floatDateFacet = getFacetXML(response, "countn", "fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "long", "float"); + Collection floatDate = getLongList("countn", "fieldFacets", "date_dtd", "long", "float"); ArrayList floatDateTest = (ArrayList)calculateStat(floatDateTestStart, "count"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(),floatDate,floatDateTest); //Float String - String floatStringFacet = getFacetXML(response, "countn", "fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "long", "float"); + Collection floatString = getLongList("countn", "fieldFacets", "string_sd", "long", "float"); ArrayList floatStringTest = (ArrayList)calculateStat(floatStringTestStart, "count"); - assertEquals(floatString,floatStringTest); + assertEquals(getRawResponse(),floatString,floatStringTest); //Double Date - String doubleDateFacet = getFacetXML(response, "countn", "fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "long", "double"); + Collection doubleDate = getLongList("countn", "fieldFacets", "date_dtd", "long", "double"); ArrayList doubleDateTest = (ArrayList)calculateStat(doubleDateTestStart, "count"); - assertEquals(doubleDate,doubleDateTest); + assertEquals(getRawResponse(),doubleDate,doubleDateTest); //Double String - String doubleStringFacet = getFacetXML(response, "countn", "fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "long", "double"); + Collection doubleString = getLongList("countn", "fieldFacets", "string_sd", "long", "double"); ArrayList doubleStringTest = (ArrayList)calculateStat(doubleStringTestStart, "count"); - assertEquals(doubleString,doubleStringTest); + assertEquals(getRawResponse(),doubleString,doubleStringTest); //Date Int - String dateIntFacet = getFacetXML(response, "count", "fieldFacets", "int_id"); - Collection dateInt = (ArrayList)xmlToList(dateIntFacet, "long", "date"); + Collection dateInt = getLongList("count", "fieldFacets", "int_id", "long", "date"); ArrayList dateIntTest = (ArrayList)calculateStat(dateIntTestStart, "count"); - assertEquals(dateIntTest,dateInt); + assertEquals(getRawResponse(),dateIntTest,dateInt); //Date Long - String dateLongFacet = getFacetXML(response, "count", "fieldFacets", "long_ld"); - Collection dateLong = (ArrayList)xmlToList(dateLongFacet, "long", "date"); + Collection dateLong = getLongList("count", "fieldFacets", "long_ld", "long", "date"); ArrayList dateLongTest = (ArrayList)calculateStat(dateLongTestStart, "count"); - assertEquals(dateLong,dateLongTest); + assertEquals(getRawResponse(),dateLong,dateLongTest); //String Int - String stringIntFacet = getFacetXML(response, "count", "fieldFacets", "int_id"); - Collection stringInt = (ArrayList)xmlToList(stringIntFacet, "long", "str"); + Collection stringInt = getLongList("count", "fieldFacets", "int_id", "long", "str"); ArrayList stringIntTest = (ArrayList)calculateStat(stringIntTestStart, "count"); - assertEquals(stringInt,stringIntTest); + assertEquals(getRawResponse(),stringInt,stringIntTest); //String Long - String stringLongFacet = getFacetXML(response, "count", "fieldFacets", "long_ld"); - Collection stringLong = (ArrayList)xmlToList(stringLongFacet, "long", "str"); + Collection stringLong = getLongList("count", "fieldFacets", "long_ld", "long", "str"); ArrayList stringLongTest = (ArrayList)calculateStat(stringLongTestStart, "count"); - assertEquals(stringLong,stringLongTest); + assertEquals(getRawResponse(),stringLong,stringLongTest); } @SuppressWarnings("unchecked") @Test public void missingTest() throws Exception { //Int Date - String intDateFacet = getFacetXML(response, "missingn", "fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "long", "int"); + Collection intDate = getLongList("missingn", "fieldFacets", "date_dtd", "long", "int"); setLatestType("int"); - assertEquals(intDateTestMissing,intDate); + assertEquals(getRawResponse(),intDateTestMissing,intDate); //Int String - String intStringFacet = getFacetXML(response, "missingn", "fieldFacets", "string_sd"); - Collection intString = (ArrayList)xmlToList(intStringFacet, "long", "int"); - assertEquals(intStringTestMissing,intString); + Collection intString = getLongList("missingn", "fieldFacets", "string_sd", "long", "int"); + assertEquals(getRawResponse(),intStringTestMissing,intString); //Long Date - String longDateFacet = getFacetXML(response, "missingn", "fieldFacets", "date_dtd"); - Collection longDate = (ArrayList)xmlToList(longDateFacet, "long", "long"); + Collection longDate = getLongList("missingn", "fieldFacets", "date_dtd", "long", "long"); setLatestType("long"); - assertEquals(longDateTestMissing,longDate); + assertEquals(getRawResponse(),longDateTestMissing,longDate); //Long String - String longStringFacet = getFacetXML(response, "missingn", "fieldFacets", "string_sd"); - Collection longString = (ArrayList)xmlToList(longStringFacet, "long", "long"); - assertEquals(longStringTestMissing,longString); + Collection longString = getLongList("missingn", "fieldFacets", "string_sd", "long", "long"); + assertEquals(getRawResponse(),longStringTestMissing,longString); //Float Date - String floatDateFacet = getFacetXML(response, "missingn", "fieldFacets", "date_dtd"); - Collection floatDate = (ArrayList)xmlToList(floatDateFacet, "long", "float"); + Collection floatDate = getLongList("missingn", "fieldFacets", "date_dtd", "long", "float"); setLatestType("float"); - assertEquals(floatDateTestMissing,floatDate); + assertEquals(getRawResponse(),floatDateTestMissing,floatDate); //Float String - String floatStringFacet = getFacetXML(response, "missingn", "fieldFacets", "string_sd"); - Collection floatString = (ArrayList)xmlToList(floatStringFacet, "long", "float"); - assertEquals(floatStringTestMissing,floatString); + Collection floatString = getLongList("missingn", "fieldFacets", "string_sd", "long", "float"); + assertEquals(getRawResponse(),floatStringTestMissing,floatString); //Double Date - String doubleDateFacet = getFacetXML(response, "missingn", "fieldFacets", "date_dtd"); - Collection doubleDate = (ArrayList)xmlToList(doubleDateFacet, "long", "double"); + Collection doubleDate = getLongList("missingn", "fieldFacets", "date_dtd", "long", "double"); setLatestType("double"); - assertEquals(doubleDateTestMissing,doubleDate); + assertEquals(getRawResponse(),doubleDateTestMissing,doubleDate); //Double String - String doubleStringFacet = getFacetXML(response, "missingn", "fieldFacets", "string_sd"); - Collection doubleString = (ArrayList)xmlToList(doubleStringFacet, "long", "double"); - assertEquals(doubleStringTestMissing,doubleString); + Collection doubleString = getLongList("missingn", "fieldFacets", "string_sd", "long", "double"); + assertEquals(getRawResponse(),doubleStringTestMissing,doubleString); //Date Int - String dateIntFacet = getFacetXML(response, "missing", "fieldFacets", "int_id"); - Collection dateInt = (ArrayList)xmlToList(dateIntFacet, "long", "date"); + Collection dateInt = getLongList("missing", "fieldFacets", "int_id", "long", "date"); setLatestType("date"); - assertEquals(dateIntTestMissing,dateInt); + assertEquals(getRawResponse(),dateIntTestMissing,dateInt); //Date Long - String dateStringFacet = getFacetXML(response, "missing", "fieldFacets", "long_ld"); - Collection dateLong = (ArrayList)xmlToList(dateStringFacet, "long", "date"); - assertEquals(dateLongTestMissing,dateLong); + Collection dateLong = getLongList("missing", "fieldFacets", "long_ld", "long", "date"); + assertEquals(getRawResponse(),dateLongTestMissing,dateLong); //String Int - String stringIntFacet = getFacetXML(response, "missing", "fieldFacets", "int_id"); - Collection stringInt = (ArrayList)xmlToList(stringIntFacet, "long", "str"); + Collection stringInt = getLongList("missing", "fieldFacets", "int_id", "long", "str"); setLatestType("string"); - assertEquals(stringIntTestMissing,stringInt); + assertEquals(getRawResponse(),stringIntTestMissing,stringInt); //String Long - String stringLongFacet = getFacetXML(response, "missing", "fieldFacets", "long_ld"); - Collection stringLong = (ArrayList)xmlToList(stringLongFacet, "long", "str"); - assertEquals(stringLongTestMissing,stringLong); + Collection stringLong = getLongList("missing", "fieldFacets", "long_ld", "long", "str"); + assertEquals(getRawResponse(),stringLongTestMissing,stringLong); } @SuppressWarnings("unchecked") @Test public void multiValueTest() throws Exception { //Long - String longFacet = getFacetXML(response, "multivalued", "fieldFacets", "long_ldm"); - Collection lon = (ArrayList)xmlToList(longFacet, "double", "mean"); + Collection lon = getDoubleList("multivalued", "fieldFacets", "long_ldm", "double", "mean"); ArrayList longTest = calculateNumberStat(multiLongTestStart, "mean"); - assertEquals(lon,longTest); + assertEquals(getRawResponse(),lon,longTest); //Date - String dateFacet = getFacetXML(response, "multivalued", "fieldFacets", "date_dtdm"); - Collection date = (ArrayList)xmlToList(dateFacet, "double", "mean"); + Collection date = getDoubleList("multivalued", "fieldFacets", "date_dtdm", "double", "mean"); ArrayList dateTest = calculateNumberStat(multiDateTestStart, "mean"); - assertEquals(date,dateTest); + assertEquals(getRawResponse(),date,dateTest); //String - String stringFacet = getFacetXML(response, "multivalued", "fieldFacets", "string_sdm"); - Collection string = (ArrayList)xmlToList(stringFacet, "double", "mean"); + Collection string = getDoubleList("multivalued", "fieldFacets", "string_sdm", "double", "mean"); ArrayList stringTest = calculateNumberStat(multiStringTestStart, "mean"); - assertEquals(string,stringTest); + assertEquals(getRawResponse(),string,stringTest); } @SuppressWarnings("unchecked") @Test public void missingFacetTest() throws Exception { //int MultiDate - String stringFacet = getFacetXML(response, "missingf", "fieldFacets", "date_dtdm"); - assertTrue(stringFacet.contains("")); - ArrayList string = (ArrayList)xmlToList(stringFacet, "double", "mean"); + String xPath = "/response/lst[@name='stats']/lst[@name='missingf']/lst[@name='fieldFacets']/lst[@name='date_dtdm']/lst[@name='(MISSING)']"; + assertNotNull(getRawResponse(), getNode(xPath)); + + ArrayList string = getDoubleList("missingf", "fieldFacets", "date_dtdm", "double", "mean"); string.remove(0); ArrayList stringTest = calculateNumberStat(multiDateTestStart, "mean"); - assertEquals(string,stringTest); + assertEquals(getRawResponse(), string,stringTest); //Int String - String intStringFacet = getFacetXML(response, "missingf", "fieldFacets", "string_sd"); - assertTrue(intStringFacet.contains("")&&!intStringFacet.contains("")); - List intString = (ArrayList)xmlToList(intStringFacet, "double", "mean"); + xPath = "/response/lst[@name='stats']/lst[@name='missingf']/lst[@name='fieldFacets']/lst[@name='string_sd']/lst[@name='(MISSING)']"; + assertNotNull(getRawResponse(), getNode(xPath)); + + xPath = "/response/lst[@name='stats']/lst[@name='missingf']/lst[@name='fieldFacets']/lst[@name='string_sd']/lst[@name='str0']"; + assertNull(getRawResponse(), getNode(xPath)); + List intString = getDoubleList("missingf", "fieldFacets", "string_sd", "double", "mean"); intString.remove(0); ArrayList intStringTest = calculateNumberStat(intStringTestStart, "mean"); - assertEquals(intString,intStringTest); + assertEquals(getRawResponse(), intString,intStringTest); //Int Date - String intDateFacet = getFacetXML(response, "missingf", "fieldFacets", "date_dtd"); - Collection intDate = (ArrayList)xmlToList(intDateFacet, "double", "mean"); + Collection intDate = getDoubleList("missingf", "fieldFacets", "date_dtd", "double", "mean"); ArrayList> intDateMissingTestStart = (ArrayList>) intDateTestStart.clone(); ArrayList intDateTest = calculateNumberStat(intDateMissingTestStart, "mean"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(),intDate,intDateTest); } - private boolean checkStddevs(ArrayList list1, ArrayList list2) { + private void checkStddevs(ArrayList list1, ArrayList list2) { for (int i = 0; i int1 = (ArrayList)xmlToList(int1Query, "double", "sum"); + ArrayList int1 = getDoubleList("ir", "queryFacets", "float1", "double", "sum"); ArrayList int1Test = calculateNumberStat(int1TestStart, "sum"); - assertEquals(int1,int1Test); + assertEquals(getRawResponse(), int1, int1Test); //Int Two - String int2Query = getFacetXML(response, "ir", "queryFacets", "float2"); - ArrayList int2 = (ArrayList)xmlToList(int2Query, "int", "percentile_8"); + ArrayList int2 = getIntegerList("ir", "queryFacets", "float2", "int", "percentile_8"); ArrayList int2Test = (ArrayList)calculateStat(int2TestStart, "perc_8"); - assertEquals(int2,int2Test); + assertEquals(getRawResponse(), int2, int2Test); //Long - String long1Query = getFacetXML(response, "lr", "queryFacets", "string"); - ArrayList long1 = (ArrayList)xmlToList(long1Query, "double", "median"); + ArrayList long1 = getDoubleList("lr", "queryFacets", "string", "double", "median"); ArrayList long1Test = calculateNumberStat(longTestStart, "median"); - assertEquals(long1,long1Test); + assertEquals(getRawResponse(),long1,long1Test); //Float - String float1Query = getFacetXML(response, "fr", "queryFacets", "lad"); - ArrayList float1 = (ArrayList)xmlToList(float1Query, "double", "mean"); + ArrayList float1 = getDoubleList("fr", "queryFacets", "lad", "double", "mean"); ArrayList float1Test = calculateNumberStat(floatTestStart, "mean"); - assertEquals(float1,float1Test); + assertEquals(getRawResponse(), float1, float1Test); } } diff --git a/solr/core/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java b/solr/core/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java index 6e9562b101d..e62f7ec52ce 100644 --- a/solr/core/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java +++ b/solr/core/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java @@ -47,8 +47,6 @@ public class RangeFacetTest extends AbstractAnalyticsFacetTest { static ArrayList> floatDoubleTestStart; static ArrayList> floatDateTestStart; - static String response; - @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-basic.xml","schema-analytics.xml"); @@ -117,7 +115,7 @@ public class RangeFacetTest extends AbstractAnalyticsFacetTest { assertU(commit()); - response = h.query(request(fileToStringArr(fileName))); + setResponse(h.query(request(fileToStringArr(fileName)))); } @SuppressWarnings("unchecked") @@ -125,42 +123,36 @@ public class RangeFacetTest extends AbstractAnalyticsFacetTest { public void rangeTest() throws Exception { //Int Long - String intLongRange = getFacetXML(response, "ri", "rangeFacets", "long_ld"); - ArrayList intLong = (ArrayList)xmlToList(intLongRange, "long", "count"); + ArrayList intLong = getLongList("ri", "rangeFacets", "long_ld", "long", "count"); ArrayList intLongTest = calculateStat(transformLists(intLongTestStart, 5, 30, 5 , false, true, false, false, false), "count"); - assertEquals(intLong,intLongTest); + assertEquals(getRawResponse(), intLong,intLongTest); //Int Double - String intDoubleRange = getFacetXML(response, "ri", "rangeFacets", "double_dd"); - ArrayList intDouble = (ArrayList)xmlToList(intDoubleRange, "double", "mean"); + ArrayList intDouble = getDoubleList("ri", "rangeFacets", "double_dd", "double", "mean"); ArrayList intDoubleTest = calculateNumberStat(transformLists(intDoubleTestStart, 3, 39, 7 , false, false, true, false, true), "mean"); - assertEquals(intDouble,intDoubleTest); + assertEquals(getRawResponse(), intDouble,intDoubleTest); //Int Date - String intDateRange = getFacetXML(response, "ri", "rangeFacets", "date_dtd"); - ArrayList intDate = (ArrayList)xmlToList(intDateRange, "long", "count"); + ArrayList intDate = getLongList("ri", "rangeFacets", "date_dtd", "long", "count"); ArrayList intDateTest = (ArrayList)calculateStat(transformLists(intDateTestStart, 7, 44, 7 , false, true, false, true, true), "count"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(), intDate,intDateTest); //Float Long - String floatLongRange = getFacetXML(response, "rf", "rangeFacets", "long_ld"); - ArrayList floatLong = (ArrayList)xmlToList(floatLongRange, "double", "median"); + ArrayList floatLong = getDoubleList("rf", "rangeFacets", "long_ld", "double", "median"); ArrayList floatLongTest = calculateNumberStat(transformLists(floatLongTestStart, 0, 29, 4 , false, true, true, true, true), "median"); - assertEquals(floatLong,floatLongTest); + assertEquals(getRawResponse(), floatLong,floatLongTest); //Float Double - String floatDoubleRange = getFacetXML(response, "rf", "rangeFacets", "double_dd"); - ArrayList floatDouble = (ArrayList)xmlToList(floatDoubleRange, "long", "count"); + ArrayList floatDouble = getLongList("rf", "rangeFacets", "double_dd", "long", "count"); ArrayList floatDoubleTest = (ArrayList)calculateStat(transformLists(floatDoubleTestStart, 4, 47, 11 , false, false, false, true, false), "count"); - assertEquals(floatDouble,floatDoubleTest); + assertEquals(getRawResponse(), floatDouble,floatDoubleTest); //Float Date - String floatDateRange = getFacetXML(response, "rf", "rangeFacets", "date_dtd"); - ArrayList floatDate = (ArrayList)xmlToList(floatDateRange, "double", "sumOfSquares"); + ArrayList floatDate = getDoubleList("rf", "rangeFacets", "date_dtd", "double", "sumOfSquares"); ArrayList floatDateTest = calculateNumberStat(transformLists(floatDateTestStart, 4, 46, 5 , false, false, true, true, false), "sumOfSquares"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(), floatDate,floatDateTest); } @@ -168,84 +160,72 @@ public class RangeFacetTest extends AbstractAnalyticsFacetTest { @Test public void hardendRangeTest() throws Exception { //Int Long - String intLongRange = getFacetXML(response, "hi", "rangeFacets", "long_ld"); - ArrayList intLong = (ArrayList)xmlToList(intLongRange, "double", "sum"); + ArrayList intLong = getDoubleList("hi", "rangeFacets", "long_ld", "double", "sum"); ArrayList intLongTest = calculateNumberStat(transformLists(intLongTestStart, 5, 30, 5 , true, true, false, false, false), "sum"); - assertEquals(intLong,intLongTest); + assertEquals(getRawResponse(), intLong,intLongTest); //Int Double - String intDoubleRange = getFacetXML(response, "hi", "rangeFacets", "double_dd"); - ArrayList intDouble = (ArrayList)xmlToList(intDoubleRange, "double", "mean"); + ArrayList intDouble = getDoubleList("hi", "rangeFacets", "double_dd", "double", "mean"); ArrayList intDoubleTest = calculateNumberStat(transformLists(intDoubleTestStart, 3, 39, 7 , true, false, true, false, true), "mean"); - assertEquals(intDouble,intDoubleTest); + assertEquals(getRawResponse(), intDouble,intDoubleTest); //Int Date - String intDateRange = getFacetXML(response, "hi", "rangeFacets", "date_dtd"); - ArrayList intDate = (ArrayList)xmlToList(intDateRange, "long", "count"); + ArrayList intDate = getLongList("hi", "rangeFacets", "date_dtd", "long", "count"); ArrayList intDateTest = (ArrayList)calculateStat(transformLists(intDateTestStart, 7, 44, 7 , true, true, false, true, true), "count"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(), intDate,intDateTest); //Float Long - String floatLongRange = getFacetXML(response, "hf", "rangeFacets", "long_ld"); - ArrayList floatLong = (ArrayList)xmlToList(floatLongRange, "double", "median"); + ArrayList floatLong = getDoubleList("hf", "rangeFacets", "long_ld", "double", "median"); ArrayList floatLongTest = calculateNumberStat(transformLists(floatLongTestStart, 0, 29, 4 , true, true, true, true, true), "median"); - assertEquals(floatLong,floatLongTest); + assertEquals(getRawResponse(), floatLong,floatLongTest); //Float Double - String floatDoubleRange = getFacetXML(response, "hf", "rangeFacets", "double_dd"); - ArrayList floatDouble = (ArrayList)xmlToList(floatDoubleRange, "long", "count"); + ArrayList floatDouble = getLongList("hf", "rangeFacets", "double_dd", "long", "count"); ArrayList floatDoubleTest = (ArrayList)calculateStat(transformLists(floatDoubleTestStart, 4, 47, 11 , true, false, false, true, false), "count"); - assertEquals(floatDouble,floatDoubleTest); + assertEquals(getRawResponse(), floatDouble,floatDoubleTest); //Float Date - String floatDateRange = getFacetXML(response, "hf", "rangeFacets", "date_dtd"); - ArrayList floatDate = (ArrayList)xmlToList(floatDateRange, "double", "sumOfSquares"); + ArrayList floatDate = getDoubleList("hf", "rangeFacets", "date_dtd", "double", "sumOfSquares"); ArrayList floatDateTest = calculateNumberStat(transformLists(floatDateTestStart, 4, 46, 5 , true, false, true, true, false), "sumOfSquares"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(), floatDate,floatDateTest); } @SuppressWarnings("unchecked") @Test public void multiGapTest() throws Exception { //Int Long - String intLongRange = getFacetXML(response, "mi", "rangeFacets", "long_ld"); - ArrayList intLong = (ArrayList)xmlToList(intLongRange, "double", "sum"); + ArrayList intLong = getDoubleList("mi", "rangeFacets", "long_ld", "double", "sum"); ArrayList intLongTest = calculateNumberStat(transformLists(intLongTestStart, 5, 30, "4,2,6,3" , false, true, false, false, false), "sum"); - assertEquals(intLong,intLongTest); + assertEquals(getRawResponse(), intLong,intLongTest); //Int Double - String intDoubleRange = getFacetXML(response, "mi", "rangeFacets", "double_dd"); - ArrayList intDouble = (ArrayList)xmlToList(intDoubleRange, "double", "mean"); + ArrayList intDouble = getDoubleList("mi", "rangeFacets", "double_dd", "double", "mean"); ArrayList intDoubleTest = calculateNumberStat(transformLists(intDoubleTestStart, 3, 39, "3,1,7" , false, false, true, false, true), "mean"); - assertEquals(intDouble,intDoubleTest); + assertEquals(getRawResponse(), intDouble,intDoubleTest); //Int Date - String intDateRange = getFacetXML(response, "mi", "rangeFacets", "date_dtd"); - ArrayList intDate = (ArrayList)xmlToList(intDateRange, "long", "count"); + ArrayList intDate = getLongList("mi", "rangeFacets", "date_dtd", "long", "count"); ArrayList intDateTest = (ArrayList)calculateStat(transformLists(intDateTestStart, 7, 44, "2,7" , false, true, false, true, true), "count"); - assertEquals(intDate,intDateTest); + assertEquals(getRawResponse(), intDate,intDateTest); //Float Long - String floatLongRange = getFacetXML(response, "mf", "rangeFacets", "long_ld"); - ArrayList floatLong = (ArrayList)xmlToList(floatLongRange, "double", "median"); + ArrayList floatLong = getDoubleList("mf", "rangeFacets", "long_ld", "double", "median"); ArrayList floatLongTest = calculateNumberStat(transformLists(floatLongTestStart, 0, 29, "1,4" , false, true, true, true, true), "median");; - assertEquals(floatLong,floatLongTest); + assertEquals(getRawResponse(), floatLong,floatLongTest); //Float Double - String floatDoubleRange = getFacetXML(response, "mf", "rangeFacets", "double_dd"); - ArrayList floatDouble = (ArrayList)xmlToList(floatDoubleRange, "long", "count"); + ArrayList floatDouble = getLongList("mf", "rangeFacets", "double_dd", "long", "count"); ArrayList floatDoubleTest = (ArrayList)calculateStat(transformLists(floatDoubleTestStart, 4, 47, "2,3,11" , false, false, false, true, false), "count"); - assertEquals(floatDouble,floatDoubleTest); + assertEquals(getRawResponse(), floatDouble,floatDoubleTest); //Float Date - String floatDateRange = getFacetXML(response, "mf", "rangeFacets", "date_dtd"); - ArrayList floatDate = (ArrayList)xmlToList(floatDateRange, "double", "sumOfSquares"); + ArrayList floatDate = getDoubleList("mf", "rangeFacets", "date_dtd", "double", "sumOfSquares"); ArrayList floatDateTest = calculateNumberStat(transformLists(floatDateTestStart, 4, 46, "4,5" , false, false, true, true, false), "sumOfSquares"); - assertEquals(floatDate,floatDateTest); + assertEquals(getRawResponse(), floatDate,floatDateTest); } private ArrayList> transformLists(ArrayList> listsStart, int start, int end, int gap