I want to add tests which import csv files and then perform assertions on resulting graph. I wrote tests almost identical to the examples I found in ImportPlugin tests. However, I receive an exception when calling importer.setFile(file):
java.lang.NullPointerException at org.gephi.io.importer.api.ImportUtils.getTextReader(ImportUtils.java:92) at org.gephi.io.importer.plugin.file.spreadsheet.ImporterSpreadsheetCSV.autoDetectFieldDelimiter(ImporterSpreadsheetCSV.java:117) at org.gephi.io.importer.plugin.file.spreadsheet.ImporterSpreadsheetCSV.refreshAutoDetections(ImporterSpreadsheetCSV.java:100) at org.gephi.io.importer.plugin.file.spreadsheet.AbstractImporterSpreadsheet.setFile(AbstractImporterSpreadsheet.java:403) at org.openuniversityofisrael.katzcentrality.KatzCentralityTest.testAdjacencyList(KatzCentralityTest.java:55) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
This happens because of this:
setFile-> autoDetectFieldDelimiter-> FileUtil.toFileObject(this.file)->URLMapper.findFileObject(url)->mapper.getFileObjects(url)->FileObject f = find(url) and finally find returns null because of this line !"memory".equals(url.getProtocol()) which returns true and sets the file as null.
So even though I can print my file using Scanner netbeans filesystems API thinks the file protocol in memory instead of being file I guess (e.g. file:/home/pathToMyFile.csv). I can't figure out the problem perhaps @eduramiba can help because he write the ImportPlugin tests.
Expected Behavior
The test passes.
Current Behavior
The test doesn't pass.
Possible Solution
Steps to Reproduce
Create any package (module).
Create test directory: src/test/java/your/package.
I want to add tests which import csv files and then perform assertions on resulting graph. I wrote tests almost identical to the examples I found in ImportPlugin tests. However, I receive an exception when calling
importer.setFile(file)
:java.lang.NullPointerException at org.gephi.io.importer.api.ImportUtils.getTextReader(ImportUtils.java:92) at org.gephi.io.importer.plugin.file.spreadsheet.ImporterSpreadsheetCSV.autoDetectFieldDelimiter(ImporterSpreadsheetCSV.java:117) at org.gephi.io.importer.plugin.file.spreadsheet.ImporterSpreadsheetCSV.refreshAutoDetections(ImporterSpreadsheetCSV.java:100) at org.gephi.io.importer.plugin.file.spreadsheet.AbstractImporterSpreadsheet.setFile(AbstractImporterSpreadsheet.java:403) at org.openuniversityofisrael.katzcentrality.KatzCentralityTest.testAdjacencyList(KatzCentralityTest.java:55) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
This happens because of this:
setFile
->autoDetectFieldDelimiter
->FileUtil.toFileObject(this.file)
->URLMapper.findFileObject(url)
->mapper.getFileObjects(url)
->FileObject f = find(url)
and finallyfind
returnsnull
because of this line!"memory".equals(url.getProtocol())
which returns true and sets the file asnull
.So even though I can print my file using
Scanner
netbeans filesystems API thinks the file protocol inmemory
instead of beingfile
I guess (e.g.file:/home/pathToMyFile.csv
). I can't figure out the problem perhaps @eduramiba can help because he write theImportPlugin
tests.Expected Behavior
The test passes.
Current Behavior
The test doesn't pass.
Possible Solution
Steps to Reproduce
src/test/java/your/package
.src/test/resources/your/package
.test.csv
insrc/test/resources/your/package
.mvn test
.This the test file content:
Context
Your Environment