Skip to content

NIFI-10153 Refactor DocGeneratorTest and remove binary test files#6146

Closed
exceptionfactory wants to merge 1 commit intoapache:mainfrom
exceptionfactory:NIFI-10153
Closed

NIFI-10153 Refactor DocGeneratorTest and remove binary test files#6146
exceptionfactory wants to merge 1 commit intoapache:mainfrom
exceptionfactory:NIFI-10153

Conversation

@exceptionfactory
Copy link
Contributor

Summary

NIFI-10153 Refactors the DocGeneratorTest in nifi-documentation and to eliminate the need for binary NAR files in the project repository. The refactored implementation mocks the ExtensionManager and returns component and bundle information to support HTML documentation generation.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 8
    • JDK 11
    • JDK 17

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

Copy link
Contributor

@bejancsaba bejancsaba left a comment

Choose a reason for hiding this comment

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

+1 from me, thanks for the cleanup! I had two minor comments but that shouldn't block merging, will leave it up to you

doReturn(PROCESSOR_CLASS).when(extensionManager).getClass(eq(definition));

final Processor processor = new ProcessorWithLogger();
when(extensionManager.getTempComponent(eq(PROCESSOR_CLASS.getName()), eq(bundleCoordinate))).thenReturn(processor);
Copy link
Contributor

Choose a reason for hiding this comment

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

As you don't really need the processor you could just simply do Mockito.mock(ProcessorWithLogger.class) at return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the documentation generation uses the instantiated component during HTML generation.

assertFalse(files.isEmpty());

final File file = files.iterator().next();
final byte[] bytes = Files.readAllBytes(file.toPath());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use Files.readString? It is basically the same you can save a few lines :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like Files.readString was introduced in Java 11, so this seems to be the best approach for now.

@exceptionfactory
Copy link
Contributor Author

Thanks for the review @bejancsaba!

Copy link
Contributor

@kevdoran kevdoran left a comment

Choose a reason for hiding this comment

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

+1 from me. Thanks @exceptionfactory - if you can address the merge conflicts, I'll be happy to merge this

@exceptionfactory
Copy link
Contributor Author

Thanks @kevdoran, rebased.

@kevdoran kevdoran closed this in c1c1d0d Jun 28, 2022
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