Search in sources :

Example 46 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class GreaterThanEqualToEvaluatorTest method gteDifferentTypes4.

@Test(expected = IOException.class)
public void gteDifferentTypes4() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
    values.clear();
    values.put("a", "true");
    values.put("b", true);
    evaluator.evaluate(new Tuple(values));
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 47 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class GreaterThanEqualToEvaluatorTest method gteTwoStrings.

@Test
public void gteTwoStrings() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
    Object result;
    String foo = "foo";
    String bar = "bar";
    values.clear();
    values.put("a", "foo");
    values.put("b", "foo");
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Boolean);
    Assert.assertEquals(true, result);
    values.clear();
    values.put("a", "foo");
    values.put("b", "bar");
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Boolean);
    Assert.assertEquals(true, result);
    values.clear();
    values.put("a", "foo bar baz");
    values.put("b", "foo bar baz");
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Boolean);
    Assert.assertEquals(true, result);
    values.clear();
    values.put("a", "foo bar baz");
    values.put("b", "foo bar jaz");
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Boolean);
    Assert.assertEquals(false, result);
    values.clear();
    values.put("a", foo);
    values.put("b", foo);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Boolean);
    Assert.assertEquals(true, result);
    values.clear();
    values.put("a", foo);
    values.put("b", bar);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Boolean);
    Assert.assertEquals(true, result);
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 48 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class ModuloEvaluatorTest method modTwoFieldsWithMissingNumerator.

@Test(expected = IOException.class)
public void modTwoFieldsWithMissingNumerator() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
    values.clear();
    values.put("b", 1);
    evaluator.evaluate(new Tuple(values));
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 49 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class ModuloEvaluatorTest method modTwoFieldsWithMissingDenominator.

@Test(expected = IOException.class)
public void modTwoFieldsWithMissingDenominator() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)");
    values.clear();
    values.put("a", 1);
    evaluator.evaluate(new Tuple(values));
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 50 with StreamEvaluator

use of org.apache.solr.client.solrj.io.eval.StreamEvaluator in project lucene-solr by apache.

the class ModuloEvaluatorTest method modManyFieldsWithSubmods.

@Test
public void modManyFieldsWithSubmods() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("mod(a,mod(b,c))");
    Object result;
    values.clear();
    values.put("a", 1);
    values.put("b", 2);
    values.put("c", 9);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertTrue(result instanceof Long);
    Assert.assertEquals(Long.valueOf(1 % (2 % 9)), result);
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Aggregations

StreamEvaluator (org.apache.solr.client.solrj.io.eval.StreamEvaluator)137 Tuple (org.apache.solr.client.solrj.io.Tuple)135 Test (org.junit.Test)119 StreamContext (org.apache.solr.client.solrj.io.stream.StreamContext)6 HashMap (java.util.HashMap)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 UUID (java.util.UUID)1 StreamOperation (org.apache.solr.client.solrj.io.ops.StreamOperation)1