Github user mans2singh commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2562#discussion_r178480359
  
    --- Diff: 
nifi-nar-bundles/nifi-influxdb-bundle/nifi-influxdb-processors/src/test/java/org/apache/nifi/processors/influxdb/ITExecuteInfluxDBQuery.java
 ---
    @@ -0,0 +1,231 @@
    +/*
    + * 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.influxdb;
    +import static org.junit.Assert.assertEquals;
    +import org.junit.Assert;
    +import java.util.List;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.util.MockFlowFile;
    +import org.apache.nifi.util.TestRunners;
    +import org.influxdb.InfluxDB;
    +import org.influxdb.dto.QueryResult;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +/**
    + * Integration test for executing InfluxDB queries. Please ensure that the 
InfluxDB is running
    + * on local host with default port and has database test with table test. 
Please set user
    + * and password if applicable before running the integration tests.
    + */
    +public class ITExecuteInfluxDBQuery extends AbstractITInfluxDB {
    +
    +    @Before
    +    public void setUp() throws Exception {
    +        initInfluxDB();
    +        runner = TestRunners.newTestRunner(ExecuteInfluxDBQuery.class);
    +        initializeRunner();
    +    }
    +
    +    @Test
    +    public void testValidScheduleQueryWithNoIncoming() {
    +        String message = "water,country=US,city=newark rain=1,humidity=0.6 
1501002274856668652";
    +        influxDB.write(dbName, DEFAULT_RETENTION_POLICY, 
InfluxDB.ConsistencyLevel.ONE, message);
    +
    +        String query = "select * from water";
    +        runner.setProperty(ExecuteInfluxDBQuery.INFLUX_DB_QUERY, query);
    +
    +        runner.setIncomingConnection(false);
    +        runner.run(1,true,true);
    +        
runner.assertAllFlowFilesTransferred(ExecuteInfluxDBQuery.REL_SUCCESS, 1);
    +        List<MockFlowFile> flowFiles = 
runner.getFlowFilesForRelationship(ExecuteInfluxDBQuery.REL_SUCCESS);
    +        assertEquals("Value should be equal", 1, flowFiles.size());
    +        assertEquals("Value should be equal",null, 
flowFiles.get(0).getAttribute(ExecuteInfluxDBQuery.INFLUX_DB_ERROR_MESSAGE));
    +        assertEquals("Value should be equal",query, 
flowFiles.get(0).getAttribute(ExecuteInfluxDBQuery.INFLUX_DB_EXECUTED_QUERY));
    +        flowFiles.get(0).assertContentEquals(
    --- End diff --
    
    Updated to parse json and compare typed results.


---

Reply via email to