I am pretty much new to apache nifi. Couple of days back I stuck at this problem (which involves miss behaving custom nifi processor). Debugging wasnt helping me well. So I decided to explore nifi mock framework (which I should be doing already, but didnt do it :) as suggested in comments on that question.
I am taking help from these links: 1 , 2
What I was trying to do is to send single flow file to custom processor. For that I saved/serialized actual flow file using MergeContent (with FlowFile v3 version) and PutFile processor as suggested here . Now I am trying to re-read this file through code in my test using GetFile processor as follows:
import static org.junit.Assert.*;
import java.util.List;
import org.junit.Test;
import org.apache.nifi.util.TestRunners;
import org.apache.nifi.processors.standard.GetFile;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
public class MyCustomProcessorTest {
@Test
public void testOnTrigger() {
TestRunner runner = TestRunners.newTestRunner(new GetFile());
runner.setProperty(GetFile.DIRECTORY, "C:\\Mahesh\\delete\\serialized-flow-files");
runner.setProperty(GetFile.KEEP_SOURCE_FILE, "true");
runner.run(1);
List<MockFlowFile> results = runner.getFlowFilesForRelationship(GetFile.REL_SUCCESS);
System.out.println("done");
}
}
This is giving me following error:
Which maven dependency should I include to get this class? Also is my approach fine or there is any more preferable approach?
I would double-check if org.apache.nifi:nifi-api: is in the classpath.
If using maven I would run "mvn dependency:tree" to check.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.