exceptionfactory commented on code in PR #6192: URL: https://github.com/apache/nifi/pull/6192#discussion_r923430649
########## nifi-nar-bundles/nifi-smb-bundle/nifi-smb-client-provider-api/pom.xml: ########## @@ -0,0 +1,48 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-bundle</artifactId> + <version>1.17.0-SNAPSHOT</version> + </parent> + <artifactId>nifi-smb-client-provider-api</artifactId> + <packaging>jar</packaging> + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</artifactId> + <version>1.17.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-listed-entity</artifactId> + <version>1.17.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record</artifactId> + </dependency> + <dependency> + <groupId>com.hierynomus</groupId> + <artifactId>smbj</artifactId> + </dependency> Review Comment: This dependency should be removed from this `api` module. ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smb-client-provider-api/src/main/java/org/apache/nifi/services/smb/NiFiSmbClient.java: ########## @@ -0,0 +1,15 @@ +package org.apache.nifi.services.smb; + +import java.io.OutputStream; +import java.util.stream.Stream; + +public interface NiFiSmbClient { + + Stream<SmbListableEntity> listRemoteFiles(String path); + + void createDirectory(String path); + + OutputStream getOutputStreamForFile(String pathAndFileName); Review Comment: Recommend adjusting this method name and parameter: ```suggestion OutputStream getFileOutputStream(String path); ``` ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smbj-client-provider/pom.xml: ########## @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-bundle</artifactId> + <version>1.17.0-SNAPSHOT</version> + </parent> + + <artifactId>nifi-smbj-client-provider</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-client-provider-api</artifactId> + <version>1.17.0-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-distributed-cache-client-service-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record</artifactId> + </dependency> + <!--dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record-serialization-service-api</artifactId> + </dependency--> Review Comment: This commented dependency should be removed. ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smbj-client-provider/pom.xml: ########## @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-bundle</artifactId> + <version>1.17.0-SNAPSHOT</version> + </parent> + + <artifactId>nifi-smbj-client-provider</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-client-provider-api</artifactId> + <version>1.17.0-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-distributed-cache-client-service-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record</artifactId> + </dependency> + <!--dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record-serialization-service-api</artifactId> + </dependency--> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-utils</artifactId> + </dependency> + <dependency> + <groupId>com.hierynomus</groupId> + <artifactId>smbj</artifactId> + </dependency> + <!--dependency> + <groupId>net.engio</groupId> + <artifactId>mbassador</artifactId> + </dependency--> Review Comment: This commented dependency should be removed. ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smb-client-provider-api/src/main/java/org/apache/nifi/services/smb/NiFiSmbClient.java: ########## @@ -0,0 +1,15 @@ +package org.apache.nifi.services.smb; + +import java.io.OutputStream; +import java.util.stream.Stream; + +public interface NiFiSmbClient { Review Comment: Although the `NiFi` prefix helps to distinguish this interface from the SMBJ `SmbClient`, prefixing components with `NiFi` is not a great pattern because the package name already indicates NiFi association. What about naming this `SmbClientService`? ```suggestion public interface SmbClientService { ``` ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smb-client-provider-api/src/main/java/org/apache/nifi/services/smb/NiFiSmbClient.java: ########## @@ -0,0 +1,15 @@ +package org.apache.nifi.services.smb; + +import java.io.OutputStream; +import java.util.stream.Stream; + Review Comment: It would be helpful to produce a basic description of this interface, just a sentence or two should be sufficient. ```suggestion /** * Service abstraction for Server Message Block protocol operations */ ``` ########## nifi-assembly/pom.xml: ########## @@ -664,6 +664,18 @@ language governing permissions and limitations under the License. --> <version>1.17.0-SNAPSHOT</version> <type>nar</type> </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-connection-pool-api-nar</artifactId> Review Comment: This should be changed to `nifi-smb-client-provider-api-nar` ########## nifi-assembly/pom.xml: ########## @@ -664,6 +664,18 @@ language governing permissions and limitations under the License. --> <version>1.17.0-SNAPSHOT</version> <type>nar</type> </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-connection-pool-api-nar</artifactId> + <version>1.17.0-SNAPSHOT</version> + <type>nar</type> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-connection-pool-nar</artifactId> Review Comment: This should be changed to `nifi-smb-client-provider-nar` ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smb-processors/pom.xml: ########## @@ -26,23 +26,62 @@ <packaging>jar</packaging> <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-client-provider-api</artifactId> + <version>1.17.0-SNAPSHOT</version> + <scope>provided</scope> + </dependency> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-api</artifactId> </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-distributed-cache-client-service-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record-serialization-service-api</artifactId> + </dependency> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-utils</artifactId> - <version>1.17.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.hierynomus</groupId> <artifactId>smbj</artifactId> - <version>0.10.0</version> + </dependency> + <dependency> + <groupId>net.engio</groupId> + <artifactId>mbassador</artifactId> + </dependency> Review Comment: This dependency appears unnecessary. ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smb-client-provider-api/pom.xml: ########## @@ -0,0 +1,48 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-bundle</artifactId> + <version>1.17.0-SNAPSHOT</version> + </parent> + <artifactId>nifi-smb-client-provider-api</artifactId> + <packaging>jar</packaging> + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</artifactId> + <version>1.17.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-listed-entity</artifactId> + <version>1.17.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record</artifactId> + </dependency> + <dependency> + <groupId>com.hierynomus</groupId> + <artifactId>smbj</artifactId> + </dependency> + <!--dependency> + <groupId>net.engio</groupId> + <artifactId>mbassador</artifactId> + </dependency--> Review Comment: Commented dependency should be removed ```suggestion ``` ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smbj-client-provider/pom.xml: ########## @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-bundle</artifactId> + <version>1.17.0-SNAPSHOT</version> + </parent> + + <artifactId>nifi-smbj-client-provider</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-client-provider-api</artifactId> + <version>1.17.0-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-distributed-cache-client-service-api</artifactId> + </dependency> Review Comment: This dependency does not appear to be used. ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smbj-client-provider/src/main/java/org/apache/nifi/services/smb/NiFiSmbjClient.java: ########## @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.services.smb; + +import static java.util.Arrays.asList; +import static java.util.stream.StreamSupport.stream; + +import com.hierynomus.msdtyp.AccessMask; +import com.hierynomus.msfscc.FileAttributes; +import com.hierynomus.msfscc.fileinformation.FileIdBothDirectoryInformation; +import com.hierynomus.mssmb2.SMB2CreateDisposition; +import com.hierynomus.mssmb2.SMB2CreateOptions; +import com.hierynomus.mssmb2.SMB2ShareAccess; +import com.hierynomus.mssmb2.SMBApiException; +import com.hierynomus.smbj.session.Session; +import com.hierynomus.smbj.share.Directory; +import com.hierynomus.smbj.share.DiskShare; +import com.hierynomus.smbj.share.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UncheckedIOException; +import java.util.EnumSet; +import java.util.List; +import java.util.stream.Stream; +import org.apache.nifi.services.smb.NiFiSmbClient; +import org.apache.nifi.services.smb.SmbListableEntity; + +public class NiFiSmbjClient implements NiFiSmbClient { Review Comment: Following the naming recommend to avoid prefixing with `NiFi`, recommend naming this class `SmbjSmbClientService` or `StandardSmbClientService`. ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smb-processors/pom.xml: ########## @@ -26,23 +26,62 @@ <packaging>jar</packaging> <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-client-provider-api</artifactId> + <version>1.17.0-SNAPSHOT</version> + <scope>provided</scope> + </dependency> <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-api</artifactId> </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-distributed-cache-client-service-api</artifactId> + </dependency> Review Comment: This dependency appears to be unnecessary. ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smbj-client-provider/pom.xml: ########## @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-bundle</artifactId> + <version>1.17.0-SNAPSHOT</version> + </parent> + + <artifactId>nifi-smbj-client-provider</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-smb-client-provider-api</artifactId> + <version>1.17.0-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-distributed-cache-client-service-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record</artifactId> + </dependency> + <!--dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record-serialization-service-api</artifactId> + </dependency--> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-utils</artifactId> + </dependency> + <dependency> + <groupId>com.hierynomus</groupId> + <artifactId>smbj</artifactId> + </dependency> + <!--dependency> + <groupId>net.engio</groupId> + <artifactId>mbassador</artifactId> + </dependency--> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <!--dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency--> Review Comment: This commented dependency should be removed. ########## nifi-nar-bundles/nifi-smb-bundle/nifi-smb-processors/src/test/java/org/apache/nifi/processors/smb/ListSmbTest.java: ########## @@ -0,0 +1,295 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.smb; + +import static java.util.Arrays.stream; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.NANOSECONDS; +import static org.apache.nifi.processor.util.list.AbstractListProcessor.LISTING_STRATEGY; +import static org.apache.nifi.processor.util.list.AbstractListProcessor.REL_SUCCESS; +import static org.apache.nifi.processor.util.list.AbstractListProcessor.TARGET_SYSTEM_TIMESTAMP_PRECISION; +import static org.apache.nifi.processor.util.list.ListedEntityTracker.TRACKING_STATE_CACHE; +import static org.apache.nifi.processors.smb.ListSmb.DIRECTORY; +import static org.apache.nifi.processors.smb.ListSmb.MINIMUM_AGE; +import static org.apache.nifi.processors.smb.ListSmb.SKIP_FILES_WITH_SUFFIX; +import static org.apache.nifi.processors.smb.ListSmb.SMB_CONNECTION_POOL_SERVICE; +import static org.apache.nifi.util.TestRunners.newTestRunner; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.net.URI; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicLong; +import org.apache.nifi.distributed.cache.client.DistributedMapCacheClient; +import org.apache.nifi.processor.util.list.ListedEntity; +import org.apache.nifi.services.smb.NiFiSmbClient; +import org.apache.nifi.services.smb.SmbListableEntity; +import org.apache.nifi.services.smb.SmbClientProviderService; +import org.apache.nifi.util.TestRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class ListSmbTest { + + private final static AtomicLong currentMillis = new AtomicLong(); + private final static AtomicLong currentNanos = new AtomicLong(); + + private static long currentMillis() { + return currentMillis.get(); + } + + private static long currentNanos() { + return currentNanos.get(); + } + + private static void setTime(Long timeInMillis) { + currentMillis.set(timeInMillis); + currentNanos.set(NANOSECONDS.convert(timeInMillis, MILLISECONDS)); + } + + private static void timePassed(Long timeInMillis) { + currentMillis.addAndGet(timeInMillis); + currentNanos.addAndGet(NANOSECONDS.convert(timeInMillis, MILLISECONDS)); + } + + @Test + public void shouldResetStateWhenPropertiesChanged() throws Exception { + final TestRunner testRunner = newTestRunner(ListSmb.class); + testRunner.setProperty(LISTING_STRATEGY, "timestamps"); + testRunner.setProperty(TARGET_SYSTEM_TIMESTAMP_PRECISION, "millis"); + testRunner.setProperty(MINIMUM_AGE, "0 ms"); + final NiFiSmbClient mockNifiSmbClient = configureTestRunnerWithMockedSambaClient(testRunner); + long now = System.currentTimeMillis(); + mockSmbFolders(mockNifiSmbClient, listableEntity("should_list_it_after_each_reset", now - 100)); + testRunner.run(); + testRunner.assertTransferCount(REL_SUCCESS, 1); + testRunner.setProperty(DIRECTORY, "testDirectoryChanged"); + testRunner.run(); + testRunner.assertTransferCount(REL_SUCCESS, 2); + + testRunner.setProperty(SKIP_FILES_WITH_SUFFIX, "suffix_changed"); + testRunner.run(); + testRunner.assertTransferCount(REL_SUCCESS, 3); + + final SmbClientProviderService connectionPoolService = mock(SmbClientProviderService.class); + when(connectionPoolService.getIdentifier()).thenReturn("connection-pool-2"); + when(connectionPoolService.getServiceLocation()).thenReturn(URI.create("smb://localhost:445/share")); + when(connectionPoolService.getClient()).thenReturn(mockNifiSmbClient); +// final NiFiSmbClientFactory mockSmbClientFactory = mock(NiFiSmbClientFactory.class); +// ((ListSmb) testRunner.getProcessor()).smbClientFactory = mockSmbClientFactory; +// when(mockSmbClientFactory.create(any(), any())).thenReturn(mockNifiSmbClient); Review Comment: These commented lines should be removed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
