Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSL4LibreOffice - D [GSoC '24] #11636

Merged
merged 39 commits into from
Aug 24, 2024
Merged

CSL4LibreOffice - D [GSoC '24] #11636

merged 39 commits into from
Aug 24, 2024

Conversation

subhramit
Copy link
Member

@subhramit subhramit commented Aug 16, 2024

Test suite, refactoring and documentation for OO-CSL components

[PR - D of the GSoC '24 CSL4LibreOffice Project]
Follow-up to #11477, #11521, #11577 and #11604

  • Miscellaneous refactoring (majorly shifting of utility functions to a new class - CSLFormatUtils).
  • Documentation for all methods created as a part the project.
  • Tests for all the utility formatting methods, and a few extras (e.g. StAX parser for title and isNumericStyle implemented during the project).

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@subhramit subhramit added type: documentation openoffice/libreoffice type: code-quality Issues related to code or architecture decisions project: GSoC tests Related to tests labels Aug 16, 2024
@subhramit subhramit added this to the 6.0-alpha milestone Aug 16, 2024
@subhramit subhramit requested a review from Siedlerchr August 16, 2024 16:10
@@ -58,6 +57,22 @@ void aPACitation() {
assertEquals(expected, citation);
}

/**
Copy link
Member

Choose a reason for hiding this comment

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

just mark the test @disabled

Copy link
Member

Choose a reason for hiding this comment

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

The comment is IMHO helpful. For someone diving into it 1 year later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Marked disabled and kept the comment.

@subhramit
Copy link
Member Author

@Siedlerchr @koppor @ThiloteE Review changes are done.

@subhramit
Copy link
Member Author

subhramit commented Aug 20, 2024

Also manually adapted as per upcoming best practices enforcement: #11643.
(PR can be merged independently).

@subhramit subhramit requested review from Siedlerchr and koppor August 20, 2024 09:29
Comment on lines 75 to 77
String expected = "[Smit2016]";

assertEquals(expected, inTextCitationText);
Copy link
Member

Choose a reason for hiding this comment

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

One-liners can be inlined

Suggested change
String expected = "[Smit2016]";
assertEquals(expected, inTextCitationText);
assertEquals("[Smit2016]", inTextCitationText);

List<CitationStyle> styleList = CitationStyle.discoverCitationStyles();
assertNotNull(styleList);
}

@ParameterizedTest
@MethodSource("citationStyleProvider")
Copy link
Member

Choose a reason for hiding this comment

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

Typically, name the providing method the same as the testing method

    @MethodSource

However, in your case, you are providing one source for multiple tests.

Please split up your test case in three:

Name the methods as follows:

  • citationStylePresent
  • titleMatches
  • numericPropertyMatches

Do NOT use explanations for assertEquals. All of your text can be read out of the code.

Maybe, you are searching for the name parameter of @ParamterizedTest (https://stackoverflow.com/a/57894201/873282)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, you are searching for the name parameter of @ParamterizedTest (https://stackoverflow.com/a/57894201/873282)?

This was an interesting read. Right now, we don't need it but can come in handy sometime.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated: used same name for provider and test method uniformly throughout PR.

/**
* Test to check transformation of raw, unsupported HTML into OO-ready HTML.
*
* @param input the raw HTML.
Copy link
Member

Choose a reason for hiding this comment

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

Rename parameter input to rawHtml and remove comment. Thus, the parameter name is self-explanatory.

static Stream<Arguments> rawHTMLProvider() {
return Stream.of(

// First three are general test cases for unescaping HTML entities
Copy link
Member

Choose a reason for hiding this comment

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

Use // region: ... and then // endregion. Reason: Someone might add new test cases and might not update the commet.

* <b>Precondition:</b> This test assumes that {@link CitationStyleGenerator#generateCitation(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateCitation} works as expected.
* </p>
*
* @param style the CSL style to test transformation on.
Copy link
Member

Choose a reason for hiding this comment

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

Can be removed

*/
@ParameterizedTest
@MethodSource("rawBibliographyProvider")
void ooHTMLTransformFromRawBibliography(CitationStyle style, String expected) {
Copy link
Member

Choose a reason for hiding this comment

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

To be in line with assertEquals, the expected parameter should be passed first.

Copy link
Member Author

Choose a reason for hiding this comment

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

So should this be flipped in every method (along with the provider arguments)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, changed uniformly on all methods and providers.

* <b>Precondition:</b> This test assumes that {@link CitationStyleGenerator#generateInText(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateInText} works as expected.
* </p>
*
* @param style the CSL style to test transformation on.
Copy link
Member

Choose a reason for hiding this comment

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

Remove

@subhramit
Copy link
Member Author

Updated as per latest review - 3962402

@subhramit subhramit requested a review from koppor August 21, 2024 09:46
@Siedlerchr
Copy link
Member

In general, you don't need extensive javadoc for test classes. Javadoc is more important for the classes under test that contain the real functionality

@subhramit subhramit mentioned this pull request Aug 22, 2024
6 tasks
Copy link
Contributor

github-actions bot commented Aug 22, 2024

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Scrolled through. Looks good. Since Chris seemed to check thoroughly, good to go.

@koppor koppor added this pull request to the merge queue Aug 24, 2024
Merged via the queue into main with commit f6ea6a9 Aug 24, 2024
21 checks passed
@koppor koppor deleted the csl-tests branch August 24, 2024 13:04
@subhramit subhramit added this to the 6.0-alpha milestone Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openoffice/libreoffice project: GSoC tests Related to tests type: code-quality Issues related to code or architecture decisions type: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants