Kumar,

I would validate you included the nifi-mock in your pom.xml.

For more information on testing review the developer guide
<https://nifi.apache.org/docs/nifi-docs/html/developer-guide.html#testing>
or this post
<https://www.nifi.rocks/developing-a-custom-apache-nifi-processor-unit-tests-partI/>
.

Hope that helps,

Phillip
https://nifi.rocks

On Tue, Feb 26, 2019 at 6:04 PM Sandish Kumar HN <[email protected]>
wrote:

> Hi,
>
>
> *I'm stuck with below error:*
>
>
> java.lang.AssertionError: Could not invoke methods annotated with
> @OnScheduled annotation due to: java.lang.reflect.InvocationTargetException
>
> at
>
> org.apache.nifi.kudu.TestPutKuduT.testWriteKuduWithDefaults(TestPutKuduT.java:70)
>
>
> [INFO]
>
> [INFO] Results:
>
> [INFO]
>
> [ERROR] Failures:
>
> [ERROR]   TestPutKuduT.testWriteKuduWithDefaults:70 Could not invoke
> methods annotated with @OnScheduled annotation due to:
> java.lang.reflect.InvocationTargetException
>
>
> *The test case is here :*
>
> @Test
> public void testWriteKuduWithDefaults() throws InitializationException {
>     final TestRunner runner = TestRunners.newTestRunner(PutKudu.class);
>     setUpTestRunner(runner);
>
>     final MockKuduClientService kuduClient = getKuduClientService(runner);
>     createRecordReader(100, runner);
>
>     final String filename = "testWriteKudu-" + System.currentTimeMillis();
>     final Map<String,String> flowFileAttributes = new HashMap<>();
>     flowFileAttributes.put(CoreAttributes.FILENAME.key(), filename);
>     runner.enqueue("trigger", flowFileAttributes);
>     runner.run();
>     runner.assertAllFlowFilesTransferred(PutKudu.REL_SUCCESS);
>     // verify the successful flow file has the expected content &
> attributes
>     final MockFlowFile mockFlowFile =
> runner.getFlowFilesForRelationship(PutKudu.REL_SUCCESS).get(0);
>     mockFlowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(),
> filename);
>     mockFlowFile.assertAttributeEquals(PutKudu.RECORD_COUNT_ATTR, "100");
>     mockFlowFile.assertContentEquals("trigger");
> }
>
> *and onSchedule meMethod is here:*
>
> @OnScheduled
>
> public void onScheduled(final ProcessContext context) throws
> IOException, LoginException {
>
>     final String tableName =
> context.getProperty(TABLE_NAME).evaluateAttributeExpressions().getValue();
>     operationType =
> OperationType.valueOf(context.getProperty(INSERT_OPERATION).getValue());
>     batchSize =
> context.getProperty(BATCH_SIZE).evaluateAttributeExpressions().asInteger();
>     ffbatch   =
>
> context.getProperty(FLOWFILE_BATCH_SIZE).evaluateAttributeExpressions().asInteger();
>     flushMode =
>
> SessionConfiguration.FlushMode.valueOf(context.getProperty(FLUSH_MODE).getValue());
>     getLogger().debug("Setting up Kudu connection...");
>     clientService =
>
> context.getProperty(KUDU_CLIENT_SERVICE).asControllerService(KuduClientService.class);
>     kuduTable = clientService.getKuduClient().openTable(tableName);
>     getLogger().debug("Kudu connection successfully initialized");
> }
>
> *Can someone one help me to bypass this issue? I tried all optiones
> dicussed here
>
> http://apache-nifi-developer-list.39713.n7.nabble.com/Error-handling-in-OnScheduled-td19446.html
> <
> http://apache-nifi-developer-list.39713.n7.nabble.com/Error-handling-in-OnScheduled-td19446.html
> >
> *
>

Reply via email to