-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
352 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
base/src/main/java/org/ndx/aadarchi/base/utils/commonsvfs/FileSystemOptionsConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.ndx.aadarchi.base.utils.commonsvfs; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.apache.commons.vfs2.FileSystemOptions; | ||
|
||
@FunctionalInterface | ||
public interface FileSystemOptionsConfigurer extends Consumer<FileSystemOptions>{ | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
base/src/main/java/org/ndx/aadarchi/base/utils/commonsvfs/FileSystemOptionsProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.ndx.aadarchi.base.utils.commonsvfs; | ||
|
||
import org.apache.commons.vfs2.FileSystemOptions; | ||
|
||
import jakarta.enterprise.inject.Instance; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
public class FileSystemOptionsProducer { | ||
|
||
@Inject Instance<FileSystemOptionsConfigurer> configurers; | ||
@Produces @Singleton FileSystemOptions createOptions(Instance<FileSystemOptions> updaters) { | ||
FileSystemOptions globalOptions = new FileSystemOptions(); | ||
configurers.stream() | ||
.forEach(configurer -> configurer.accept(globalOptions)); | ||
return globalOptions; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
github-scm-handler/src/main/java/org/ndx/aadarchi/github/vfs/GitHubRootProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.ndx.aadarchi.github.vfs; | ||
|
||
import org.apache.commons.vfs2.FileObject; | ||
import org.apache.commons.vfs2.FileSystemException; | ||
import org.apache.commons.vfs2.FileSystemManager; | ||
import org.apache.commons.vfs2.FileSystemOptions; | ||
import org.ndx.aadarchi.vfs.github.GitHubFileProvider; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
public class GitHubRootProvider { | ||
@Inject FileSystemManager fileSystemManager; | ||
@Inject FileSystemOptions options; | ||
public FileObject getProjectRoot(String project) throws FileSystemException { | ||
return fileSystemManager.resolveFile(GitHubFileProvider.urlFor(project), options); | ||
} | ||
} |
34 changes: 30 additions & 4 deletions
34
...b-scm-handler/src/test/java/org/ndx/aadarchi/github/vfs/GitHubFileSystemProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,57 @@ | ||
package org.ndx.aadarchi.github.vfs; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.apache.commons.vfs2.FileObject; | ||
import org.apache.commons.vfs2.FileSystemException; | ||
import org.apache.commons.vfs2.FileSystemManager; | ||
import org.apache.commons.vfs2.filter.RegexFileFilter; | ||
import org.assertj.core.api.Assertions; | ||
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.enhancers.ModelElementKeys; | ||
import org.ndx.aadarchi.base.utils.commonsvfs.FileObjectDetector; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.model.SoftwareSystem; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
@EnableWeld | ||
class GitHubFileSystemProviderTest { | ||
@WeldSetup | ||
public WeldInitiator weld = WeldInitiator.performDefaultDiscovery(); | ||
|
||
@Inject GitHubFileSystemProvider gitHubFileSystem; | ||
@Inject GitHubFileSystemOptionsConfigurer gitHubFileSystem; | ||
@Inject FileSystemManager fileSystemManager; | ||
@Inject GitHubRootProvider gitHubRootProvider; | ||
@Inject FileObjectDetector detector; | ||
|
||
@Test | ||
void test() throws FileSystemException { | ||
// Given | ||
FileObject repositoryRoot = gitHubFileSystem.getProjectRoot("Riduidel/aadarchi"); | ||
FileObject repositoryRoot = gitHubRootProvider.getProjectRoot("Riduidel/aadarchi"); | ||
// When | ||
FileObject readme = repositoryRoot.getChild("README.md"); | ||
// Then | ||
Assertions.assertThat((Object) readme).isNotNull(); | ||
Assertions.assertThat(readme.getContent().getSize()).isGreaterThan(100); | ||
} | ||
|
||
|
||
@Test | ||
void bug_432_is_resolved() throws FileSystemException { | ||
// Given | ||
var w = new Workspace(getClass().getName(), "a test workspace"); | ||
SoftwareSystem system = w.getModel().addSoftwareSystem("The system which has an associated file to read"); | ||
system.addProperty(ModelElementKeys.ConfigProperties.BasePath.NAME, "github://github.com/Riduidel/aadarchi"); | ||
// When | ||
detector.whenFileDetected(system, | ||
new RegexFileFilter("(readme|README)\\.(adoc|md)"), | ||
// Then | ||
elementRoot -> { Assertions.fail("We should detect one readme file"); }, | ||
(elementRoot, readme) -> Assertions.assertThat((Object) readme).isNotNull(), | ||
(elementRoot, files) -> Assertions.fail("We should detect one readme file")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
gitlab-scm-handler/src/main/java/org/ndx/aadarchi/gitlab/vfs/GitLabRootProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.ndx.aadarchi.gitlab.vfs; | ||
|
||
import org.apache.commons.vfs2.FileObject; | ||
import org.apache.commons.vfs2.FileSystemException; | ||
import org.apache.commons.vfs2.FileSystemManager; | ||
import org.apache.commons.vfs2.FileSystemOptions; | ||
import org.ndx.aadarchi.cdi.deltaspike.ConfigProperty; | ||
import org.ndx.aadarchi.gitlab.Constants; | ||
import org.ndx.aadarchi.vfs.gitlab.GitLabFileProvider; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
public class GitLabRootProvider { | ||
@Inject FileSystemManager fileSystemManager; | ||
@Inject FileSystemOptions fileSystemOptions; | ||
@Inject @ConfigProperty(name = Constants.CONFIG_GITLAB_URL, defaultValue = "gitlab.com") String gitlabUrl; | ||
|
||
public FileObject getProjectRoot(String project) throws FileSystemException { | ||
return fileSystemManager.resolveFile(GitLabFileProvider.urlFor(gitlabUrl, project), fileSystemOptions); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.