-
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 This happens because of this:
So even though I can print my file using Expected BehaviorThe test passes. Current BehaviorThe test doesn't pass. Possible SolutionSteps to Reproduce
This the test file content: package org.mypackage;
import org.gephi.graph.api.GraphController;
import org.gephi.graph.api.GraphModel;
import org.gephi.io.importer.api.Container;
import org.gephi.io.importer.api.ImportController;
import org.gephi.io.importer.plugin.file.spreadsheet.ImporterSpreadsheetCSV;
import org.gephi.io.processor.plugin.DefaultProcessor;
import org.gephi.project.api.ProjectController;
import org.gephi.project.api.Workspace;
import org.openide.filesystems.FileUtil;
import org.openide.util.Lookup;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.Scanner;
public class Test {
private final ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
private final ImportController importController = Lookup.getDefault().lookup(ImportController.class);
private final GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
private Workspace workspace;
private String testName = null;
@BeforeMethod
public void setup(Method method) {
testName = method.getName();
System.out.println("Starting test: " + testName);
projectController.newProject();
workspace = projectController.getCurrentWorkspace();
}
@AfterMethod
public void teardown() {
projectController.closeCurrentProject();
workspace = null;
}
@Test
public void testAdjacencyList() throws FileNotFoundException, IOException {
File file = FileUtil.archiveOrDirForURL(KatzCentralityTest.class.getResource("/org/mypackge/nodes.csv"));
ImporterSpreadsheetCSV importer = new ImporterSpreadsheetCSV();
importer.setFile(file); // <---- the error occurs here
Container container = importController.importFile(
file, importer
);
Assert.assertNotNull(container);
importController.process(container, new DefaultProcessor(), workspace);
GraphModel gm = graphController.getGraphModel(workspace);
boolean hasEdges = gm.getGraph().getEdges().iterator().hasNext();
Assert.assertEquals(hasEdges, false);
}
} ContextYour Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @yossisp and sorry for the delay. Please be aware that we've improved this capability since 0.9.3 version. First, we've migrated off TestNG and now use JUnit as this is the default in Netbeans Platform. Then, we've created some utility in You can take a look at the
|
Beta Was this translation helpful? Give feedback.
Hi @yossisp and sorry for the delay. Please be aware that we've improved this capability since 0.9.3 version. First, we've migrated off TestNG and now use JUnit as this is the default in Netbeans Platform. Then, we've created some utility in
ImportAPI
to make it easier importing graph files in other modules.You can take a look at the
StatisticsPlugin
module that takes advantage of that. In thepom.xml
one need to add this dependency and then you can use theGraphImporter
class.