Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ public boolean supportsFile(final InputFile file)

private List<ImporterFactory> getMatchingFactories(final InputFile file)
{
return this.serviceLoader.load()
final List<ImporterFactory> allFactories = this.serviceLoader.load().toList();
if (allFactories.isEmpty())
{
LOG.warning("No importers discovered. If you are running OpenFastTrace as a library, "
+ "ensure that the thread context classloader has access to the importer implementations.");
}
return allFactories.stream()
.filter(f -> f.supportsFile(file))
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.itsallcode.openfasttrace.core.importer;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.same;
Expand All @@ -10,7 +11,7 @@
import java.nio.file.Paths;
import java.util.Arrays;

import org.itsallcode.openfasttrace.api.importer.ImporterContext;

Check warning on line 14 in core/src/test/java/org/itsallcode/openfasttrace/core/importer/TestImporterFactoryLoader.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'org.itsallcode.openfasttrace.api.importer.ImporterContext'.

See more on https://sonarcloud.io/project/issues?id=org.itsallcode.openfasttrace%3Aopenfasttrace-root&issues=AZ51OrTcaV4rjTNzSlcS&open=AZ51OrTcaV4rjTNzSlcS&pullRequest=529
import org.itsallcode.openfasttrace.api.importer.ImporterFactory;
import org.itsallcode.openfasttrace.api.importer.input.InputFile;
import org.itsallcode.openfasttrace.api.importer.input.RealFileInput;
Expand All @@ -35,8 +36,6 @@
private ImporterFactory supportedFactory2;
@Mock
private ImporterFactory unsupportedFactory;
@Mock
private ImporterContext contextMock;

private ImporterFactoryLoader loader;
private InputFile file;
Expand All @@ -59,6 +58,13 @@
assertTrue(this.loader.getImporterFactory(this.file).isEmpty());
}

@Test
void testSupportsFileWhenNoFactoryRegisteredReturnsFalse()
{
simulateFactories();
assertThat(this.loader.supportsFile(this.file), is(false));
}

@Test
void testMatchingFactoryFoundOnlyOneAvailable()
{
Expand Down
2 changes: 2 additions & 0 deletions doc/changes/changes_4.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ We also refactored the tests around the CLI starter to improve readability and m

We added FXML to the list of supported file formats for the tag importer.

When no importer factory is found for a given file format, the importer factory loader will now log a warning that explains the likely cause. This is helpful in case OFT is used as a library with a custom classloader and thus does not have the right context.

## Features

* #503: Added `-h` / `--help` to the command line.
Loading