You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2021/01/31 19:03:28 UTC

[directory-studio] branch master updated: DIRSTUDIO-745: Fix quick search corner cases

This is an automated email from the ASF dual-hosted git repository.

seelmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-studio.git


The following commit(s) were added to refs/heads/master by this push:
     new 12bf5bc  DIRSTUDIO-745: Fix quick search corner cases
12bf5bc is described below

commit 12bf5bcd6f0a2822d1ea760d362d6a6c5d0aa50b
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Sun Jan 31 20:03:11 2021 +0100

    DIRSTUDIO-745: Fix quick search corner cases
---
 .../widgets/browser/BrowserContentProvider.java    | 40 +++++++++---------
 .../studio/test/integration/ui/SearchTest.java     | 47 +++++++++++++++++++++-
 .../test/integration/ui/bots/BrowserViewBot.java   |  3 +-
 3 files changed, 70 insertions(+), 20 deletions(-)

diff --git a/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java b/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
index b58e780..b4d9573 100644
--- a/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
+++ b/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
@@ -349,7 +349,6 @@ public class BrowserContentProvider implements ITreeContentProvider
         else if ( parent instanceof IEntry )
         {
             final IEntry parentEntry = ( IEntry ) parent;
-            IQuickSearch quickSearch = parentEntry.getBrowserConnection().getQuickSearch();
 
             if ( parentEntry instanceof IContinuation )
             {
@@ -364,6 +363,14 @@ public class BrowserContentProvider implements ITreeContentProvider
                 }
             }
 
+            List<Object> objects = new ArrayList<Object>();
+
+            IQuickSearch quickSearch = getQuickSearchForEntry( parentEntry );
+            if ( quickSearch != null )
+            {
+                objects.add( quickSearch );
+            }
+
             if ( !parentEntry.isChildrenInitialized() )
             {
                 new StudioBrowserJob( new InitializeChildrenRunnable( false, parentEntry ) ).execute();
@@ -379,14 +386,6 @@ public class BrowserContentProvider implements ITreeContentProvider
 
                 IEntry[] results = parentEntry.getChildren();
 
-                List<Object> objects = new ArrayList<Object>();
-
-                if ( quickSearch != null
-                    && parentEntry.getDn().equals( quickSearch.getSearchBase() ) )
-                {
-                    objects.add( quickSearch );
-                }
-
                 if ( parentEntry.getTopPageChildrenRunnable() != null )
                 {
                     objects.add( parentEntry.getTopPageChildrenRunnable() );
@@ -405,14 +404,6 @@ public class BrowserContentProvider implements ITreeContentProvider
             {
                 BrowserEntryPage[] entryPages = getEntryPages( parentEntry );
 
-                List<Object> objects = new ArrayList<Object>();
-
-                if ( quickSearch != null
-                    && parentEntry.getDn().equals( quickSearch.getSearchBase() ) )
-                {
-                    objects.add( quickSearch );
-                }
-
                 objects.addAll( Arrays.asList( entryPages ) );
 
                 return objects.toArray();
@@ -552,7 +543,7 @@ public class BrowserContentProvider implements ITreeContentProvider
         if ( parent instanceof IEntry )
         {
             IEntry parentEntry = ( IEntry ) parent;
-            return parentEntry.hasChildren();
+            return parentEntry.hasChildren() || getQuickSearchForEntry( parentEntry ) != null;
         }
         else if ( parent instanceof SearchContinuation )
         {
@@ -585,6 +576,19 @@ public class BrowserContentProvider implements ITreeContentProvider
     }
 
 
+    private IQuickSearch getQuickSearchForEntry( IEntry parentEntry )
+    {
+        IQuickSearch quickSearch = parentEntry.getBrowserConnection().getQuickSearch();
+        if ( quickSearch != null
+            && parentEntry.getDn().equals( quickSearch.getSearchBase() ) )
+        {
+            return quickSearch;
+        }
+
+        return null;
+    }
+
+
     private BrowserEntryPage[] getEntryPages( final IEntry parentEntry )
     {
         BrowserEntryPage[] entryPages;
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
index eb07d1c..68ff60f 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
@@ -73,7 +73,6 @@ public class SearchTest extends AbstractLdapTestUnit
     private Connection connection1;
     private Connection connection2;
 
-
     @Before
     public void setUp() throws Exception
     {
@@ -175,6 +174,52 @@ public class SearchTest extends AbstractLdapTestUnit
     }
 
 
+    @Test
+    public void testQuickSearch() throws Exception
+    {
+        // quick search on context entry
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system" );
+
+        browserViewBot.typeQuickSearchAttributeType( "ou" );
+        browserViewBot.typeQuickSearchValue( "*" );
+        browserViewBot.clickRunQuickSearchButton();
+
+        browserViewBot.waitForEntry( "DIT", "Root DSE", "ou=system", "Quick Search (5)" );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "Quick Search (5)" );
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "Quick Search (5)" );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "Quick Search (5)", "ou=users,ou=system" );
+
+        // quick search on non-leaf entry
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
+
+        browserViewBot.typeQuickSearchAttributeType( "uid" );
+        browserViewBot.typeQuickSearchValue( "user.1" );
+        browserViewBot.clickRunQuickSearchButton();
+
+        browserViewBot.waitForEntry( "DIT", "Root DSE", "ou=system", "ou=users", "Quick Search (1)" );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "Quick Search (1)" );
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users", "Quick Search (1)" );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "Quick Search (1)",
+            "uid=user.1,ou=users,ou=system" );
+
+        // quick search on leaf entry
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" );
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" );
+
+        browserViewBot.typeQuickSearchAttributeType( "uid" );
+        browserViewBot.typeQuickSearchValue( "user.1" );
+        browserViewBot.clickRunQuickSearchButton();
+
+        browserViewBot.waitForEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1", "Quick Search (0)" );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1", "Quick Search (0)" );
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1", "Quick Search (0)" );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1", "Quick Search (0)",
+            "No Results" );
+    }
+
+
     /**
      * Test for DIRSTUDIO-601.
      * (The 'Perform Search/Search Again' button in the Search Result Editor does not work correctly)
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
index e26dfea..194f92a 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
@@ -57,7 +57,8 @@ public class BrowserViewBot
 
     public void selectEntry( String... path )
     {
-        boolean wait = !"Quick Search".equals( path[path.length - 1] )
+        boolean wait = !path[path.length - 1].startsWith( "Quick Search" )
+            && !path[path.length - 1].equals( "No Results" )
             && !"Searches".equals( path[0] );
         browserBot.selectEntry( wait, path );
     }