Skip to content

NIFI-16053 Refactored Get/PutSmbFile to use SmbClientProviderService - #11542

Open
turcsanyip wants to merge 3 commits into
apache:mainfrom
turcsanyip:NIFI-16053
Open

NIFI-16053 Refactored Get/PutSmbFile to use SmbClientProviderService#11542
turcsanyip wants to merge 3 commits into
apache:mainfrom
turcsanyip:NIFI-16053

Conversation

@turcsanyip

Copy link
Copy Markdown
Contributor

Summary

NIFI-16053

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 contains commits signed with a registered key indicating Verified status

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 ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

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

Comment on lines 135 to 164
@Test
public void testNonRecurse() {
testRunner.setProperty(GetSmbFile.RECURSE, "false");
String subdir = DIRECTORY + "\\subdir1";
mockDir(DIRECTORY, List.of(
mockFile(DIRECTORY, "file1.txt", "abc"),
mockFile(DIRECTORY, "file2.txt", "abc"),
mockDir(subdir, List.of(mockFile(subdir, "file3.txt", "abc")))
));

mockListing(
fileEntity(DIRECTORY, "file1.txt"),
fileEntity(DIRECTORY, "file2.txt")
);
testRunner.run();
verifyOpenFile(DIRECTORY, "file1.txt", 1);
verifyOpenFile(DIRECTORY, "file2.txt", 1);
verifyOpenFile(subdir, "file3.txt", 0);
verifyReadFile(DIRECTORY, "file1.txt", 1);
verifyReadFile(DIRECTORY, "file2.txt", 1);
verifyReadFile(subdir, "file3.txt", 0);
testRunner.assertTransferCount(GetSmbFile.REL_SUCCESS, 2);
}

@Test
public void testRecurse() {
testRunner.setProperty(GetSmbFile.RECURSE, "true");
String subdir = DIRECTORY + "\\subdir1";
mockDir(DIRECTORY, List.of(
mockFile(DIRECTORY, "file1.txt", "abc"),
mockFile(DIRECTORY, "file2.txt", "abc"),
mockDir(subdir, List.of(mockFile(subdir, "file3.txt", "abc")))
)
mockListing(
fileEntity(DIRECTORY, "file1.txt"),
fileEntity(DIRECTORY, "file2.txt"),
fileEntity(subdir, "file3.txt")
);

testRunner.run();
verifyOpenFile(DIRECTORY, "file1.txt", 1);
verifyOpenFile(DIRECTORY, "file2.txt", 1);
verifyOpenFile(subdir, "file3.txt", 1);
verifyReadFile(DIRECTORY, "file1.txt", 1);
verifyReadFile(DIRECTORY, "file2.txt", 1);
verifyReadFile(subdir, "file3.txt", 1);
testRunner.assertTransferCount(GetSmbFile.REL_SUCCESS, 3);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These tests don't really test the corresponding behaviour after the refactor.
I suggest something like this instead:

@ParameterizedTest
@ValueSource(booleans = {true, false})
public void testRecursePropertyForwardedToListFiles(final boolean recurse) {
    testRunner.setProperty(GetSmbFile.RECURSE, Boolean.toString(recurse));
    mockListing(
            fileEntity(DIRECTORY, "file1.txt"),
            fileEntity(DIRECTORY, "file2.txt")
    );
    testRunner.run();
    verify(clientService).listFiles(anyString(), eq(recurse));
    verifyReadFile(DIRECTORY, "file1.txt", 1);
    verifyReadFile(DIRECTORY, "file2.txt", 1);
    testRunner.assertTransferCount(GetSmbFile.REL_SUCCESS, 2);
}

Comment on lines 61 to 64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ensureDirectory doesn't check share.fileExists but share. folderExists instead

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.

2 participants