use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class ArcSineEvaluatorTest method test.
private void test(Double value) throws IOException {
StreamEvaluator evaluator = factory.constructEvaluator("asin(a)");
values.clear();
values.put("a", value);
Object result = evaluator.evaluate(new Tuple(values));
if (null == value) {
Assert.assertNull(result);
} else {
Assert.assertTrue(result instanceof Double);
Assert.assertEquals(Math.asin(value), result);
}
}
use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class AddEvaluatorTest method addTwoFieldsWithValues.
@Test
public void addTwoFieldsWithValues() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
Object result;
values.clear();
values.put("a", 1);
values.put("b", 2);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Long);
Assert.assertEquals(3L, result);
values.clear();
values.put("a", 1.1);
values.put("b", 2);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Double);
Assert.assertEquals(3.1D, result);
values.clear();
values.put("a", 1.1);
values.put("b", 2.1);
result = evaluator.evaluate(new Tuple(values));
Assert.assertTrue(result instanceof Double);
Assert.assertEquals(3.2D, result);
}
use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class ArcSineEvaluatorTest method noValue.
@Test
public void noValue() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("asin(a)");
values.clear();
Object result = evaluator.evaluate(new Tuple(values));
assertNull(result);
}
use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class AddEvaluatorTest method addTwoFieldWithNulls.
@Test
public void addTwoFieldWithNulls() throws Exception {
StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
Object result;
values.clear();
result = evaluator.evaluate(new Tuple(values));
Assert.assertNull(result);
}
use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.
the class ArcTangentEvaluatorTest method test.
private void test(Double value) throws IOException {
StreamEvaluator evaluator = factory.constructEvaluator("atan(a)");
values.clear();
values.put("a", value);
Object result = evaluator.evaluate(new Tuple(values));
if (null == value) {
Assert.assertNull(result);
} else {
Assert.assertTrue(result instanceof Double);
Assert.assertEquals(Math.atan(value), result);
}
}
Aggregations