Skip to content

Commit

Permalink
Fixed NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlasov committed Aug 28, 2024
1 parent d20876f commit 36e713f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/test/java/org/nasdanika/launcher/tests/TestCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.icepear.echarts.components.series.SeriesLabel;
import org.icepear.echarts.render.Engine;
import org.jgrapht.alg.drawing.FRLayoutAlgorithm2D;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.nasdanika.common.Context;
import org.nasdanika.models.echarts.graph.Graph;
Expand Down Expand Up @@ -94,7 +93,6 @@ public class TestCommands {
* @throws IOException
*/
@Test
@Disabled // Fails in GitHub actions for some reason
public void testModuleGraph() throws IOException {
Module thisModule = getClass().getModule();
ModuleLayer moduleLayer = thisModule.getLayer();
Expand Down Expand Up @@ -158,15 +156,17 @@ private Node moduleToNode(
Item otherCategory) {
ModuleDescriptor moduleDescriptor = module.getDescriptor();
Node moduleNode = getModuleNode(module, layer, graph, nsdCategory, eclipseCategory, javaCategory, otherCategory);
for (Requires req: moduleDescriptor.requires()) {
Optional<Module> rmo = layer.findModule(req.name());
if (rmo.isPresent()) {
Node reqNode = moduleToNode(rmo.get(), layer, graph, nsdCategory, eclipseCategory, javaCategory, otherCategory);
org.nasdanika.models.echarts.graph.Link reqLink = GraphFactory.eINSTANCE.createLink();
reqLink.setTarget(reqNode);
moduleNode.getOutgoingLinks().add(reqLink);
if (moduleNode != null) {
for (Requires req: moduleDescriptor.requires()) {
Optional<Module> rmo = layer.findModule(req.name());
if (rmo.isPresent()) {
Node reqNode = moduleToNode(rmo.get(), layer, graph, nsdCategory, eclipseCategory, javaCategory, otherCategory);
org.nasdanika.models.echarts.graph.Link reqLink = GraphFactory.eINSTANCE.createLink();
reqLink.setTarget(reqNode);
moduleNode.getOutgoingLinks().add(reqLink);
}
}
}
}
return moduleNode;
}

Expand All @@ -178,13 +178,17 @@ private Node getModuleNode(
Item eclipseCategory,
Item javaCategory,
Item otherCategory) {
String moduleName = module.getName();
if (moduleName == null) {
return null;
}
for (Node n: graph.getNodes()) {
if (n.getName().equals(module.getName())) {
if (n.getName().equals(moduleName)) {
return n;
}
}
Node ret = GraphFactory.eINSTANCE.createNode();
ret.setName(module.getName());
ret.setName(moduleName);

if (ret.getName().startsWith("org.nasdanika.")) {
ret.setCategory(nsdCategory);
Expand Down

0 comments on commit 36e713f

Please sign in to comment.