diff options
| author | reger <reger18@arcor.de> | 2017-08-14 02:16:43 +0200 |
|---|---|---|
| committer | reger <reger18@arcor.de> | 2017-08-14 02:16:43 +0200 |
| commit | f38fb7f02c9c93e73a6a3326b98074bc1624f9f0 (patch) | |
| tree | e5e5089f3cde64893bd9582f12ffb888f19c91d7 /test/java | |
| parent | 2a07799ad10c81ee3bbce7af8ea6b972e3e4d86a (diff) | |
Add junit test for AbstractOperations.addOperand()
Diffstat (limited to 'test/java')
| -rw-r--r-- | test/java/net/yacy/cora/federate/solr/logic/AbstractOperationsTest.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/java/net/yacy/cora/federate/solr/logic/AbstractOperationsTest.java b/test/java/net/yacy/cora/federate/solr/logic/AbstractOperationsTest.java new file mode 100644 index 000000000..30eda250a --- /dev/null +++ b/test/java/net/yacy/cora/federate/solr/logic/AbstractOperationsTest.java @@ -0,0 +1,57 @@ +/**
+ * AbstractOperationsTest
+ * part of YaCy
+ * Copyright 2017 by reger24; https://github.com/reger24
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.yacy.cora.federate.solr.logic;
+
+import net.yacy.search.schema.CollectionSchema;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ * Unit tests for AbstractOperationsTest class.
+ *
+ */
+public class AbstractOperationsTest {
+
+ /**
+ * Test of addOperand method, of class AbstractOperations.
+ */
+ @Test
+ public void testAddOperand() {
+
+
+ // create a simple query
+ Conjunction con = new Conjunction();
+ con.addOperand(new LongLiteral(CollectionSchema.httpstatus_i, 200)); // result: con="httpstatus_i:200"
+
+ // create a 2nd empty query
+ Disjunction dnf = new Disjunction();
+ // add the empty query
+ con.addOperand(dnf); // result (shall be unchanged): "httpstatus_i:200"
+
+ // test for wrong result "(httpstatus_i:200 AND )"
+ String query = con.toString();
+ String testStr = query.replace(")", ""); // remove all ')' for easier testing
+ testStr = testStr.replace("(", ""); // remove all '(' for easier testing
+ testStr = testStr.trim();
+ assertFalse("query ending with operator =" + query, testStr.endsWith(con.operandName));
+ assertFalse("query ending with operator =" + query, testStr.endsWith(dnf.operandName));
+ }
+
+}
|
