You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/11/02 11:16:19 UTC
[10/56] lucene-solr:jira/gradle: Add :solr:contrib:analytics module
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java
deleted file mode 100644
index 9996c28..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.DoubleValue;
-import org.apache.solr.analytics.value.DoubleValueStream;
-import org.apache.solr.analytics.value.FloatValue;
-import org.apache.solr.analytics.value.FloatValueStream;
-import org.apache.solr.analytics.value.IntValue;
-import org.apache.solr.analytics.value.IntValueStream;
-import org.apache.solr.analytics.value.LongValue;
-import org.apache.solr.analytics.value.LongValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;
-import org.junit.Test;
-
-public class AbsoluteValueFunctionTest extends SolrTestCaseJ4 {
-
- @Test
- public void singleValueIntTest() {
- TestIntValue val = new TestIntValue();
-
- AnalyticsValueStream uncasted = AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof IntValue);
- IntValue func = (IntValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getInt();
- assertFalse(func.exists());
-
- // Value exists
- val.setValue(21).setExists(true);
- assertEquals(21, func.getInt());
- assertTrue(func.exists());
-
- val.setValue(-100).setExists(true);
- assertEquals(100, func.getInt());
- assertTrue(func.exists());
- }
-
- @Test
- public void singleValueLongTest() {
- TestLongValue val = new TestLongValue();
-
- AnalyticsValueStream uncasted = AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof LongValue);
- LongValue func = (LongValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getLong();
- assertFalse(func.exists());
-
- // Value exists
- val.setValue(21L).setExists(true);
- assertEquals(21L, func.getLong());
- assertTrue(func.exists());
-
- val.setValue(-100L).setExists(true);
- assertEquals(100L, func.getLong());
- assertTrue(func.exists());
- }
-
- @Test
- public void singleValueFloatTest() {
- TestFloatValue val = new TestFloatValue();
-
- AnalyticsValueStream uncasted = AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof FloatValue);
- FloatValue func = (FloatValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getFloat();
- assertFalse(func.exists());
-
- // Value exists
- val.setValue(21.56F).setExists(true);
- assertEquals(21.56F, func.getFloat(), 0.00001);
- assertTrue(func.exists());
-
- val.setValue(-100F).setExists(true);
- assertEquals(100F, func.getFloat(), 0.00001);
- assertTrue(func.exists());
- }
-
- @Test
- public void singleValueDoubleTest() {
- TestDoubleValue val = new TestDoubleValue();
-
- AnalyticsValueStream uncasted = AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DoubleValue);
- DoubleValue func = (DoubleValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getDouble();
- assertFalse(func.exists());
-
- // Value exists
- val.setValue(21.56).setExists(true);
- assertEquals(21.56, func.getDouble(), 0.00001);
- assertTrue(func.exists());
-
- val.setValue(-100.1).setExists(true);
- assertEquals(100.1, func.getDouble(), 0.00001);
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueIntTest() {
- TestIntValueStream val = new TestIntValueStream();
-
- AnalyticsValueStream uncasted = AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof IntValueStream);
- IntValueStream func = (IntValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamInts( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues(-4);
- Iterator<Integer> values1 = Arrays.asList(4).iterator();
- func.streamInts( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next().intValue(), value);
- });
- assertFalse(values1.hasNext());
-
- // Multiple values
- val.setValues(4, -10, 50, -74);
- Iterator<Integer> values2 = Arrays.asList(4, 10, 50, 74).iterator();
- func.streamInts( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next().intValue(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void multiValueLongTest() {
- TestLongValueStream val = new TestLongValueStream();
-
- AnalyticsValueStream uncasted = AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof LongValueStream);
- LongValueStream func = (LongValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamLongs( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues(-4L);
- Iterator<Long> values1 = Arrays.asList(4L).iterator();
- func.streamLongs( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next().longValue(), value);
- });
- assertFalse(values1.hasNext());
-
- // Multiple values
- val.setValues(4L, -10L, 50L, -74L);
- Iterator<Long> values2 = Arrays.asList(4L, 10L, 50L, 74L).iterator();
- func.streamLongs( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next().longValue(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void multiValueFloatTest() {
- TestFloatValueStream val = new TestFloatValueStream();
-
- AnalyticsValueStream uncasted = AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof FloatValueStream);
- FloatValueStream func = (FloatValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamFloats( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues(-4.3F);
- Iterator<Float> values1 = Arrays.asList(4.3F).iterator();
- func.streamFloats( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next(), value, .000001);
- });
- assertFalse(values1.hasNext());
-
- // Multiple values
- val.setValues(4.3F, -10F, 50.75F, -74.4446F);
- Iterator<Float> values2 = Arrays.asList(4.3F, 10F, 50.75F, 74.4446F).iterator();
- func.streamFloats( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value, .000001);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void multiValueDoubleTest() {
- TestDoubleValueStream val = new TestDoubleValueStream();
-
- AnalyticsValueStream uncasted = AbsoluteValueFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DoubleValueStream);
- DoubleValueStream func = (DoubleValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamDoubles( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues(-4.3);
- Iterator<Double> values1 = Arrays.asList(4.3).iterator();
- func.streamDoubles( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next(), value, .000001);
- });
- assertFalse(values1.hasNext());
-
- // Multiple values
- val.setValues(4.3, -10, 50.75, -74.4446);
- Iterator<Double> values2 = Arrays.asList(4.3, 10.0, 50.75, 74.4446).iterator();
- func.streamDoubles( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value, .000001);
- });
- assertFalse(values2.hasNext());
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java
deleted file mode 100644
index 87b80cb..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.DoubleValue;
-import org.apache.solr.analytics.value.DoubleValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;
-import org.junit.Test;
-
-public class AddFunctionTest extends SolrTestCaseJ4 {
-
- @Test
- public void twoSingleValueParametersTest() {
- TestIntValue val1 = new TestIntValue();
- TestFloatValue val2 = new TestFloatValue();
-
- AnalyticsValueStream uncasted = AddFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});
- assertTrue(uncasted instanceof DoubleValue);
- DoubleValue func = (DoubleValue) uncasted;
-
- // Neither exists
- val1.setExists(false);
- val2.setExists(false);
- func.getDouble();
- assertFalse(func.exists());
-
- // One exists
- val1.setValue(30).setExists(true);
- val2.setExists(false);
- func.getDouble();
- assertFalse(func.exists());
-
- // Both exist
- val1.setValue(30).setExists(true);
- val2.setValue(21.56F).setExists(true);
- assertEquals(51.56, func.getDouble(), 0.000001);
- assertTrue(func.exists());
- }
-
- @Test
- public void oneMultiValueParameterTest() {
- TestLongValueStream val = new TestLongValueStream();
-
- AnalyticsValueStream uncasted = AddFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DoubleValue);
- DoubleValue func = (DoubleValue) uncasted;
-
- // No values
- val.setValues();
- func.getDouble();
- assertFalse(func.exists());
-
- // One value
- val.setValues(30L);
- assertEquals(30, func.getDouble(), 0.000001);
- assertTrue(func.exists());
-
- // Multiple values
- val.setValues(30L, 20L, 55L, 61L);
- assertEquals(166, func.getDouble(), 0.000001);
- assertTrue(func.exists());
- }
-
- @Test
- public void oneMultiOneSingleValueParameterTest() {
- TestLongValueStream val1 = new TestLongValueStream();
- TestDoubleValue val2 = new TestDoubleValue();
-
- AnalyticsValueStream uncasted = AddFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});
- assertTrue(uncasted instanceof DoubleValueStream);
- DoubleValueStream func = (DoubleValueStream) uncasted;
-
- // No values, One value
- val1.setValues();
- val2.setValue(21.56F).setExists(true);
- func.streamDoubles( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Multiple values, no value
- val1.setValues(4L, 10023L);
- val2.setExists(false);
- func.streamDoubles( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Multiple values, one value
- val1.setValues(4L, 10023L, 48L);
- val2.setValue(21.56F).setExists(true);
- Iterator<Double> values = Arrays.asList(25.56, 10044.56, 69.56).iterator();
- func.streamDoubles( value -> {
- assertTrue(values.hasNext());
- assertEquals(values.next(), value, 0.000001);
- });
- assertFalse(values.hasNext());
- }
-
- @Test
- public void multipleSingleValueParameterTest() {
- TestLongValue val1 = new TestLongValue();
- TestDoubleValue val2 = new TestDoubleValue();
- TestFloatValue val3 = new TestFloatValue();
- TestIntValue val4 = new TestIntValue();
-
- AnalyticsValueStream uncasted = AddFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof DoubleValue);
- DoubleValue func = (DoubleValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getDouble();
- assertFalse(func.exists());
-
- // Some exist
- val1.setExists(false);
- val2.setValue(30.56).setExists(true);
- val3.setExists(false);
- val4.setValue(12).setExists(true);
- func.getDouble();
- assertFalse(func.exists());
-
- // All exist values, one value
- val1.setValue(45L).setExists(true);
- val2.setValue(30.56).setExists(true);
- val3.setValue(2.5F).setExists(true);
- val4.setValue(12).setExists(true);
- assertEquals(90.06, func.getDouble(), 0.000001);
- assertTrue(func.exists());
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java
deleted file mode 100644
index d2e9a1b..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.function.mapping.LogicFunction.AndFunction;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.BooleanValue;
-import org.apache.solr.analytics.value.BooleanValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestBooleanValueStream;
-import org.junit.Test;
-
-public class AndFunctionTest extends SolrTestCaseJ4 {
- @Test
- public void twoSingleValueParametersTest() {
- TestBooleanValue val1 = new TestBooleanValue();
- TestBooleanValue val2 = new TestBooleanValue();
-
- AnalyticsValueStream uncasted = AndFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});
- assertTrue(uncasted instanceof BooleanValue);
- BooleanValue func = (BooleanValue) uncasted;
-
- // Neither exists
- val1.setExists(false);
- val2.setExists(false);
- func.getBoolean();
- assertFalse(func.exists());
-
- // One exists
- val1.setValue(true).setExists(true);
- val2.setExists(false);
- func.getBoolean();
- assertFalse(func.exists());
-
- // Both exist
- val1.setValue(false).setExists(true);
- val2.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
- assertTrue(func.exists());
-
- val1.setValue(true).setExists(true);
- val2.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
- assertTrue(func.exists());
-
- val1.setValue(false).setExists(true);
- val2.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
- assertTrue(func.exists());
-
- val1.setValue(true).setExists(true);
- val2.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
- assertTrue(func.exists());
- }
-
- @Test
- public void oneMultiValueParameterTest() {
- TestBooleanValueStream val = new TestBooleanValueStream();
-
- AnalyticsValueStream uncasted = AndFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof BooleanValue);
- BooleanValue func = (BooleanValue) uncasted;
-
- // No values
- val.setValues();
- func.getBoolean();
- assertFalse(func.exists());
-
- // One value
- val.setValues(true);
- assertEquals(true, func.getBoolean());
- assertTrue(func.exists());
-
- val.setValues(false);
- assertEquals(false, func.getBoolean());
- assertTrue(func.exists());
-
- // Multiple values
- val.setValues(true, true, false, true);
- assertEquals(false, func.getBoolean());
- assertTrue(func.exists());
-
- val.setValues(true, true, true);
- assertEquals(true, func.getBoolean());
- assertTrue(func.exists());
- }
-
- @Test
- public void oneMultiOneSingleValueParameterTest() {
- TestBooleanValue val1 = new TestBooleanValue();
- TestBooleanValueStream val2 = new TestBooleanValueStream();
-
- AnalyticsValueStream uncasted = AndFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});
- assertTrue(uncasted instanceof BooleanValueStream);
- BooleanValueStream func = (BooleanValueStream) uncasted;
-
- // No values, One value
- val1.setValue(false).setExists(true);
- val2.setValues();
- func.streamBooleans( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Multiple values, no value
- val1.setExists(false);
- val2.setValues(true, false);
- func.streamBooleans( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Multiple values, one value
- val1.setValue(false).setExists(true);
- val2.setValues(true, false, true);
- Iterator<Boolean> values1 = Arrays.asList(false, false, false).iterator();
- func.streamBooleans( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next(), value);
- });
- assertFalse(values1.hasNext());
-
- val1.setValue(true).setExists(true);
- val2.setValues(true, false, true);
- Iterator<Boolean> values2 = Arrays.asList(true, false, true).iterator();
- func.streamBooleans( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void multipleSingleValueParameterTest() {
- TestBooleanValue val1 = new TestBooleanValue();
- TestBooleanValue val2 = new TestBooleanValue();
- TestBooleanValue val3 = new TestBooleanValue();
- TestBooleanValue val4 = new TestBooleanValue();
-
- AnalyticsValueStream uncasted = AndFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof BooleanValue);
- BooleanValue func = (BooleanValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getBoolean();
- assertFalse(func.exists());
-
- // Some exist
- val1.setExists(false);
- val2.setValue(true).setExists(true);
- val3.setExists(false);
- val4.setValue(false).setExists(true);
- func.getBoolean();
- assertFalse(func.exists());
-
- // All exist values, one value
- val1.setValue(true).setExists(true);
- val2.setValue(false).setExists(true);
- val3.setValue(true).setExists(true);
- val4.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
- assertTrue(func.exists());
-
- val1.setValue(true).setExists(true);
- val2.setValue(true).setExists(true);
- val3.setValue(true).setExists(true);
- val4.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
- assertTrue(func.exists());
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/BottomFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/BottomFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/BottomFunctionTest.java
deleted file mode 100644
index feb43d8..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/BottomFunctionTest.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.time.Instant;
-import java.time.format.DateTimeParseException;
-import java.util.Date;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.DateValue;
-import org.apache.solr.analytics.value.DoubleValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;
-import org.apache.solr.analytics.value.FloatValue;
-import org.apache.solr.analytics.value.IntValue;
-import org.apache.solr.analytics.value.LongValue;
-import org.apache.solr.analytics.value.StringValue;
-import org.junit.Test;
-
-public class BottomFunctionTest extends SolrTestCaseJ4 {
-
- @Test
- public void multiValueIntTest() {
- TestIntValueStream val = new TestIntValueStream();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof IntValue);
- IntValue func = (IntValue) uncasted;
-
- // Neither exists
- val.setValues();
- func.getInt();
- assertFalse(func.exists());
-
- // One exists
- val.setValues(30);
- assertEquals(30, func.getInt());
- assertTrue(func.exists());
-
- // Both exist
- val.setValues(30, 20, -10, 59);
- assertEquals(-10, func.getInt());
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueLongTest() {
- TestLongValueStream val = new TestLongValueStream();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof LongValue);
- LongValue func = (LongValue) uncasted;
-
- // Neither exists
- val.setValues();
- func.getLong();
- assertFalse(func.exists());
-
- // One exists
- val.setValues(30L);
- assertEquals(30L, func.getLong());
- assertTrue(func.exists());
-
- // Both exist
- val.setValues(30L, 20L, -10L, 59L);
- assertEquals(-10L, func.getLong());
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueFloatTest() {
- TestFloatValueStream val = new TestFloatValueStream();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof FloatValue);
- FloatValue func = (FloatValue) uncasted;
-
- // Neither exists
- val.setValues();
- func.getFloat();
- assertFalse(func.exists());
-
- // One exists
- val.setValues(30.0F);
- assertEquals(30.0F, func.getFloat(), .000001);
- assertTrue(func.exists());
-
- // Both exist
- val.setValues(30.5F, 20.01F, -10.49F, -10.48F);
- assertEquals(-10.49F, func.getFloat(), .000001);
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueDoubleTest() {
- TestDoubleValueStream val = new TestDoubleValueStream();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DoubleValue);
- DoubleValue func = (DoubleValue) uncasted;
-
- // Neither exists
- val.setValues();
- func.getDouble();
- assertFalse(func.exists());
-
- // One exists
- val.setValues(30.0);
- assertEquals(30.0, func.getDouble(), .000001);
- assertTrue(func.exists());
-
- // Both exist
- val.setValues(30.5, 20.01, -10.49, -10.48);
- assertEquals(-10.49, func.getDouble(), .000001);
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueDateTest() throws DateTimeParseException {
- TestDateValueStream val = new TestDateValueStream();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DateValue);
- DateValue func = (DateValue) uncasted;
-
- // Neither exists
- val.setValues();
- func.getDate();
- assertFalse(func.exists());
-
- // One exists
- val.setValues("1950-05-03T10:30:50Z");
- assertEquals(Date.from(Instant.parse("1950-05-03T10:30:50Z")), func.getDate());
- assertTrue(func.exists());
-
- // Both exist
- val.setValues("1950-05-03T10:30:50Z", "2200-01-01T10:00:50Z", "1800-12-31T11:30:50Z", "1930-05-020T10:45:50Z");
- assertEquals(Date.from(Instant.parse("1800-12-31T11:30:50Z")), func.getDate());
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueStringTest() {
- TestStringValueStream val = new TestStringValueStream();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof StringValue);
- StringValue func = (StringValue) uncasted;
-
- // Neither exists
- val.setValues();
- func.getString();
- assertFalse(func.exists());
-
- // One exists
- val.setValues("abc");
- assertEquals("abc", func.getString());
- assertTrue(func.exists());
-
- // Both exist
- val.setValues("1abcdef", "abc", "def", "1abc");
- assertEquals("1abc", func.getString());
- assertTrue(func.exists());
- }
-
- @Test
- public void multipleSingleValueIntTest() {
- TestIntValue val1 = new TestIntValue();
- TestIntValue val2 = new TestIntValue();
- TestIntValue val3 = new TestIntValue();
- TestIntValue val4 = new TestIntValue();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof IntValue);
- IntValue func = (IntValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getInt();
- assertFalse(func.exists());
-
- // Some exist
- val1.setValue(1000).setExists(false);
- val2.setValue(30).setExists(true);
- val3.setValue(-1000).setExists(false);
- val4.setValue(12).setExists(true);
- assertEquals(12, func.getInt());
- assertTrue(func.exists());
-
- // All exist values, one value
- val1.setValue(45).setExists(true);
- val2.setValue(30).setExists(true);
- val3.setValue(-2).setExists(true);
- val4.setValue(12).setExists(true);
- assertEquals(-2, func.getInt());
- assertTrue(func.exists());
- }
-
- @Test
- public void multipleSingleValueLongTest() {
- TestLongValue val1 = new TestLongValue();
- TestLongValue val2 = new TestLongValue();
- TestLongValue val3 = new TestLongValue();
- TestLongValue val4 = new TestLongValue();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof LongValue);
- LongValue func = (LongValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getLong();
- assertFalse(func.exists());
-
- // Some exist
- val1.setValue(1000L).setExists(false);
- val2.setValue(30L).setExists(true);
- val3.setValue(-1000L).setExists(false);
- val4.setValue(12L).setExists(true);
- assertEquals(12L, func.getLong());
- assertTrue(func.exists());
-
- // All exist values, one value
- val1.setValue(45L).setExists(true);
- val2.setValue(30L).setExists(true);
- val3.setValue(-2L).setExists(true);
- val4.setValue(12L).setExists(true);
- assertEquals(-2L, func.getLong());
- assertTrue(func.exists());
- }
-
- @Test
- public void multipleSingleValueFloatTest() {
- TestFloatValue val1 = new TestFloatValue();
- TestFloatValue val2 = new TestFloatValue();
- TestFloatValue val3 = new TestFloatValue();
- TestFloatValue val4 = new TestFloatValue();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof FloatValue);
- FloatValue func = (FloatValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getFloat();
- assertFalse(func.exists());
-
- // Some exist
- val1.setValue(1000.1233F).setExists(false);
- val2.setValue(30.34F).setExists(true);
- val3.setValue(-1000.3241F).setExists(false);
- val4.setValue(12.123F).setExists(true);
- assertEquals(12.123F, func.getFloat(), .000001);
- assertTrue(func.exists());
-
- // All exist values, one value
- val1.setValue(45.43F).setExists(true);
- val2.setValue(30.231F).setExists(true);
- val3.setValue(-2.33F).setExists(true);
- val4.setValue(12.5F).setExists(true);
- assertEquals(-2.33F, func.getFloat(), .000001);
- assertTrue(func.exists());
- }
-
- @Test
- public void multipleSingleValueDoubleTest() {
- TestDoubleValue val1 = new TestDoubleValue();
- TestDoubleValue val2 = new TestDoubleValue();
- TestDoubleValue val3 = new TestDoubleValue();
- TestDoubleValue val4 = new TestDoubleValue();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof DoubleValue);
- DoubleValue func = (DoubleValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getDouble();
- assertFalse(func.exists());
-
- // Some exist
- val1.setValue(1000.1233).setExists(false);
- val2.setValue(30.34).setExists(true);
- val3.setValue(-1000.3241).setExists(false);
- val4.setValue(12.123).setExists(true);
- assertEquals(12.123, func.getDouble(), .000001);
- assertTrue(func.exists());
-
- // All exist values, one value
- val1.setValue(45.43).setExists(true);
- val2.setValue(30.231).setExists(true);
- val3.setValue(-2.33).setExists(true);
- val4.setValue(12.5).setExists(true);
- assertEquals(-2.33, func.getDouble(), .000001);
- assertTrue(func.exists());
- }
-
- @Test
- public void multipleSingleValueDateTest() throws DateTimeParseException {
- TestDateValue val1 = new TestDateValue();
- TestDateValue val2 = new TestDateValue();
- TestDateValue val3 = new TestDateValue();
- TestDateValue val4 = new TestDateValue();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof DateValue);
- DateValue func = (DateValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getDate();
- assertFalse(func.exists());
-
- // Some exist
- val1.setValue("9999-05-03T10:30:50Z").setExists(false);
- val2.setValue("1950-05-03T10:30:50Z").setExists(true);
- val3.setValue("0000-05-03T10:30:50Z").setExists(false);
- val4.setValue("1850-05-03T10:30:50Z").setExists(true);
- assertEquals(Date.from(Instant.parse("1850-05-03T10:30:50Z")), func.getDate());
- assertTrue(func.exists());
-
- // All exist values, one value
- val1.setValue("2200-05-03T10:30:50Z").setExists(true);
- val2.setValue("1950-05-03T10:30:50Z").setExists(true);
- val3.setValue("1700-05-03T10:30:50Z").setExists(true);
- val4.setValue("1850-05-03T10:30:50Z").setExists(true);
- assertEquals(Date.from(Instant.parse("1700-05-03T10:30:50Z")), func.getDate());
- assertTrue(func.exists());
- }
-
- @Test
- public void multipleStringValueDateTest() {
- TestStringValue val1 = new TestStringValue();
- TestStringValue val2 = new TestStringValue();
- TestStringValue val3 = new TestStringValue();
- TestStringValue val4 = new TestStringValue();
-
- AnalyticsValueStream uncasted = BottomFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof StringValue);
- StringValue func = (StringValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getString();
- assertFalse(func.exists());
-
- // Some exist
- val1.setValue("abc").setExists(true);
- val2.setValue("1111").setExists(false);
- val3.setValue("asdfads").setExists(true);
- val4.setValue("zzzzzzzz").setExists(false);
- assertEquals("abc", func.getString());
- assertTrue(func.exists());
-
- // All exist values, one value
- val1.setValue("abc").setExists(true);
- val2.setValue("abc1234").setExists(true);
- val3.setValue("asdfads").setExists(true);
- val4.setValue("fdgsfg").setExists(true);
- assertEquals("abc", func.getString());
- assertTrue(func.exists());
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java
deleted file mode 100644
index c527df8..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.function.mapping.DecimalNumericConversionFunction.CeilingFunction;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.IntValue;
-import org.apache.solr.analytics.value.IntValueStream;
-import org.apache.solr.analytics.value.LongValue;
-import org.apache.solr.analytics.value.LongValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestIntValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;
-import org.junit.Test;
-
-public class CeilingFunctionTest extends SolrTestCaseJ4 {
-
- @Test
- public void singleValueFloatParameterTest() {
- TestFloatValue val = new TestFloatValue();
-
- AnalyticsValueStream uncasted = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof IntValue);
- IntValue func = (IntValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getInt();
- assertFalse(func.exists());
-
- // Value exists
- val.setValue(21.56F).setExists(true);
- assertEquals(22, func.getInt());
- assertTrue(func.exists());
-
- val.setValue(-100.3F).setExists(true);
- assertEquals(-100, func.getInt());
- assertTrue(func.exists());
- }
-
- @Test
- public void singleValueDoubleParameterTest() {
- TestDoubleValue val = new TestDoubleValue();
-
- AnalyticsValueStream uncasted = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof LongValue);
- LongValue func = (LongValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getLong();
- assertFalse(func.exists());
-
- // Value exists
- val.setValue(21.56).setExists(true);
- assertEquals(22L, func.getLong());
- assertTrue(func.exists());
-
- val.setValue(-100.3).setExists(true);
- assertEquals(-100L, func.getLong());
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueFloatParameterTest() {
- TestFloatValueStream val = new TestFloatValueStream();
-
- AnalyticsValueStream uncasted = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof IntValueStream);
- IntValueStream func = (IntValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamInts( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues(-4F);
- Iterator<Integer> values1 = Arrays.asList(-4).iterator();
- func.streamInts( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next().intValue(), value);
- });
- assertFalse(values1.hasNext());
-
- // Multiple values
- val.setValues(4F, -10.9999F, 50.00001F, 74.99999F);
- Iterator<Integer> values2 = Arrays.asList(4, -10, 51, 75).iterator();
- func.streamInts( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next().intValue(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void multiValueDoubleParameterTest() {
- TestDoubleValueStream val = new TestDoubleValueStream();
-
- AnalyticsValueStream uncasted = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof LongValueStream);
- LongValueStream func = (LongValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamLongs( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues(-4);
- Iterator<Long> values1 = Arrays.asList(-4L).iterator();
- func.streamLongs( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next().longValue(), value);
- });
- assertFalse(values1.hasNext());
-
- // Multiple values
- val.setValues(4, -10.9999, 50.000001, 74.99999);
- Iterator<Long> values2 = Arrays.asList(4L, -10L, 51L, 75L).iterator();
- func.streamLongs( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next().longValue(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void nonDecimalParameterTest() {
- AnalyticsValueStream result;
- AnalyticsValueStream param;
-
- param = new TestIntValue();
- result = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});
- assertTrue(result instanceof IntValue);
- assertEquals(param, result);
-
- param = new TestIntValueStream();
- result = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});
- assertTrue(result instanceof IntValueStream);
- assertEquals(param, result);
-
- param = new TestLongValue();
- result = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});
- assertTrue(result instanceof LongValue);
- assertEquals(param, result);
-
- param = new TestLongValueStream();
- result = CeilingFunction.creatorFunction.apply(new AnalyticsValueStream[] {param});
- assertTrue(result instanceof LongValueStream);
- assertEquals(param, result);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java
deleted file mode 100644
index db5b36e..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.function.mapping.ConcatFunction.SeparatedConcatFunction;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;
-import org.apache.solr.analytics.value.StringValue;
-import org.apache.solr.analytics.value.StringValueStream;
-import org.apache.solr.analytics.value.constant.ConstantStringValue;
-import org.junit.Test;
-
-public class ConcatFunctionTest extends SolrTestCaseJ4 {
-
- @Test
- public void oneMultiValueParameterUnseparatedTest() {
- TestStringValueStream val = new TestStringValueStream();
-
- AnalyticsValueStream uncasted = ConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof StringValue);
- StringValue func = (StringValue) uncasted;
-
- // No values
- val.setValues();
- func.getString();
- assertFalse(func.exists());
-
- // One value
- val.setValues("abc");
- assertEquals("abc", func.getString());
- assertTrue(func.exists());
-
- // Multiple values
- val.setValues("abc", "def", "ghi");
- assertEquals("abcdefghi", func.getString());
- assertTrue(func.exists());
- }
-
- @Test
- public void oneMultiValueParameterSeparatedTest() {
- TestStringValueStream val = new TestStringValueStream();
- ConstantStringValue sep = new ConstantStringValue("===:---");
-
- AnalyticsValueStream uncasted = SeparatedConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {sep, val});
- assertTrue(uncasted instanceof StringValue);
- StringValue func = (StringValue) uncasted;
-
- // No values
- val.setValues();
- func.getString();
- assertFalse(func.exists());
-
- // One value
- val.setValues("abc");
- assertEquals("abc", func.getString());
- assertTrue(func.exists());
-
- // Multiple values
- val.setValues("abc", "def", "ghi");
- assertEquals("abc===:---def===:---ghi", func.getString());
- assertTrue(func.exists());
- }
-
- @Test
- public void oneSingleOneMultiValueParameterUnseperatedTest() {
- TestStringValue val1 = new TestStringValue();
- TestStringValueStream val2 = new TestStringValueStream();
-
- AnalyticsValueStream uncasted = ConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});
- assertTrue(uncasted instanceof StringValueStream);
- StringValueStream func = (StringValueStream) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setValues();
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One exists
- val1.setExists(false);
- val2.setValues("def");
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- val1.setValue("abc").setExists(true);
- val2.setValues();
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Both exist
- val1.setValue("abc").setExists(true);
- val2.setValues("def", "ghi", "jkl");
- Iterator<String> values2 = Arrays.asList("abcdef", "abcghi", "abcjkl").iterator();
- func.streamStrings( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void oneSingleOneMultiValueParameterSeperatedTest() {
- TestStringValue val1 = new TestStringValue();
- TestStringValueStream val2 = new TestStringValueStream();
- ConstantStringValue sep = new ConstantStringValue("+-;");
-
- AnalyticsValueStream uncasted = SeparatedConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {sep, val1, val2});
- assertTrue(uncasted instanceof StringValueStream);
- StringValueStream func = (StringValueStream) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setValues();
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One exists
- val1.setExists(false);
- val2.setValues("def");
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- val1.setValue("abc").setExists(true);
- val2.setValues();
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Both exist
- val1.setValue("abc").setExists(true);
- val2.setValues("def", "ghi", "jkl");
- Iterator<String> values2 = Arrays.asList("abc+-;def", "abc+-;ghi", "abc+-;jkl").iterator();
- func.streamStrings( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void oneMultiOneSingleValueParameterUnseperatedTest() {
- TestStringValueStream val1 = new TestStringValueStream();
- TestStringValue val2 = new TestStringValue();
-
- AnalyticsValueStream uncasted = ConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2});
- assertTrue(uncasted instanceof StringValueStream);
- StringValueStream func = (StringValueStream) uncasted;
-
- // None exist
- val1.setValues();
- val2.setExists(false);
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One exists
- val1.setValues("def");
- val2.setExists(false);
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- val1.setValues();
- val2.setValue("abc").setExists(true);
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Both exist
- val1.setValues("def", "ghi", "jkl");
- val2.setValue("abc").setExists(true);
- Iterator<String> values2 = Arrays.asList("defabc", "ghiabc", "jklabc").iterator();
- func.streamStrings( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void oneMultiOneSingleValueParameterSeperatedTest() {
- TestStringValueStream val1 = new TestStringValueStream();
- TestStringValue val2 = new TestStringValue();
- ConstantStringValue sep = new ConstantStringValue("<");
-
- AnalyticsValueStream uncasted = SeparatedConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {sep, val1, val2});
- assertTrue(uncasted instanceof StringValueStream);
- StringValueStream func = (StringValueStream) uncasted;
-
- // None exist
- val1.setValues();
- val2.setExists(false);
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One exists
- val1.setValues("def");
- val2.setExists(false);
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- val1.setValues();
- val2.setValue("abc").setExists(true);
- func.streamStrings( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Both exist
- val1.setValues("def", "ghi", "jkl");
- val2.setValue("abc").setExists(true);
- Iterator<String> values2 = Arrays.asList("def<abc", "ghi<abc", "jkl<abc").iterator();
- func.streamStrings( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value);
- });
- assertFalse(values2.hasNext());
- }
-
- @Test
- public void multipleSingleValueParameterUnseperatedTest() {
- TestStringValue val1 = new TestStringValue();
- TestStringValue val2 = new TestStringValue();
- TestStringValue val3 = new TestStringValue();
- TestStringValue val4 = new TestStringValue();
-
- AnalyticsValueStream uncasted = ConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {val1, val2, val3, val4});
- assertTrue(uncasted instanceof StringValue);
- StringValue func = (StringValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getString();
- assertFalse(func.exists());
-
- // Some exist
- val1.setExists(false);
- val2.setValue("def").setExists(true);
- val3.setExists(false);
- val4.setValue("jkl").setExists(true);
- assertEquals("defjkl", func.getString());
- assertTrue(func.exists());
-
- // All exist values, one value
- val1.setValue("abc").setExists(true);
- val2.setValue("def").setExists(true);
- val3.setValue("ghi").setExists(true);
- val4.setValue("jkl").setExists(true);
- assertEquals("abcdefghijkl", func.getString());
- assertTrue(func.exists());
- }
-
- @Test
- public void multipleSingleValueParameterSeperatedTest() {
- TestStringValue val1 = new TestStringValue();
- TestStringValue val2 = new TestStringValue();
- TestStringValue val3 = new TestStringValue();
- TestStringValue val4 = new TestStringValue();
- ConstantStringValue sep = new ConstantStringValue("+:-");
-
- AnalyticsValueStream uncasted = SeparatedConcatFunction.creatorFunction.apply(new AnalyticsValueStream[] {sep, val1, val2, val3, val4});
- assertTrue(uncasted instanceof StringValue);
- StringValue func = (StringValue) uncasted;
-
- // None exist
- val1.setExists(false);
- val2.setExists(false);
- val3.setExists(false);
- val4.setExists(false);
- func.getString();
- assertFalse(func.exists());
-
- // Some exist
- val1.setExists(false);
- val2.setValue("def").setExists(true);
- val3.setExists(false);
- val4.setValue("jkl").setExists(true);
- assertEquals("def+:-jkl", func.getString());
- assertTrue(func.exists());
-
- // All exist values, one value
- val1.setValue("abc").setExists(true);
- val2.setValue("def").setExists(true);
- val3.setValue("ghi").setExists(true);
- val4.setValue("jkl").setExists(true);
- assertEquals("abc+:-def+:-ghi+:-jkl", func.getString());
- assertTrue(func.exists());
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DateMathFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DateMathFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DateMathFunctionTest.java
deleted file mode 100644
index f3802af..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DateMathFunctionTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.time.Instant;
-import java.time.format.DateTimeParseException;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Iterator;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.DateValue;
-import org.apache.solr.analytics.value.DateValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestDateValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestDateValueStream;
-import org.apache.solr.analytics.value.constant.ConstantStringValue;
-import org.junit.Test;
-
-public class DateMathFunctionTest extends SolrTestCaseJ4 {
-
- @Test
- public void singleValueParameterTest() throws DateTimeParseException {
- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));
- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));
-
- TestDateValue val = new TestDateValue();
-
- ConstantStringValue math1 = new ConstantStringValue("+1DAY");
- ConstantStringValue math2 = new ConstantStringValue("-1MONTH");
- ConstantStringValue math3 = new ConstantStringValue("+11YEARS");
-
- AnalyticsValueStream uncasted = DateMathFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, math1, math2, math3});
- assertTrue(uncasted instanceof DateValue);
- DateValue func = (DateValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getDate();
- assertFalse(func.exists());
- func.getLong();
- assertFalse(func.exists());
-
- // Value exists
- val.setValue("1800-01-01T10:30:15Z").setExists(true);
- assertEquals(date1, func.getDate());
- assertTrue(func.exists());
- assertEquals(date1.getTime(), func.getLong());
- assertTrue(func.exists());
-
- val.setValue("1920-04-15T18:15:45Z").setExists(true);
- assertEquals(date2, func.getDate());
- assertTrue(func.exists());
- assertEquals(date2.getTime(), func.getLong());
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueParamaterTest() throws DateTimeParseException {
- Date date1 = Date.from(Instant.parse("1810-12-02T10:30:15Z"));
- Date date2 = Date.from(Instant.parse("1931-03-16T18:15:45Z"));
- Date date3 = Date.from(Instant.parse("2023-11-01T20:30:15Z"));
-
- TestDateValueStream val = new TestDateValueStream();
-
- ConstantStringValue math1 = new ConstantStringValue("+1DAY");
- ConstantStringValue math2 = new ConstantStringValue("-1MONTH");
- ConstantStringValue math3 = new ConstantStringValue("+11YEARS");
-
- AnalyticsValueStream uncasted = DateMathFunction.creatorFunction.apply(new AnalyticsValueStream[] {val, math1, math2, math3});
- assertTrue(uncasted instanceof DateValueStream);
- DateValueStream func = (DateValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamDates( value -> {
- assertTrue("There should be no values to stream", false);
- });
- func.streamLongs( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues("1800-01-01T10:30:15Z");
- Iterator<Date> values1 = Arrays.asList(date1).iterator();
- func.streamDates( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next(), value);
- });
- assertFalse(values1.hasNext());
- Iterator<Long> times1 = Arrays.asList(date1.getTime()).iterator();
- func.streamLongs( value -> {
- assertTrue(times1.hasNext());
- assertEquals(times1.next().longValue(), value);
- });
- assertFalse(times1.hasNext());
-
- // Multiple values
- val.setValues("1800-01-01T10:30:15Z", "1920-04-15T18:15:45Z", "2012-11-30T20:30:15Z");
- Iterator<Date> values2 = Arrays.asList(date1, date2, date3).iterator();
- func.streamDates( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value);
- });
- assertFalse(values2.hasNext());
- Iterator<Long> times2 = Arrays.asList(date1.getTime(), date2.getTime(), date3.getTime()).iterator();
- func.streamLongs( value -> {
- assertTrue(times2.hasNext());
- assertEquals(times2.next().longValue(), value);
- });
- assertFalse(times2.hasNext());
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DateParseFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DateParseFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DateParseFunctionTest.java
deleted file mode 100644
index 2f34833..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DateParseFunctionTest.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.time.Instant;
-import java.time.format.DateTimeParseException;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Iterator;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.DateValue;
-import org.apache.solr.analytics.value.DateValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestStringValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestStringValueStream;
-import org.junit.Test;
-
-public class DateParseFunctionTest extends SolrTestCaseJ4 {
-
- @Test
- public void singleValueLongTest() throws DateTimeParseException {
- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));
- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));
- TestLongValue val = new TestLongValue();
-
- AnalyticsValueStream uncasted = DateParseFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DateValue);
- DateValue func = (DateValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getDate();
- assertFalse(func.exists());
- func.getLong();
- assertFalse(func.exists());
-
- // Value exists
- val.setValue(date1.getTime()).setExists(true);
- assertEquals(date1, func.getDate());
- assertTrue(func.exists());
- assertEquals(date1.getTime(), func.getLong());
- assertTrue(func.exists());
-
- val.setValue(date2.getTime()).setExists(true);
- assertEquals(date2, func.getDate());
- assertTrue(func.exists());
- assertEquals(date2.getTime(), func.getLong());
- assertTrue(func.exists());
- }
-
- @Test
- public void singleValueStringTest() throws DateTimeParseException {
- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));
- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));
- TestStringValue val = new TestStringValue();
-
- AnalyticsValueStream uncasted = DateParseFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DateValue);
- DateValue func = (DateValue) uncasted;
-
- // Value doesn't exist
- val.setExists(false);
- func.getDate();
- assertFalse(func.exists());
- func.getLong();
- assertFalse(func.exists());
-
- // Incorrect Value
- val.setValue("1800-01T10:30:15Z").setExists(true);
- func.getDate();
- assertFalse(func.exists());
- func.getLong();
- assertFalse(func.exists());
-
- val.setValue("1800-01-T::Z").setExists(true);
- func.getDate();
- assertFalse(func.exists());
- func.getLong();
- assertFalse(func.exists());
-
- val.setValue("1800--01T30:30:15Z").setExists(true);
- func.getDate();
- assertFalse(func.exists());
- func.getLong();
- assertFalse(func.exists());
-
-
- // Value exists
- val.setValue("1800-01-01T10:30:15Z").setExists(true);
- assertEquals(date1, func.getDate());
- assertTrue(func.exists());
- assertEquals(date1.getTime(), func.getLong());
- assertTrue(func.exists());
-
- val.setValue("1920-04-15T18:15:45Z").setExists(true);
- assertEquals(date2, func.getDate());
- assertTrue(func.exists());
- assertEquals(date2.getTime(), func.getLong());
- assertTrue(func.exists());
- }
-
- @Test
- public void multiValueLongTest() throws DateTimeParseException {
- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));
- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));
- Date date3 = Date.from(Instant.parse("2012-11-30T20:30:15Z"));
- TestLongValueStream val = new TestLongValueStream();
-
- AnalyticsValueStream uncasted = DateParseFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DateValueStream);
- DateValueStream func = (DateValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamDates( value -> {
- assertTrue("There should be no values to stream", false);
- });
- func.streamLongs( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues(date1.getTime());
- Iterator<Date> values1 = Arrays.asList(date1).iterator();
- func.streamDates( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next(), value);
- });
- assertFalse(values1.hasNext());
- Iterator<Long> times1 = Arrays.asList(date1.getTime()).iterator();
- func.streamLongs( value -> {
- assertTrue(times1.hasNext());
- assertEquals(times1.next().longValue(), value);
- });
- assertFalse(times1.hasNext());
-
- // Multiple values
- val.setValues(date1.getTime(), date2.getTime(), date3.getTime());
- Iterator<Date> values2 = Arrays.asList(date1, date2, date3).iterator();
- func.streamDates( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value);
- });
- assertFalse(values2.hasNext());
- Iterator<Long> times2 = Arrays.asList(date1.getTime(), date2.getTime(), date3.getTime()).iterator();
- func.streamLongs( value -> {
- assertTrue(times2.hasNext());
- assertEquals(times2.next().longValue(), value);
- });
- assertFalse(times2.hasNext());
- }
-
- @Test
- public void multiValueStringTest() throws DateTimeParseException {
- Date date1 = Date.from(Instant.parse("1800-01-01T10:30:15Z"));
- Date date2 = Date.from(Instant.parse("1920-04-15T18:15:45Z"));
- Date date3 = Date.from(Instant.parse("2012-11-30T20:30:15Z"));
- TestStringValueStream val = new TestStringValueStream();
-
- AnalyticsValueStream uncasted = DateParseFunction.creatorFunction.apply(new AnalyticsValueStream[] {val});
- assertTrue(uncasted instanceof DateValueStream);
- DateValueStream func = (DateValueStream) uncasted;
-
- // No values
- val.setValues();
- func.streamDates( value -> {
- assertTrue("There should be no values to stream", false);
- });
- func.streamLongs( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Incorrect value
- val.setValues("10:30:15Z");
- func.streamDates( value -> {
- assertTrue("There should be no values to stream", false);
- });
- func.streamLongs( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- val.setValues("01-33T10:30:15Z");
- func.streamDates( value -> {
- assertTrue("There should be no values to stream", false);
- });
- func.streamLongs( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- val.setValues("1800-01T30:30:15Z");
- func.streamDates( value -> {
- assertTrue("There should be no values to stream", false);
- });
- func.streamLongs( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // One value
- val.setValues("1800-01-01T10:30:15Z");
- Iterator<Date> values1 = Arrays.asList(date1).iterator();
- func.streamDates( value -> {
- assertTrue(values1.hasNext());
- assertEquals(values1.next(), value);
- });
- assertFalse(values1.hasNext());
- Iterator<Long> times1 = Arrays.asList(date1.getTime()).iterator();
- func.streamLongs( value -> {
- assertTrue(times1.hasNext());
- assertEquals(times1.next().longValue(), value);
- });
- assertFalse(times1.hasNext());
-
- // Multiple values
- val.setValues("1800-01-01T10:30:15Z", "1920-04-15T18:15:45Z", "2012-11-30T20:30:15Z");
- Iterator<Date> values2 = Arrays.asList(date1, date2, date3).iterator();
- func.streamDates( value -> {
- assertTrue(values2.hasNext());
- assertEquals(values2.next(), value);
- });
- assertFalse(values2.hasNext());
- Iterator<Long> times2 = Arrays.asList(date1.getTime(), date2.getTime(), date3.getTime()).iterator();
- func.streamLongs( value -> {
- assertTrue(times2.hasNext());
- assertEquals(times2.next().longValue(), value);
- });
- assertFalse(times2.hasNext());
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java
deleted file mode 100644
index 5ca324d..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.mapping;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.value.AnalyticsValueStream;
-import org.apache.solr.analytics.value.DoubleValue;
-import org.apache.solr.analytics.value.DoubleValueStream;
-import org.apache.solr.analytics.value.FillableTestValue.TestDoubleValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestFloatValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestIntValue;
-import org.apache.solr.analytics.value.FillableTestValue.TestLongValueStream;
-import org.junit.Test;
-
-public class DivideFunctionTest extends SolrTestCaseJ4 {
- @Test
- public void twoSingleValueParametersTest() {
- TestIntValue dividend = new TestIntValue();
- TestFloatValue divisor = new TestFloatValue();
-
- AnalyticsValueStream uncasted = DivideFunction.creatorFunction.apply(new AnalyticsValueStream[] {dividend, divisor});
- assertTrue(uncasted instanceof DoubleValue);
- DoubleValue func = (DoubleValue) uncasted;
-
- // Neither exists
- dividend.setExists(false);
- divisor.setExists(false);
- func.getDouble();
- assertFalse(func.exists());
-
- // One exists
- dividend.setValue(30).setExists(true);
- divisor.setExists(false);
- func.getDouble();
- assertFalse(func.exists());
-
- // Both exist
- dividend.setValue(60).setExists(true);
- divisor.setValue(23.56F).setExists(true);
- assertEquals(2.546689, func.getDouble(), 0.00001);
- assertTrue(func.exists());
- }
-
- @Test
- public void oneMultiOneSingleValueParameterTest() {
- TestLongValueStream dividend = new TestLongValueStream();
- TestDoubleValue divisor = new TestDoubleValue();
-
- AnalyticsValueStream uncasted = DivideFunction.creatorFunction.apply(new AnalyticsValueStream[] {dividend, divisor});
- assertTrue(uncasted instanceof DoubleValueStream);
- DoubleValueStream func = (DoubleValueStream) uncasted;
-
- // No values, One value
- dividend.setValues();
- divisor.setValue(21.56F).setExists(true);
- func.streamDoubles( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Multiple values, no value
- dividend.setValues(4L, 10023L);
- divisor.setExists(false);
- func.streamDoubles( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Multiple values, one value
- dividend.setValues(20L, 5L, -234L);
- divisor.setValue(44.56F).setExists(true);
- Iterator<Double> values = Arrays.asList(0.448833, 0.112208, -5.251346).iterator();
- func.streamDoubles( value -> {
- assertTrue(values.hasNext());
- assertEquals(values.next(), value, 0.00001);
- });
- assertFalse(values.hasNext());
- }
-
- @Test
- public void oneSingleOneMultiValueParameterTest() {
- TestDoubleValue dividend = new TestDoubleValue();
- TestLongValueStream divisor = new TestLongValueStream();
-
- AnalyticsValueStream uncasted = DivideFunction.creatorFunction.apply(new AnalyticsValueStream[] {dividend, divisor});
- assertTrue(uncasted instanceof DoubleValueStream);
- DoubleValueStream func = (DoubleValueStream) uncasted;
-
- // No values, One value
- dividend.setValue(21.56F).setExists(true);
- divisor.setValues();
- func.streamDoubles( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Multiple values, no value
- dividend.setExists(false);
- divisor.setValues(4L, 10023L);
- func.streamDoubles( value -> {
- assertTrue("There should be no values to stream", false);
- });
-
- // Multiple values, one value
- dividend.setValue(44.56F).setExists(true);
- divisor.setValues(20L, 5L, -234L);
- Iterator<Double> values = Arrays.asList(2.228, 8.912, -0.190427).iterator();
- func.streamDoubles( value -> {
- assertTrue(values.hasNext());
- assertEquals(values.next(), value, 0.00001);
- });
- assertFalse(values.hasNext());
- }
-}