@Test
public void Should_queryListOfExistFilesAndPollWatchServiceEvents()
        throws Exception {

    DirectoryStream directoryStreamMock = mock(DirectoryStream.class);
    Iterator directoryStreamIteratorMock = mock(Iterator.class);
    java.nio.file.Path[] filesMock = new java.nio.file.Path[] {
            mock(java.nio.file.Path.class),
            mock(java.nio.file.Path.class)
    };
    when(filesMock[0].toString()).thenReturn("dir/one");
    when(filesMock[1].toString()).thenReturn("dir/two");
    when(directoryStreamIteratorMock.hasNext()).thenReturn(true, true, false);
    when(directoryStreamIteratorMock.next()).thenReturn(filesMock[0], filesMock[1]);
    when(directoryStreamMock.iterator()).thenReturn(directoryStreamIteratorMock);
    when(fileSystemProviderMock.newDirectoryStream(any(), any())).thenReturn(directoryStreamMock);
    java.nio.file.Path newFileEventPathMock = mock(java.nio.file.Path.class);
    when(newFileEventPathMock.toString()).thenReturn("new");
    java.nio.file.Path newFileActualPathMock = mock(java.nio.file.Path.class);
    when(newFileActualPathMock.toString()).thenReturn("dir/new");
    when(directoryPathMock.resolve(newFileEventPathMock)).thenReturn(newFileActualPathMock);
    when(event1Mock.kind()).thenReturn((WatchEvent.Kind)StandardWatchEventKinds.ENTRY_CREATE);
    when(event1Mock.context()).thenReturn(newFileEventPathMock);
    when(event2Mock.kind()).thenReturn((WatchEvent.Kind)StandardWatchEventKinds.ENTRY_DELETE);
    when(watchKeyMock.pollEvents())
            .thenReturn(Arrays.asList(event1Mock, event2Mock))
            .thenReturn(Collections.emptyList());
    when(watchServiceMock.take()).thenReturn(watchKeyMock);
    when(watchKeyMock.reset()).thenReturn(true).thenReturn(false);
    ListenerTask task = new ListenerTask(directoryMock, actionMock, fileSystemMock);
    task.run();
    verify(actionMock, times(1)).execute(eq(new info.smart_tools.smartactors.base.path.Path("dir/one")));
    verify(actionMock, times(1)).execute(eq(new info.smart_tools.smartactors.base.path.Path("dir/two")));
    verify(actionMock, times(1)).execute(eq(new info.smart_tools.smartactors.base.path.Path("dir/new")));
    verify(actionMock, times(3)).execute(any());
}