Github user JPercivall commented on a diff in the pull request:
https://github.com/apache/nifi/pull/237#discussion_r56191239
--- Diff:
nifi-nar-bundles/nifi-cassandra-bundle/nifi-cassandra-processors/src/test/java/org/apache/nifi/processors/cassandra/PutCassandraQLTest.java
---
@@ -0,0 +1,189 @@
+/*
+ * 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.cassandra;
+
+import com.datastax.driver.core.BoundStatement;
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Configuration;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.Metadata;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.ResultSetFuture;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.Statement;
+import com.datastax.driver.core.exceptions.InvalidQueryException;
+import com.datastax.driver.core.exceptions.NoHostAvailableException;
+import com.datastax.driver.core.exceptions.UnavailableException;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.net.ssl.SSLContext;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Unit tests for the PutCassandraQL processor
+ */
+public class PutCassandraQLTest {
+
+ private TestRunner testRunner;
+ private MockPutCassandraQL processor;
+
+ @Before
+ public void setUp() throws Exception {
+ processor = new MockPutCassandraQL();
+ testRunner = TestRunners.newTestRunner(processor);
+ }
+
+ @Test
+ public void testProcessor() {
+ testRunner.setProperty(AbstractCassandraProcessor.CONTACT_POINTS,
"localhost:9042");
+ testRunner.assertValid();
+ testRunner.setProperty(AbstractCassandraProcessor.PASSWORD,
"password");
+ testRunner.assertNotValid();
+ testRunner.setProperty(AbstractCassandraProcessor.USERNAME,
"username");
+
testRunner.setProperty(AbstractCassandraProcessor.CONSISTENCY_LEVEL, "ONE");
+ testRunner.assertValid();
+
+ testRunner.enqueue("INSERT INTO users (user_id, first_name,
last_name, properties) VALUES ?, ?, ?, ?",
+ new HashMap<String, String>() {
+ {
+ put("cql.args.1.type", "int");
+ put("cql.args.1.value", "1");
+ put("cql.args.2.type", "text");
+ put("cql.args.2.value", "Joe");
+ put("cql.args.3.type", "text");
+ // No value for arg 3 to test setNull
+ put("cql.args.4.type", "map<text,text>");
+ put("cql.args.4.value", "{'a':'Hello',
'b':'World'}");
+ put("cql.args.5.type", "list<boolean>");
+ put("cql.args.5.value", "[true,false,true]");
+ put("cql.args.6.type", "set<double>");
+ put("cql.args.6.value", "{1.0, 2.0}");
+ put("cql.args.7.type", "bigint");
+ put("cql.args.7.value", "20000000");
+ put("cql.args.8.type", "float");
+ put("cql.args.8.value", "1.0");
+ put("cql.args.9.type", "blob");
+ put("cql.args.9.value", "0xDEADBEEF");
+
+ }
+ });
+ testRunner.run(1, true, true);
+
testRunner.assertAllFlowFilesTransferred(PutCassandraQL.REL_SUCCESS, 1);
+ testRunner.clearTransferState();
+
+ // Test exceptions
--- End diff --
Any thoughts on breaking each of these out into it's own test? It would
allow for better readability and modularity when something does go wrong.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---