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 2022/05/17 05:46:40 UTC

[directory-studio] branch DIRSTUDIO-1298-add-address-editor-ui-test created (now 0d66b0825)

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

seelmann pushed a change to branch DIRSTUDIO-1298-add-address-editor-ui-test
in repository https://gitbox.apache.org/repos/asf/directory-studio.git


      at 0d66b0825 DIRSTUDIO-1298: Add address editor UI test

This branch includes the following new commits:

     new 0d66b0825 DIRSTUDIO-1298: Add address editor UI test

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[directory-studio] 01/01: DIRSTUDIO-1298: Add address editor UI test

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seelmann pushed a commit to branch DIRSTUDIO-1298-add-address-editor-ui-test
in repository https://gitbox.apache.org/repos/asf/directory-studio.git

commit 0d66b0825c607c88e1c706ecbc2124af04dec868
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Tue May 17 07:44:32 2022 +0200

    DIRSTUDIO-1298: Add address editor UI test
---
 .../test/integration/ui/EntryEditorTest.java       | 71 ++++++++++++++++++++++
 .../ui/bots/AddressEditorDialogBot.java            | 47 ++++++++++++++
 .../test/integration/ui/bots/EntryEditorBot.java   |  6 ++
 .../integration/ui/bots/EntryEditorWidgetBot.java  |  7 +++
 .../integration/ui/bots/NewAttributeWizardBot.java |  7 +++
 5 files changed, 138 insertions(+)

diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
index 220dc2073..7c2b53ca7 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
@@ -54,6 +54,7 @@ import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
 import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
 import org.apache.directory.studio.test.integration.junit5.LdapServersSource.Mode;
 import org.apache.directory.studio.test.integration.ui.bots.AciItemEditorDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.AddressEditorDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.CertificateEditorDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.DnEditorDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.EditAttributeWizardBot;
@@ -567,6 +568,76 @@ public class EntryEditorTest extends AbstractTestBase
     }
 
 
+    /**
+     * DIRSTUDIO-1298: The RFC 4517 Postal Address value editor en-/decoding is incomplete
+     */
+    @ParameterizedTest
+    @LdapServersSource
+    public void testAddressValueEditor( TestLdapServer server ) throws Exception
+    {
+        connectionsViewBot.createTestConnection( server );
+        browserViewBot.selectEntry( path( BJENSEN_DN ) );
+
+        EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( BJENSEN_DN.getName() );
+        entryEditorBot.activate();
+        String dn = entryEditorBot.getDnText();
+        assertEquals( "DN: " + BJENSEN_DN.getName(), dn );
+        assertEquals( 8, entryEditorBot.getAttributeValues().size() );
+        assertEquals( "", modificationLogsViewBot.getModificationLogsText() );
+
+        // add postalAddress attribute and verify value is correctly encoded
+        entryEditorBot.activate();
+        NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
+        assertTrue( wizardBot.isVisible() );
+        wizardBot.typeAttributeType( "postalAddress" );
+        AddressEditorDialogBot addressEditorDialogBot = wizardBot.clickFinishButtonExpectingAddressEditor();
+        assertTrue( addressEditorDialogBot.isVisible() );
+        addressEditorDialogBot.setText( "1234 Main St.\nAnytown, CA 12345\nUSA" );
+        addressEditorDialogBot.clickOkButton();
+        assertEquals( 9, entryEditorBot.getAttributeValues().size() );
+        assertTrue(
+            entryEditorBot.getAttributeValues().contains( "postalAddress: 1234 Main St., Anytown, CA 12345, USA" ) );
+        modificationLogsViewBot.waitForText( "add: postalAddress\npostalAddress: 1234 Main St.$Anytown, CA 12345$USA" );
+
+        // verify value is correctly decoded
+        addressEditorDialogBot = entryEditorBot.editValueExpectingAddressEditor( "postalAddress",
+            "1234 Main St., Anytown, CA 12345, USA" );
+        assertTrue( addressEditorDialogBot.isVisible() );
+        assertEquals( "1234 Main St.\nAnytown, CA 12345\nUSA", addressEditorDialogBot.getText() );
+        addressEditorDialogBot.clickCancelButton();
+
+        // edit value with a complex address and verify value is correctly encoded
+        addressEditorDialogBot = entryEditorBot.editValueExpectingAddressEditor( "postalAddress",
+            "1234 Main St., Anytown, CA 12345, USA" );
+        assertTrue( addressEditorDialogBot.isVisible() );
+        assertEquals( "1234 Main St.\nAnytown, CA 12345\nUSA", addressEditorDialogBot.getText() );
+        // TODO: $1,000,000 Sweepstakes
+        addressEditorDialogBot.setText( "1,000,000 Sweepstakes\nPO Box 1000000\nAnytown, CA 12345\nUSA" );
+        addressEditorDialogBot.clickOkButton();
+        assertEquals( 9, entryEditorBot.getAttributeValues().size() );
+        assertFalse( entryEditorBot.getAttributeValues()
+            .contains( "postalAddress: 1234 Main St., Anytown, CA 12345, USA" ) );
+        assertTrue( entryEditorBot.getAttributeValues()
+            // TODO: $1,000,000 Sweepstakes
+            .contains( "postalAddress: 1,000,000 Sweepstakes, PO Box 1000000, Anytown, CA 12345, USA" ) );
+        modificationLogsViewBot
+            .waitForText( "delete: postalAddress\npostalAddress: 1234 Main St.$Anytown, CA 12345$USA" );
+        modificationLogsViewBot.waitForText(
+            // TODO: $1,000,000 Sweepstakes
+            "add: postalAddress\npostalAddress: 1,000,000 Sweepstakes$PO Box 1000000$Anytown, CA 12345$USA" );
+
+        // verify value is correctly decoded
+        // TODO: $1,000,000 Sweepstakes
+        addressEditorDialogBot = entryEditorBot.editValueExpectingAddressEditor( "postalAddress",
+            "1,000,000 Sweepstakes, PO Box 1000000, Anytown, CA 12345, USA" );
+        assertTrue( addressEditorDialogBot.isVisible() );
+        // TODO: $1,000,000 Sweepstakes
+        assertEquals( "1,000,000 Sweepstakes\nPO Box 1000000\nAnytown, CA 12345\nUSA",
+            addressEditorDialogBot.getText() );
+        addressEditorDialogBot.clickCancelButton();
+    }
+
+
     /**
      * DIRSTUDIO-1199, DIRSTUDIO-1204, DIRSTUDIO-1267: Binary attributes.
      * Test adding, editing and deleting of attributes with binary option in the entry editor.
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AddressEditorDialogBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AddressEditorDialogBot.java
new file mode 100644
index 000000000..83a7719da
--- /dev/null
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AddressEditorDialogBot.java
@@ -0,0 +1,47 @@
+/*
+ *  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.directory.studio.test.integration.ui.bots;
+
+
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+
+
+public class AddressEditorDialogBot extends DialogBot
+{
+
+    public AddressEditorDialogBot()
+    {
+        super( "Address Editor" );
+        super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name );
+    }
+
+
+    public String getText()
+    {
+        return bot.text( 0 ).getText();
+    }
+
+
+    public void setText( String text )
+    {
+        bot.text( 0 ).setText( text );
+    }
+
+}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
index 0012f6868..fa61a4062 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
@@ -144,6 +144,12 @@ public class EntryEditorBot
     }
 
 
+    public AddressEditorDialogBot editValueExpectingAddressEditor( String attributeType, String value )
+    {
+        return editorBot.editValueExpectingAddressEditor( attributeType, value );
+    }
+
+
     public TextEditorDialogBot editValueWithTextEditor( String attributeType, String value )
     {
         return editorBot.editValueWithTextEditor( attributeType, value );
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
index 15bfdecdb..a39ec122d 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
@@ -196,6 +196,13 @@ class EntryEditorWidgetBot
     }
 
 
+    AddressEditorDialogBot editValueExpectingAddressEditor( String attributeType, String value )
+    {
+        editValue( attributeType, value );
+        return new AddressEditorDialogBot();
+    }
+
+
     TextEditorDialogBot editValueWithTextEditor( String attributeType, String value )
     {
         editValueWith( attributeType, value, "^Text Editor$" );
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
index 62877bd30..7532df0aa 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
@@ -82,4 +82,11 @@ public class NewAttributeWizardBot extends WizardBot
         return new HexEditorDialogBot();
     }
 
+
+    public AddressEditorDialogBot clickFinishButtonExpectingAddressEditor()
+    {
+        clickFinishButton();
+        return new AddressEditorDialogBot();
+    }
+
 }