Skip to content

Handling of files for which no importer (or too many) is present does not fail with an exception#258

Merged
kaklakariada merged 4 commits into
itsallcode:developfrom
poldi2015:feature/257-only_import_support_files_from_zip_files
May 24, 2021
Merged

Handling of files for which no importer (or too many) is present does not fail with an exception#258
kaklakariada merged 4 commits into
itsallcode:developfrom
poldi2015:feature/257-only_import_support_files_from_zip_files

Conversation

@poldi2015

@poldi2015 poldi2015 commented Apr 16, 2021

Copy link
Copy Markdown
Contributor
  • Implement files for ZIP File Importer
  • Improve ZIP File importer
  • Implement tests

@codecov

codecov Bot commented Apr 16, 2021

Copy link
Copy Markdown

Codecov Report

Merging #258 (f4b6c6a) into develop (3f2af36) will decrease coverage by 0.03%.
The diff coverage is 86.66%.

❗ Current head f4b6c6a differs from pull request most recent head f116915. Consider uploading reports for the commit f116915 to get more accurate results
Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #258      +/-   ##
=============================================
- Coverage      87.29%   87.25%   -0.04%     
  Complexity      1034     1034              
=============================================
  Files            120      120              
  Lines           3187     3193       +6     
  Branches         249      250       +1     
=============================================
+ Hits            2782     2786       +4     
  Misses           335      335              
- Partials          70       72       +2     
Impacted Files Coverage Δ Complexity Δ
...de/openfasttrace/importer/zip/ZipFileImporter.java 44.44% <ø> (ø) 3.00 <0.00> (ø)
...fasttrace/core/importer/MultiFileImporterImpl.java 91.48% <80.00%> (-3.86%) 19.00 <4.00> (ø)
...fasttrace/core/importer/ImporterFactoryLoader.java 94.11% <100.00%> (+0.78%) 9.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f2af36...f116915. Read the comment docs.

…le to deal with any type of file. If no importer is present than nothing is imported (silently, with a LOG.info message in ImporterFactoryLoader). No special handling in ZipFileImporter necesssary anymore.
@poldi2015 poldi2015 changed the title WIP: Changed ZipFileImporter to only read files for which an importer is a… Changed ZipFileImporter to only read files for which an importer is a… Apr 17, 2021
@poldi2015 poldi2015 changed the title Changed ZipFileImporter to only read files for which an importer is a… Handling of files for which no importer (or too many) is present does not fail with an exception Apr 17, 2021
…into feature/257-only_import_support_files_from_zip_files
@kaklakariada

kaklakariada commented Apr 18, 2021

Copy link
Copy Markdown
Contributor

Bitte noch bei Bedarf Requirements und Design aktualisieren :)

@kaklakariada kaklakariada requested a review from redcatbear April 18, 2021 15:17
@kaklakariada

Copy link
Copy Markdown
Contributor

Build for PR from fork failed because of missing SONAR_TOKEN. We still can merge this.
@redcatbear Please also review.

@poldi2015

Copy link
Copy Markdown
Contributor Author

Can we merge this pull request to develop or is something still open? Should @redcatbear also do a review?

@kaklakariada

Copy link
Copy Markdown
Contributor

Yes, he should also review.

Comment on lines +25 to +26


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

* when no or more than one {@link ImporterFactory} is found.
*/
public ImporterFactory getImporterFactory(final InputFile file)
public Optional<ImporterFactory> getImporterFactory(final InputFile file)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split into check method and getter method instead of using Optional. Use getter only if check comes back green.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would mean that the ImporterFactory needs to be searched twice: once by the check method to figure out that there is a fitting ImporterFactory and second by the get method. Th search calls ImporterFactory.supportsFile() on each factory when then figures out by examine the given file if it can load the file.

What is the problem with Optional. As Java has no Either construct, isn't Optional not the Java approach for such a construct?

Comment on lines +142 to +144
LOG.fine(() -> ( importer.isPresent() ?
"Created importer of type '" + importer.getClass().getSimpleName() :
"No import" )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG.fine(() -> ( importer.isPresent() ?
"Created importer of type '" + importer.getClass().getSimpleName() :
"No import" )
LOG.fine(() -> (importer.isPresent() ?
"Created importer of type '" + importer.getClass().getSimpleName() :
"No import")

Please use auto-formatting. that should also make sure that all spaces are uniform.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

@redcatbear

Copy link
Copy Markdown
Collaborator

Build failing.

@kaklakariada

Copy link
Copy Markdown
Contributor

Build fails during sonar analysis with message Caused by: org.sonar.api.utils.MessageException: You're not authorized to run analysis. Please contact the project administrator.

Root cause is, that pr from forks don't have access to the sonar token. I fixed this issue on develop by skipping sonar in this case.

I will merge the pr as is. We can fix potential sonar findings later.

@kaklakariada kaklakariada merged commit 1104526 into itsallcode:develop May 24, 2021
poldi2015 pushed a commit that referenced this pull request Jul 11, 2021
…t_files_from_zip_files

Handling of files for which no importer (or too many) is present does not fail with an exception
poldi2015 pushed a commit that referenced this pull request Jul 11, 2021
…t_files_from_zip_files

Handling of files for which no importer (or too many) is present does not fail with an exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants