mirror of https://github.com/apache/lucene.git
SOLR-5488: Added DOM parsing to the test cases rather than string manipulation
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1545080 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aca845c6a0
commit
0e19da794b
|
@ -17,12 +17,15 @@
|
||||||
|
|
||||||
package org.apache.solr.analytics;
|
package org.apache.solr.analytics;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -35,32 +38,75 @@ import org.apache.solr.request.SolrQueryRequest;
|
||||||
import com.google.common.collect.ObjectArrays;
|
import com.google.common.collect.ObjectArrays;
|
||||||
import org.apache.solr.util.ExternalPaths;
|
import org.apache.solr.util.ExternalPaths;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
@SuppressCodecs({"Lucene3x","Lucene40","Lucene41","Lucene42","Appending","Asserting"})
|
@SuppressCodecs({"Lucene3x","Lucene40","Lucene41","Lucene42","Appending","Asserting"})
|
||||||
public class AbstractAnalyticsStatsTest extends SolrTestCaseJ4 {
|
public class AbstractAnalyticsStatsTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
protected static final String[] BASEPARMS = new String[]{ "q", "*:*", "indent", "true", "olap", "true", "rows", "0" };
|
protected static final String[] BASEPARMS = new String[]{ "q", "*:*", "indent", "true", "olap", "true", "rows", "0" };
|
||||||
protected static final HashMap<String,Object> defaults = new HashMap<String,Object>();
|
protected static final HashMap<String,Object> defaults = new HashMap<String,Object>();
|
||||||
|
|
||||||
public Object getStatResult(String response, String request, String type, String name) {
|
public static enum VAL_TYPE {
|
||||||
String cat = "\n <lst name=\""+request+"\">";
|
INTEGER("int"),
|
||||||
String begin = "<"+type+" name=\""+name+"\">";
|
LONG("long"),
|
||||||
String end = "</"+type+">";
|
FLOAT("float"),
|
||||||
int beginInt = response.indexOf(begin, response.indexOf(cat))+begin.length();
|
DOUBLE("double"),
|
||||||
int endInt = response.indexOf(end, beginInt);
|
STRING("str"),
|
||||||
String resultStr = response.substring(beginInt, endInt);
|
DATE("date");
|
||||||
if (type.equals("double")) {
|
|
||||||
return Double.parseDouble(resultStr);
|
private VAL_TYPE (final String text) {
|
||||||
} else if (type.equals("int")) {
|
this.text = text;
|
||||||
return Integer.parseInt(resultStr);
|
}
|
||||||
} else if (type.equals("long")) {
|
|
||||||
return Long.parseLong(resultStr);
|
private final String text;
|
||||||
} else if (type.equals("float")) {
|
|
||||||
return Float.parseFloat(resultStr);
|
@Override
|
||||||
} else {
|
public String toString() {
|
||||||
return resultStr;
|
return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static private Document doc;
|
||||||
|
static private XPathFactory xPathFact = XPathFactory.newInstance();
|
||||||
|
|
||||||
|
public 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())));
|
||||||
|
xPathFact = XPathFactory.newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getStatResult(String section, String name, VAL_TYPE type) 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(section).append("']");
|
||||||
|
|
||||||
|
// This is a little fragile in that it demands the elements have the same name as type, i.e. when looking for a
|
||||||
|
// VAL_TYPE.DOUBLE, the element in question is <double name="blah">47.0</double>.
|
||||||
|
sb.append("/").append(type.toString()).append("[@name='").append(name).append("']");
|
||||||
|
String val = xPathFact.newXPath().compile(sb.toString()).evaluate(doc, XPathConstants.STRING).toString();
|
||||||
|
switch (type) {
|
||||||
|
case INTEGER: return Integer.parseInt(val);
|
||||||
|
case DOUBLE: return Double.parseDouble(val);
|
||||||
|
case FLOAT: return Float.parseFloat(val);
|
||||||
|
case LONG: return Long.parseLong(val);
|
||||||
|
case STRING: return val;
|
||||||
|
case DATE: return val;
|
||||||
|
}
|
||||||
|
fail("Unknown type used in getStatResult");
|
||||||
|
return null; // Really can't get here, but the compiler thinks we can!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public <T extends Number & Comparable<T>> Double calculateNumberStat(ArrayList<T> list, String stat) {
|
public <T extends Number & Comparable<T>> Double calculateNumberStat(ArrayList<T> list, String stat) {
|
||||||
Double result;
|
Double result;
|
||||||
if (stat.equals("median")) {
|
if (stat.equals("median")) {
|
||||||
|
|
|
@ -58,12 +58,10 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
static ArrayList<String> dateTestStart;
|
static ArrayList<String> dateTestStart;
|
||||||
static long dateMissing = 0;
|
static long dateMissing = 0;
|
||||||
|
|
||||||
//STRING
|
//STR
|
||||||
static ArrayList<String> stringTestStart;
|
static ArrayList<String> stringTestStart;
|
||||||
static long stringMissing = 0;
|
static long stringMissing = 0;
|
||||||
|
|
||||||
static String response;
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
initCore("solrconfig-basic.xml","schema-analytics.xml");
|
initCore("solrconfig-basic.xml","schema-analytics.xml");
|
||||||
|
@ -138,51 +136,51 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
assertU(commit());
|
assertU(commit());
|
||||||
|
|
||||||
//Sort ascending tests
|
//Sort ascending tests
|
||||||
response = h.query(request(fileToStringArr(fileName)));
|
setResponse(h.query(request(fileToStringArr(fileName))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sumTest() throws Exception {
|
public void sumTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Double intResult = (Double)getStatResult(response, "sr", "double", "int_id");
|
Double intResult = (Double)getStatResult("sr", "int_id", VAL_TYPE.DOUBLE);
|
||||||
Double intTest = (Double)calculateNumberStat(intTestStart, "sum");
|
Double intTest = (Double)calculateNumberStat(intTestStart, "sum");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Double longResult = (Double)getStatResult(response, "sr", "double", "long_ld");
|
Double longResult = (Double)getStatResult("sr", "long_ld", VAL_TYPE.DOUBLE);
|
||||||
Double longTest = (Double)calculateNumberStat(longTestStart, "sum");
|
Double longTest = (Double)calculateNumberStat(longTestStart, "sum");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Double floatResult = (Double)getStatResult(response, "sr", "double", "float_fd");
|
Double floatResult = (Double)getStatResult("sr", "float_fd", VAL_TYPE.DOUBLE);
|
||||||
Double floatTest = (Double)calculateNumberStat(floatTestStart, "sum");
|
Double floatTest = (Double)calculateNumberStat(floatTestStart, "sum");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Double doubleResult = (Double)getStatResult(response, "sr", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("sr", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "sum");
|
Double doubleTest = (Double) calculateNumberStat(doubleTestStart, "sum");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sumOfSquaresTest() throws Exception {
|
public void sumOfSquaresTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Double intResult = (Double)getStatResult(response, "sosr", "double", "int_id");
|
Double intResult = (Double)getStatResult("sosr", "int_id", VAL_TYPE.DOUBLE);
|
||||||
Double intTest = (Double)calculateNumberStat(intTestStart, "sumOfSquares");
|
Double intTest = (Double)calculateNumberStat(intTestStart, "sumOfSquares");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Double longResult = (Double)getStatResult(response, "sosr", "double", "long_ld");
|
Double longResult = (Double)getStatResult("sosr", "long_ld", VAL_TYPE.DOUBLE);
|
||||||
Double longTest = (Double)calculateNumberStat(longTestStart, "sumOfSquares");
|
Double longTest = (Double)calculateNumberStat(longTestStart, "sumOfSquares");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Double floatResult = (Double)getStatResult(response, "sosr", "double", "float_fd");
|
Double floatResult = (Double)getStatResult("sosr", "float_fd", VAL_TYPE.DOUBLE);
|
||||||
Double floatTest = (Double)calculateNumberStat(floatTestStart, "sumOfSquares");
|
Double floatTest = (Double)calculateNumberStat(floatTestStart, "sumOfSquares");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Double doubleResult = (Double)getStatResult(response, "sosr", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("sosr", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "sumOfSquares");
|
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "sumOfSquares");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
}
|
}
|
||||||
|
@ -190,22 +188,22 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void meanTest() throws Exception {
|
public void meanTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Double intResult = (Double)getStatResult(response, "mr", "double", "int_id");
|
Double intResult = (Double)getStatResult("mr", "int_id", VAL_TYPE.DOUBLE);
|
||||||
Double intTest = (Double)calculateNumberStat(intTestStart, "mean");
|
Double intTest = (Double)calculateNumberStat(intTestStart, "mean");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Double longResult = (Double)getStatResult(response, "mr", "double", "long_ld");
|
Double longResult = (Double)getStatResult("mr", "long_ld", VAL_TYPE.DOUBLE);
|
||||||
Double longTest = (Double)calculateNumberStat(longTestStart, "mean");
|
Double longTest = (Double)calculateNumberStat(longTestStart, "mean");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Double floatResult = (Double)getStatResult(response, "mr", "double", "float_fd");
|
Double floatResult = (Double)getStatResult("mr", "float_fd", VAL_TYPE.DOUBLE);
|
||||||
Double floatTest = (Double)calculateNumberStat(floatTestStart, "mean");
|
Double floatTest = (Double)calculateNumberStat(floatTestStart, "mean");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Double doubleResult = (Double)getStatResult(response, "mr", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("mr", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "mean");
|
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "mean");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
}
|
}
|
||||||
|
@ -213,17 +211,17 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test @Ignore("SOLR-5488")
|
@Test @Ignore("SOLR-5488")
|
||||||
public void stddevTest() throws Exception {
|
public void stddevTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Double intResult = (Double)getStatResult(response, "str", "double", "int_id");
|
Double intResult = (Double)getStatResult("str", "int_id", VAL_TYPE.DOUBLE);
|
||||||
Double intTest = (Double)calculateNumberStat(intTestStart, "stddev");
|
Double intTest = (Double)calculateNumberStat(intTestStart, "stddev");
|
||||||
assertTrue(Math.abs(intResult-intTest)<.00000000001);
|
assertTrue(Math.abs(intResult-intTest)<.00000000001);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Double longResult = (Double)getStatResult(response, "str", "double", "long_ld");
|
Double longResult = (Double)getStatResult("str", "long_ld", VAL_TYPE.DOUBLE);
|
||||||
Double longTest = (Double)calculateNumberStat(longTestStart, "stddev");
|
Double longTest = (Double)calculateNumberStat(longTestStart, "stddev");
|
||||||
assertTrue(Math.abs(longResult-longTest)<.00000000001);
|
assertTrue(Math.abs(longResult-longTest)<.00000000001);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Double floatResult = (Double)getStatResult(response, "str", "double", "float_fd");
|
Double floatResult = (Double)getStatResult("str", "float_fd", VAL_TYPE.DOUBLE);
|
||||||
Double floatTest = (Double)calculateNumberStat(floatTestStart, "stddev");
|
Double floatTest = (Double)calculateNumberStat(floatTestStart, "stddev");
|
||||||
assertTrue("Oops: (double raws) " + Double.doubleToRawLongBits(floatResult) + " - "
|
assertTrue("Oops: (double raws) " + Double.doubleToRawLongBits(floatResult) + " - "
|
||||||
+ Double.doubleToRawLongBits(floatTest) + " < " + Double.doubleToRawLongBits(.00000000001) +
|
+ Double.doubleToRawLongBits(floatTest) + " < " + Double.doubleToRawLongBits(.00000000001) +
|
||||||
|
@ -234,7 +232,7 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
|
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Double doubleResult = (Double)getStatResult(response, "str", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("str", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "stddev");
|
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "stddev");
|
||||||
assertTrue(Math.abs(doubleResult-doubleTest)<.00000000001);
|
assertTrue(Math.abs(doubleResult-doubleTest)<.00000000001);
|
||||||
}
|
}
|
||||||
|
@ -242,22 +240,22 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void medianTest() throws Exception {
|
public void medianTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Double intResult = (Double)getStatResult(response, "medr", "double", "int_id");
|
Double intResult = (Double)getStatResult("medr", "int_id", VAL_TYPE.DOUBLE);
|
||||||
Double intTest = (Double)calculateNumberStat(intTestStart, "median");
|
Double intTest = (Double)calculateNumberStat(intTestStart, "median");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Double longResult = (Double)getStatResult(response, "medr", "double", "long_ld");
|
Double longResult = (Double)getStatResult("medr", "long_ld", VAL_TYPE.DOUBLE);
|
||||||
Double longTest = (Double)calculateNumberStat(longTestStart, "median");
|
Double longTest = (Double)calculateNumberStat(longTestStart, "median");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Double floatResult = (Double)getStatResult(response, "medr", "double", "float_fd");
|
Double floatResult = (Double)getStatResult("medr", "float_fd", VAL_TYPE.DOUBLE);
|
||||||
Double floatTest = (Double)calculateNumberStat(floatTestStart, "median");
|
Double floatTest = (Double)calculateNumberStat(floatTestStart, "median");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Double doubleResult = (Double)getStatResult(response, "medr", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("medr", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "median");
|
Double doubleTest = (Double)calculateNumberStat(doubleTestStart, "median");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
}
|
}
|
||||||
|
@ -265,32 +263,32 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void perc20Test() throws Exception {
|
public void perc20Test() throws Exception {
|
||||||
//Int 20
|
//Int 20
|
||||||
Integer intResult = (Integer)getStatResult(response, "p2r", "int", "int_id");
|
Integer intResult = (Integer)getStatResult("p2r", "int_id", VAL_TYPE.INTEGER);
|
||||||
Integer intTest = (Integer)calculateStat(intTestStart, "perc_20");
|
Integer intTest = (Integer)calculateStat(intTestStart, "perc_20");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long 20
|
//Long 20
|
||||||
Long longResult = (Long)getStatResult(response, "p2r", "long", "long_ld");
|
Long longResult = (Long)getStatResult("p2r", "long_ld", VAL_TYPE.LONG);
|
||||||
Long longTest = (Long)calculateStat(longTestStart, "perc_20");
|
Long longTest = (Long)calculateStat(longTestStart, "perc_20");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float 20
|
//Float 20
|
||||||
Float floatResult = (Float)getStatResult(response, "p2r", "float", "float_fd");
|
Float floatResult = (Float)getStatResult("p2r", "float_fd", VAL_TYPE.FLOAT);
|
||||||
Float floatTest = (Float)calculateStat(floatTestStart, "perc_20");
|
Float floatTest = (Float)calculateStat(floatTestStart, "perc_20");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double 20
|
//Double 20
|
||||||
Double doubleResult = (Double)getStatResult(response, "p2r", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("p2r", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateStat(doubleTestStart, "perc_20");
|
Double doubleTest = (Double)calculateStat(doubleTestStart, "perc_20");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
|
|
||||||
//Date 20
|
//Date 20
|
||||||
String dateResult = (String)getStatResult(response, "p2r", "date", "date_dtd");
|
String dateResult = (String)getStatResult("p2r", "date_dtd", VAL_TYPE.DATE);
|
||||||
String dateTest = (String)calculateStat(dateTestStart, "perc_20");
|
String dateTest = (String)calculateStat(dateTestStart, "perc_20");
|
||||||
assertEquals(dateResult,dateTest);
|
assertEquals(dateResult,dateTest);
|
||||||
|
|
||||||
//String 20
|
//String 20
|
||||||
String stringResult = (String)getStatResult(response, "p2r", "str", "string_sd");
|
String stringResult = (String)getStatResult("p2r", "string_sd", VAL_TYPE.STRING);
|
||||||
String stringTest = (String)calculateStat(stringTestStart, "perc_20");
|
String stringTest = (String)calculateStat(stringTestStart, "perc_20");
|
||||||
assertEquals(stringResult,stringTest);
|
assertEquals(stringResult,stringTest);
|
||||||
}
|
}
|
||||||
|
@ -298,32 +296,32 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void perc60Test() throws Exception {
|
public void perc60Test() throws Exception {
|
||||||
//Int 60
|
//Int 60
|
||||||
Integer intResult = (Integer)getStatResult(response, "p6r", "int", "int_id");
|
Integer intResult = (Integer)getStatResult("p6r", "int_id", VAL_TYPE.INTEGER);
|
||||||
Integer intTest = (Integer)calculateStat(intTestStart, "perc_60");
|
Integer intTest = (Integer)calculateStat(intTestStart, "perc_60");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long 60
|
//Long 60
|
||||||
Long longResult = (Long)getStatResult(response, "p6r", "long", "long_ld");
|
Long longResult = (Long)getStatResult("p6r", "long_ld", VAL_TYPE.LONG);
|
||||||
Long longTest = (Long)calculateStat(longTestStart, "perc_60");
|
Long longTest = (Long)calculateStat(longTestStart, "perc_60");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float 60
|
//Float 60
|
||||||
Float floatResult = (Float)getStatResult(response, "p6r", "float", "float_fd");
|
Float floatResult = (Float)getStatResult("p6r", "float_fd", VAL_TYPE.FLOAT);
|
||||||
Float floatTest = (Float)calculateStat(floatTestStart, "perc_60");
|
Float floatTest = (Float)calculateStat(floatTestStart, "perc_60");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double 60
|
//Double 60
|
||||||
Double doubleResult = (Double)getStatResult(response, "p6r", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("p6r", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateStat(doubleTestStart, "perc_60");
|
Double doubleTest = (Double)calculateStat(doubleTestStart, "perc_60");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
|
|
||||||
//Date 60
|
//Date 60
|
||||||
String dateResult = (String)getStatResult(response, "p6r", "date", "date_dtd");
|
String dateResult = (String)getStatResult("p6r", "date_dtd", VAL_TYPE.DATE);
|
||||||
String dateTest = (String)calculateStat(dateTestStart, "perc_60");
|
String dateTest = (String)calculateStat(dateTestStart, "perc_60");
|
||||||
assertEquals(dateResult,dateTest);
|
assertEquals(dateResult,dateTest);
|
||||||
|
|
||||||
//String 60
|
//String 60
|
||||||
String stringResult = (String)getStatResult(response, "p6r", "str", "string_sd");
|
String stringResult = (String)getStatResult("p6r", "string_sd", VAL_TYPE.STRING);
|
||||||
String stringTest = (String)calculateStat(stringTestStart, "perc_60");
|
String stringTest = (String)calculateStat(stringTestStart, "perc_60");
|
||||||
assertEquals(stringResult,stringTest);
|
assertEquals(stringResult,stringTest);
|
||||||
}
|
}
|
||||||
|
@ -331,32 +329,32 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void minTest() throws Exception {
|
public void minTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Integer intResult = (Integer)getStatResult(response, "mir", "int", "int_id");
|
Integer intResult = (Integer)getStatResult("mir", "int_id", VAL_TYPE.INTEGER);
|
||||||
Integer intTest = (Integer)calculateStat(intTestStart, "min");
|
Integer intTest = (Integer)calculateStat(intTestStart, "min");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Long longResult = (Long)getStatResult(response, "mir", "long", "long_ld");
|
Long longResult = (Long)getStatResult("mir", "long_ld", VAL_TYPE.LONG);
|
||||||
Long longTest = (Long)calculateStat(longTestStart, "min");
|
Long longTest = (Long)calculateStat(longTestStart, "min");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Float floatResult = (Float)getStatResult(response, "mir", "float", "float_fd");
|
Float floatResult = (Float)getStatResult("mir", "float_fd", VAL_TYPE.FLOAT);
|
||||||
Float floatTest = (Float)calculateStat(floatTestStart, "min");
|
Float floatTest = (Float)calculateStat(floatTestStart, "min");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Double doubleResult = (Double)getStatResult(response, "mir", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("mir", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateStat(doubleTestStart, "min");
|
Double doubleTest = (Double)calculateStat(doubleTestStart, "min");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
|
|
||||||
//Date
|
//Date
|
||||||
String dateResult = (String)getStatResult(response, "mir", "date", "date_dtd");
|
String dateResult = (String)getStatResult("mir", "date_dtd", VAL_TYPE.DATE);
|
||||||
String dateTest = (String)calculateStat(dateTestStart, "min");
|
String dateTest = (String)calculateStat(dateTestStart, "min");
|
||||||
assertEquals(dateResult,dateTest);
|
assertEquals(dateResult,dateTest);
|
||||||
|
|
||||||
//String
|
//String
|
||||||
String stringResult = (String)getStatResult(response, "mir", "str", "string_sd");
|
String stringResult = (String)getStatResult("mir", "string_sd", VAL_TYPE.STRING);
|
||||||
String stringTest = (String)calculateStat(stringTestStart, "min");
|
String stringTest = (String)calculateStat(stringTestStart, "min");
|
||||||
assertEquals(stringResult,stringTest);
|
assertEquals(stringResult,stringTest);
|
||||||
}
|
}
|
||||||
|
@ -364,32 +362,32 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void maxTest() throws Exception {
|
public void maxTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Integer intResult = (Integer)getStatResult(response, "mar", "int", "int_id");
|
Integer intResult = (Integer)getStatResult("mar", "int_id", VAL_TYPE.INTEGER);
|
||||||
Integer intTest = (Integer)calculateStat(intTestStart, "max");
|
Integer intTest = (Integer)calculateStat(intTestStart, "max");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Long longResult = (Long)getStatResult(response, "mar", "long", "long_ld");
|
Long longResult = (Long)getStatResult("mar", "long_ld", VAL_TYPE.LONG);
|
||||||
Long longTest = (Long)calculateStat(longTestStart, "max");
|
Long longTest = (Long)calculateStat(longTestStart, "max");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Float floatResult = (Float)getStatResult(response, "mar", "float", "float_fd");
|
Float floatResult = (Float)getStatResult("mar", "float_fd", VAL_TYPE.FLOAT);
|
||||||
Float floatTest = (Float)calculateStat(floatTestStart, "max");
|
Float floatTest = (Float)calculateStat(floatTestStart, "max");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Double doubleResult = (Double)getStatResult(response, "mar", "double", "double_dd");
|
Double doubleResult = (Double)getStatResult("mar", "double_dd", VAL_TYPE.DOUBLE);
|
||||||
Double doubleTest = (Double)calculateStat(doubleTestStart, "max");
|
Double doubleTest = (Double)calculateStat(doubleTestStart, "max");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
|
|
||||||
//Date
|
//Date
|
||||||
String dateResult = (String)getStatResult(response, "mar", "date", "date_dtd");
|
String dateResult = (String)getStatResult("mar", "date_dtd", VAL_TYPE.DATE);
|
||||||
String dateTest = (String)calculateStat(dateTestStart, "max");
|
String dateTest = (String)calculateStat(dateTestStart, "max");
|
||||||
assertEquals(dateResult,dateTest);
|
assertEquals(dateResult,dateTest);
|
||||||
|
|
||||||
//String
|
//String
|
||||||
String stringResult = (String)getStatResult(response, "mar", "str", "string_sd");
|
String stringResult = (String)getStatResult("mar", "string_sd", VAL_TYPE.STRING);
|
||||||
String stringTest = (String)calculateStat(stringTestStart, "max");
|
String stringTest = (String)calculateStat(stringTestStart, "max");
|
||||||
assertEquals(stringResult,stringTest);
|
assertEquals(stringResult,stringTest);
|
||||||
}
|
}
|
||||||
|
@ -397,32 +395,32 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void uniqueTest() throws Exception {
|
public void uniqueTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Long intResult = (Long)getStatResult(response, "ur", "long", "int_id");
|
Long intResult = (Long)getStatResult("ur", "int_id", VAL_TYPE.LONG);
|
||||||
Long intTest = (Long)calculateStat(intTestStart, "unique");
|
Long intTest = (Long)calculateStat(intTestStart, "unique");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Long longResult = (Long)getStatResult(response, "ur", "long", "long_ld");
|
Long longResult = (Long)getStatResult("ur", "long_ld", VAL_TYPE.LONG);
|
||||||
Long longTest = (Long)calculateStat(longTestStart, "unique");
|
Long longTest = (Long)calculateStat(longTestStart, "unique");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Long floatResult = (Long)getStatResult(response, "ur", "long", "float_fd");
|
Long floatResult = (Long)getStatResult("ur", "float_fd", VAL_TYPE.LONG);
|
||||||
Long floatTest = (Long)calculateStat(floatTestStart, "unique");
|
Long floatTest = (Long)calculateStat(floatTestStart, "unique");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Long doubleResult = (Long)getStatResult(response, "ur", "long", "double_dd");
|
Long doubleResult = (Long)getStatResult("ur", "double_dd", VAL_TYPE.LONG);
|
||||||
Long doubleTest = (Long)calculateStat(doubleTestStart, "unique");
|
Long doubleTest = (Long)calculateStat(doubleTestStart, "unique");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
|
|
||||||
//Date
|
//Date
|
||||||
Long dateResult = (Long)getStatResult(response, "ur", "long", "date_dtd");
|
Long dateResult = (Long)getStatResult("ur", "date_dtd", VAL_TYPE.LONG);
|
||||||
Long dateTest = (Long)calculateStat(dateTestStart, "unique");
|
Long dateTest = (Long)calculateStat(dateTestStart, "unique");
|
||||||
assertEquals(dateResult,dateTest);
|
assertEquals(dateResult,dateTest);
|
||||||
|
|
||||||
//String
|
//String
|
||||||
Long stringResult = (Long)getStatResult(response, "ur", "long", "string_sd");
|
Long stringResult = (Long)getStatResult("ur", "string_sd", VAL_TYPE.LONG);
|
||||||
Long stringTest = (Long)calculateStat(stringTestStart, "unique");
|
Long stringTest = (Long)calculateStat(stringTestStart, "unique");
|
||||||
assertEquals(stringResult,stringTest);
|
assertEquals(stringResult,stringTest);
|
||||||
}
|
}
|
||||||
|
@ -430,32 +428,32 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void countTest() throws Exception {
|
public void countTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
Long intResult = (Long)getStatResult(response, "cr", "long", "int_id");
|
Long intResult = (Long)getStatResult("cr", "int_id", VAL_TYPE.LONG);
|
||||||
Long intTest = (Long)calculateStat(intTestStart, "count");
|
Long intTest = (Long)calculateStat(intTestStart, "count");
|
||||||
assertEquals(intResult,intTest);
|
assertEquals(intResult,intTest);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
Long longResult = (Long)getStatResult(response, "cr", "long", "long_ld");
|
Long longResult = (Long)getStatResult("cr", "long_ld", VAL_TYPE.LONG);
|
||||||
Long longTest = (Long)calculateStat(longTestStart, "count");
|
Long longTest = (Long)calculateStat(longTestStart, "count");
|
||||||
assertEquals(longResult,longTest);
|
assertEquals(longResult,longTest);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
Long floatResult = (Long)getStatResult(response, "cr", "long", "float_fd");
|
Long floatResult = (Long)getStatResult("cr", "float_fd", VAL_TYPE.LONG);
|
||||||
Long floatTest = (Long)calculateStat(floatTestStart, "count");
|
Long floatTest = (Long)calculateStat(floatTestStart, "count");
|
||||||
assertEquals(floatResult,floatTest);
|
assertEquals(floatResult,floatTest);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
Long doubleResult = (Long)getStatResult(response, "cr", "long", "double_dd");
|
Long doubleResult = (Long)getStatResult("cr", "double_dd", VAL_TYPE.LONG);
|
||||||
Long doubleTest = (Long)calculateStat(doubleTestStart, "count");
|
Long doubleTest = (Long)calculateStat(doubleTestStart, "count");
|
||||||
assertEquals(doubleResult,doubleTest);
|
assertEquals(doubleResult,doubleTest);
|
||||||
|
|
||||||
//Date
|
//Date
|
||||||
Long dateResult = (Long)getStatResult(response, "cr", "long", "date_dtd");
|
Long dateResult = (Long)getStatResult("cr", "date_dtd", VAL_TYPE.LONG);
|
||||||
Long dateTest = (Long)calculateStat(dateTestStart, "count");
|
Long dateTest = (Long)calculateStat(dateTestStart, "count");
|
||||||
assertEquals(dateResult,dateTest);
|
assertEquals(dateResult,dateTest);
|
||||||
|
|
||||||
//String
|
//String
|
||||||
Long stringResult = (Long)getStatResult(response, "cr", "long", "string_sd");
|
Long stringResult = (Long)getStatResult("cr", "string_sd", VAL_TYPE.LONG);
|
||||||
Long stringTest = (Long)calculateStat(stringTestStart, "count");
|
Long stringTest = (Long)calculateStat(stringTestStart, "count");
|
||||||
assertEquals(stringResult,stringTest);
|
assertEquals(stringResult,stringTest);
|
||||||
}
|
}
|
||||||
|
@ -463,27 +461,27 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
|
||||||
@Test
|
@Test
|
||||||
public void missingDefaultTest() throws Exception {
|
public void missingDefaultTest() throws Exception {
|
||||||
//Int
|
//Int
|
||||||
long intResult = (Long)getStatResult(response, "misr", "long", "int_id");
|
long intResult = (Long)getStatResult("misr", "int_id", VAL_TYPE.LONG);
|
||||||
assertEquals(intMissing,intResult);
|
assertEquals(intMissing,intResult);
|
||||||
|
|
||||||
//Long
|
//Long
|
||||||
long longResult = (Long)getStatResult(response, "misr", "long", "long_ld");
|
long longResult = (Long)getStatResult("misr", "long_ld", VAL_TYPE.LONG);
|
||||||
assertEquals(longMissing,longResult);
|
assertEquals(longMissing,longResult);
|
||||||
|
|
||||||
//Float
|
//Float
|
||||||
long floatResult = (Long)getStatResult(response, "misr", "long", "float_fd");
|
long floatResult = (Long)getStatResult("misr", "float_fd", VAL_TYPE.LONG);
|
||||||
assertEquals(floatMissing,floatResult);
|
assertEquals(floatMissing,floatResult);
|
||||||
|
|
||||||
//Double
|
//Double
|
||||||
long doubleResult = (Long)getStatResult(response, "misr", "long", "double_dd");
|
long doubleResult = (Long)getStatResult("misr", "double_dd", VAL_TYPE.LONG);
|
||||||
assertEquals(doubleMissing,doubleResult);
|
assertEquals(doubleMissing,doubleResult);
|
||||||
|
|
||||||
//Date
|
//Date
|
||||||
long dateResult = (Long)getStatResult(response, "misr", "long", "date_dtd");
|
long dateResult = (Long)getStatResult("misr", "date_dtd", VAL_TYPE.LONG);
|
||||||
assertEquals(dateMissing,dateResult);
|
assertEquals(dateMissing,dateResult);
|
||||||
|
|
||||||
//String
|
//String
|
||||||
long stringResult = (Long)getStatResult(response, "misr", "long", "string_sd");
|
long stringResult = (Long)getStatResult("misr", "string_sd", VAL_TYPE.LONG);
|
||||||
assertEquals(stringMissing, stringResult);
|
assertEquals(stringMissing, stringResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.solr.analytics.AbstractAnalyticsStatsTest;
|
||||||
import org.apache.solr.analytics.facet.AbstractAnalyticsFacetTest;
|
import org.apache.solr.analytics.facet.AbstractAnalyticsFacetTest;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@SuppressCodecs({"Lucene3x","Lucene40","Lucene41","Lucene42","Appending","Asserting"})
|
@SuppressCodecs({"Lucene3x","Lucene40","Lucene41","Lucene42","Appending","Asserting"})
|
||||||
|
@ -36,8 +37,6 @@ public class FunctionTest extends AbstractAnalyticsStatsTest {
|
||||||
static public final int DATE = 12;
|
static public final int DATE = 12;
|
||||||
static public final int STRING = 28;
|
static public final int STRING = 28;
|
||||||
static public final int NUM_LOOPS = 100;
|
static public final int NUM_LOOPS = 100;
|
||||||
|
|
||||||
static String response;
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
|
@ -85,145 +84,145 @@ public class FunctionTest extends AbstractAnalyticsStatsTest {
|
||||||
|
|
||||||
assertU(commit());
|
assertU(commit());
|
||||||
|
|
||||||
response = h.query(request(fileToStringArr(fileName)));
|
setResponse(h.query(request(fileToStringArr(fileName))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addTest() throws Exception {
|
public void addTest() throws Exception {
|
||||||
double result = (Double)getStatResult(response, "ar", "double", "sum");
|
double result = (Double)getStatResult("ar", "sum", VAL_TYPE.DOUBLE);
|
||||||
double calculated = (Double)getStatResult(response, "ar", "double", "sumc");
|
double calculated = (Double)getStatResult("ar", "sumc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
|
|
||||||
result = (Double)getStatResult(response, "ar", "double", "mean");
|
result = (Double)getStatResult("ar", "mean", VAL_TYPE.DOUBLE);
|
||||||
calculated = (Double)getStatResult(response, "ar", "double", "meanc");
|
calculated = (Double)getStatResult("ar", "meanc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void multiplyTest() throws Exception {
|
public void multiplyTest() throws Exception {
|
||||||
double result = (Double)getStatResult(response, "mr", "double", "sum");
|
double result = (Double)getStatResult("mr", "sum", VAL_TYPE.DOUBLE);
|
||||||
double calculated = (Double)getStatResult(response, "mr", "double", "sumc");
|
double calculated = (Double)getStatResult("mr", "sumc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
|
|
||||||
result = (Double)getStatResult(response, "mr", "double", "mean");
|
result = (Double)getStatResult("mr", "mean", VAL_TYPE.DOUBLE);
|
||||||
calculated = (Double)getStatResult(response, "mr", "double", "meanc");
|
calculated = (Double)getStatResult("mr", "meanc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void divideTest() throws Exception {
|
public void divideTest() throws Exception {
|
||||||
Double result = (Double)getStatResult(response, "dr", "double", "sum");
|
Double result = (Double)getStatResult("dr", "sum", VAL_TYPE.DOUBLE);
|
||||||
Double calculated = (Double)getStatResult(response, "dr", "double", "sumc");
|
Double calculated = (Double)getStatResult("dr", "sumc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
|
|
||||||
result = (Double)getStatResult(response, "dr", "double", "mean");
|
result = (Double)getStatResult("dr", "mean", VAL_TYPE.DOUBLE);
|
||||||
calculated = (Double)getStatResult(response, "dr", "double", "meanc");
|
calculated = (Double)getStatResult("dr", "meanc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void powerTest() throws Exception {
|
public void powerTest() throws Exception {
|
||||||
double result = (Double)getStatResult(response, "pr", "double", "sum");
|
double result = (Double)getStatResult("pr", "sum", VAL_TYPE.DOUBLE);
|
||||||
double calculated = (Double)getStatResult(response, "pr", "double", "sumc");
|
double calculated = (Double)getStatResult("pr", "sumc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
|
|
||||||
result = (Double)getStatResult(response, "pr", "double", "mean");
|
result = (Double)getStatResult("pr", "mean", VAL_TYPE.DOUBLE);
|
||||||
calculated = (Double)getStatResult(response, "pr", "double", "meanc");
|
calculated = (Double)getStatResult("pr", "meanc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void negateTest() throws Exception {
|
public void negateTest() throws Exception {
|
||||||
double result = (Double)getStatResult(response, "nr", "double", "sum");
|
double result = (Double)getStatResult("nr", "sum", VAL_TYPE.DOUBLE);
|
||||||
double calculated = (Double)getStatResult(response, "nr", "double", "sumc");
|
double calculated = (Double)getStatResult("nr", "sumc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
|
|
||||||
result = (Double)getStatResult(response, "nr", "double", "mean");
|
result = (Double)getStatResult("nr", "mean", VAL_TYPE.DOUBLE);
|
||||||
calculated = (Double)getStatResult(response, "nr", "double", "meanc");
|
calculated = (Double)getStatResult("nr", "meanc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test @Ignore("SOLR-5488")
|
||||||
public void absoluteValueTest() throws Exception {
|
public void absoluteValueTest() throws Exception {
|
||||||
double result = (Double)getStatResult(response, "avr", "double", "sum");
|
double result = (Double)getStatResult("avr", "sum", VAL_TYPE.DOUBLE);
|
||||||
double calculated = (Double)getStatResult(response, "avr", "double", "sumc");
|
double calculated = (Double)getStatResult("avr", "sumc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
|
|
||||||
result = (Double)getStatResult(response, "avr", "double", "mean");
|
result = (Double)getStatResult("avr", "mean", VAL_TYPE.DOUBLE);
|
||||||
calculated = (Double)getStatResult(response, "avr", "double", "meanc");
|
calculated = (Double)getStatResult("avr", "meanc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constantNumberTest() throws Exception {
|
public void constantNumberTest() throws Exception {
|
||||||
double result = (Double)getStatResult(response, "cnr", "double", "sum");
|
double result = (Double)getStatResult("cnr", "sum", VAL_TYPE.DOUBLE);
|
||||||
double calculated = (Double)getStatResult(response, "cnr", "double", "sumc");
|
double calculated = (Double)getStatResult("cnr", "sumc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
|
|
||||||
result = (Double)getStatResult(response, "cnr", "double", "mean");
|
result = (Double)getStatResult("cnr", "mean", VAL_TYPE.DOUBLE);
|
||||||
calculated = (Double)getStatResult(response, "cnr", "double", "meanc");
|
calculated = (Double)getStatResult("cnr", "meanc", VAL_TYPE.DOUBLE);
|
||||||
assertTrue(result==calculated);
|
assertTrue(result==calculated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dateMathTest() throws Exception {
|
public void dateMathTest() throws Exception {
|
||||||
String result = (String)getStatResult(response, "dmr", "date", "median");
|
String result = (String)getStatResult("dmr", "median", VAL_TYPE.STRING);
|
||||||
String calculated = (String)getStatResult(response, "dmr", "date", "medianc");
|
String calculated = (String)getStatResult("dmr", "medianc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
|
|
||||||
result = (String)getStatResult(response, "dmr", "date", "max");
|
result = (String)getStatResult("dmr", "max", VAL_TYPE.STRING);
|
||||||
calculated = (String)getStatResult(response, "dmr", "date", "maxc");
|
calculated = (String)getStatResult("dmr", "maxc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constantDateTest() throws Exception {
|
public void constantDateTest() throws Exception {
|
||||||
String result = (String)getStatResult(response, "cdr", "date", "median");
|
String result = (String)getStatResult("cdr", "median", VAL_TYPE.STRING);
|
||||||
String calculated = (String)getStatResult(response, "cdr", "date", "medianc");
|
String calculated = (String)getStatResult("cdr", "medianc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
|
|
||||||
result = (String)getStatResult(response, "cdr", "date", "max");
|
result = (String)getStatResult("cdr", "max", VAL_TYPE.STRING);
|
||||||
calculated = (String)getStatResult(response, "cdr", "date", "maxc");
|
calculated = (String)getStatResult("cdr", "maxc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constantStringTest() throws Exception {
|
public void constantStringTest() throws Exception {
|
||||||
String result = (String)getStatResult(response, "csr", "str", "min");
|
String result = (String)getStatResult("csr", "min", VAL_TYPE.STRING);
|
||||||
String calculated = (String)getStatResult(response, "csr", "str", "minc");
|
String calculated = (String)getStatResult("csr", "minc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
|
|
||||||
result = (String)getStatResult(response, "csr", "str", "max");
|
result = (String)getStatResult("csr", "max", VAL_TYPE.STRING);
|
||||||
calculated = (String)getStatResult(response, "csr", "str", "maxc");
|
calculated = (String)getStatResult("csr", "maxc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void concatenateTest() throws Exception {
|
public void concatenateTest() throws Exception {
|
||||||
String result = (String)getStatResult(response, "cr", "str", "min");
|
String result = (String)getStatResult("cr", "min", VAL_TYPE.STRING);
|
||||||
String calculated = (String)getStatResult(response, "cr", "str", "minc");
|
String calculated = (String)getStatResult("cr", "minc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
|
|
||||||
result = (String)getStatResult(response, "cr", "str", "max");
|
result = (String)getStatResult("cr", "max", VAL_TYPE.STRING);
|
||||||
calculated = (String)getStatResult(response, "cr", "str", "maxc");
|
calculated = (String)getStatResult("cr", "maxc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reverseTest() throws Exception {
|
public void reverseTest() throws Exception {
|
||||||
String result = (String)getStatResult(response, "rr", "str", "min");
|
String result = (String)getStatResult("rr", "min", VAL_TYPE.STRING);
|
||||||
String calculated = (String)getStatResult(response, "rr", "str", "minc");
|
String calculated = (String)getStatResult("rr", "minc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
|
|
||||||
result = (String)getStatResult(response, "rr", "str", "max");
|
result = (String)getStatResult("rr", "max", VAL_TYPE.STRING);
|
||||||
calculated = (String)getStatResult(response, "rr", "str", "maxc");
|
calculated = (String)getStatResult("rr", "maxc", VAL_TYPE.STRING);
|
||||||
assertTrue(result.equals(calculated));
|
assertTrue(result.equals(calculated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void missingTest() throws Exception {
|
public void missingTest() throws Exception {
|
||||||
double min = (Double)getStatResult(response, "ms", "double", "min");
|
double min = (Double)getStatResult("ms", "min", VAL_TYPE.DOUBLE);
|
||||||
double max = (Double)getStatResult(response, "ms", "double", "max");
|
double max = (Double)getStatResult("ms", "max", VAL_TYPE.DOUBLE);
|
||||||
Assert.assertEquals((Double)48.0,(Double)max);
|
Assert.assertEquals((Double)48.0,(Double)max);
|
||||||
Assert.assertEquals((Double)1.0,(Double)min);
|
Assert.assertEquals((Double)1.0,(Double)min);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue