Github user bdesert commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2478#discussion_r169677516
--- Diff:
nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/TestScanHBase.java
---
@@ -0,0 +1,375 @@
+/*
+ * 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.nifi.hbase;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestScanHBase {
+
+ private ScanHBase proc;
+ private MockHBaseClientService hBaseClientService;
+ private TestRunner runner;
+
+ @Before
+ public void setup() throws InitializationException {
+ proc = new ScanHBase();
+ runner = TestRunners.newTestRunner(proc);
+
+ hBaseClientService = new MockHBaseClientService();
+ runner.addControllerService("hbaseClient", hBaseClientService);
+ runner.enableControllerService(hBaseClientService);
+ runner.setProperty(ScanHBase.HBASE_CLIENT_SERVICE, "hbaseClient");
+ }
+
+ @Test
+ public void testColumnsValidation() {
+ runner.setProperty(ScanHBase.TABLE_NAME, "table1");
+ runner.setProperty(ScanHBase.START_ROW, "row1");
+ runner.setProperty(ScanHBase.END_ROW, "row1");
+ runner.assertValid();
+
+ runner.setProperty(ScanHBase.COLUMNS, "cf1:cq1");
+ runner.assertValid();
+
+ runner.setProperty(ScanHBase.COLUMNS, "cf1");
+ runner.assertValid();
+
+ runner.setProperty(ScanHBase.COLUMNS, "cf1:cq1,cf2:cq2,cf3:cq3");
+ runner.assertValid();
+
+ runner.setProperty(ScanHBase.COLUMNS, "cf1,cf2:cq1,cf3");
+ runner.assertValid();
+
+ runner.setProperty(ScanHBase.COLUMNS, "cf1 cf2,cf3");
+ runner.assertNotValid();
+
+ runner.setProperty(ScanHBase.COLUMNS, "cf1:,cf2,cf3");
+ runner.assertNotValid();
+
+ runner.setProperty(ScanHBase.COLUMNS, "cf1:cq1,");
+ runner.assertNotValid();
+ }
+
+ @Test
+ public void testNoIncomingFlowFile() {
+ runner.setProperty(ScanHBase.TABLE_NAME, "table1");
+ runner.setProperty(ScanHBase.START_ROW, "row1");
+ runner.setProperty(ScanHBase.END_ROW, "row1");
+
+ runner.run();
+ runner.assertTransferCount(ScanHBase.REL_FAILURE, 0);
+ runner.assertTransferCount(ScanHBase.REL_SUCCESS, 0);
+ runner.assertTransferCount(ScanHBase.REL_ORIGINAL, 0);
+
+ Assert.assertEquals(0, hBaseClientService.getNumScans());
+ }
+
+ @Test
+ public void testInvalidTableName() {
+ runner.setProperty(ScanHBase.TABLE_NAME, "${hbase.table}");
--- End diff --
Not setting a value for "hbase.table" is intentional. This test is for
failure handling if expression is invalid (cannot be evaluated). You can see
that FF expected at REL_FAILURE without scans. If I just didn't understand what
you meant, please let me know.
---