Skip to content

Commit

Permalink
Fixes #435
Browse files Browse the repository at this point in the history
  • Loading branch information
Riduidel committed May 24, 2024
1 parent 5be8208 commit 957b42e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public <Returned> Optional<Returned> whenFileDetected(Element element,
FileSelector filter = new FileFilterSelector(fileFilter);
try {
FileObject[] found = elementRoot.findFiles(filter);
if (found.length == 0) {
if (found==null || found.length == 0) {
return onNoFileDetected.apply(elementRoot);
} else if (found.length > 1) {
return onMultipleFileDetected.apply(elementRoot, found);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.ndx.aadarchi.inferer.maven;

import java.util.Arrays;

import jakarta.inject.Inject;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.jboss.weld.junit5.EnableWeld;
import org.jboss.weld.junit5.WeldInitiator;
import org.jboss.weld.junit5.WeldSetup;
import org.junit.jupiter.api.Test;
import org.ndx.aadarchi.base.ArchitectureEnhancer;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys.ConfigProperties.BasePath;
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty;

import com.structurizr.Workspace;
import com.structurizr.model.Container;
import com.structurizr.model.SoftwareSystem;

@EnableWeld
public class TestFor435 {
@WeldSetup
public WeldInitiator weld = WeldInitiator.performDefaultDiscovery();

@Inject MavenDetailsInfererEnhancer tested;
@Inject ArchitectureEnhancer enhancer;

@Inject @ConfigProperty(name=BasePath.NAME, defaultValue = BasePath.VALUE) FileObject basePath;

@Test public void not_finding_file_doesnt_throw_NullPoinerException() throws FileSystemException {
// Given
var w = new Workspace(getClass().getName(), "a test workspace");
SoftwareSystem system = w.getModel().addSoftwareSystem("The system to decorate with maven informations");
system.addProperty(ModelElementKeys.ConfigProperties.BasePath.NAME,
basePath.getName().getPath()+"/a/folder/which/doesnt/exists");
// When
// We emulate in-depth visit (but do not really perform it)
enhancer.enhance(w, tested);
// Then
Assertions.assertThat(system.getContainers())
.describedAs("No container should be found, since path in which we search the maven pom doesn't exists")
.isEmpty()
;
}
}

0 comments on commit 957b42e

Please sign in to comment.