tpalfy commented on a change in pull request #3611: NIFI-6009 ScanKudu Processor
URL: https://github.com/apache/nifi/pull/3611#discussion_r326722572
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/test/java/org/apache/nifi/processors/kudu/MockKuduScan.java
 ##########
 @@ -0,0 +1,216 @@
+/*
+ * 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.processors.kudu;
+
+import org.apache.kudu.ColumnSchema;
+import org.apache.kudu.Schema;
+import org.apache.kudu.Type;
+import org.apache.kudu.client.KuduClient;
+import org.apache.kudu.client.KuduTable;
+import org.apache.kudu.client.KuduSession;
+import org.apache.kudu.client.RowResult;
+import org.apache.kudu.client.RowResultIterator;
+import org.apache.kudu.client.Insert;
+import org.apache.nifi.processors.kudu.io.ResultHandler;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.security.krb.KerberosUser;
+
+import javax.security.auth.login.LoginException;
+import java.io.IOException;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class MockKuduScan extends ScanKudu {
+
+    private KuduSession session;
+    private LinkedList<Insert> insertQueue;
+
+    private boolean loggedIn = false;
+    private boolean loggedOut = false;
+    private int numScans = 0;
+    private boolean throwException = false;
+    private int linesBeforeException = -1;
+    RowResultIterator testRows = mock(RowResultIterator.class);
+    List<RowResult> rowResultList = new ArrayList<>();
+
+    public MockKuduScan() {
+        this(mock(KuduSession.class));
+    }
+
+    public MockKuduScan(KuduSession session) {
+        this.session = session;
+        this.insertQueue = new LinkedList<>();
+    }
+
+    public void queue(Insert... operations) {
+        insertQueue.addAll(Arrays.asList(operations));
+    }
+
+    @Override
+    public KuduClient buildClient(final String masters, ProcessContext 
context) {
 
 Review comment:
   There are quite a few code duplications, maybe we could extract an 
`AbstractMockKuduProcessor` class?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to