*
* @throws Exception the exception
*/
public void testAddEditDeleteAttribute() throws Exception
{
final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
"cn=Barbara Jensen" );
final SWTBotTree entryEditorTree = SWTBotUtils.getEntryEditorTree( bot );
// add description attribute
entryEditorTree.contextMenu( "New Attribute..." ).click();
bot.comboBoxWithLabel( "Attribute type:" ).setText( "description" );
SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return bot.text( "" ) != null;
}
public String getFailureMessage()
{
return "Could not find empty description attribute";
}
} );
bot.text( "" ).setText( "This is the 1st description." );
SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return entryEditorTree.cell( 6, 0 ).equals( "description" )
&& entryEditorTree.cell( 6, 1 ).equals( "This is the 1st description." );
}
public String getFailureMessage()
{
return "Could not find attribute 'description:This is the 1st description.'";
}
} );
// add second value
entryEditorTree.getTreeItem( "description" ).click();
SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "New Value" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return bot.text( "" ) != null;
}
public String getFailureMessage()
{
return "Could not find empty description attribute";
}
} );
bot.text( "" ).setText( "This is the 2nd description." );
SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return entryEditorTree.cell( 7, 0 ).equals( "description" )
&& entryEditorTree.cell( 7, 1 ).equals( "This is the 2nd description." );
}
public String getFailureMessage()
{
return "Could not find attribute 'description:This is the 2nd description.'";
}
} );
// edit second value
entryEditorTree.select( 7 );
SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "Edit Value" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return bot.text( "This is the 2nd description." ) != null;
}
public String getFailureMessage()
{
return "Could not find description 'This is the 2nd description.'";
}
} );
bot.text( "This is the 2nd description." ).setText( "This is the 3rd description." );
SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return entryEditorTree.cell( 7, 0 ).equals( "description" )
&& entryEditorTree.cell( 7, 1 ).equals( "This is the 3rd description." );
}
public String getFailureMessage()
{
return "Could not find attribute 'description:This is the 3rd description.'";
}
} );
// delete second value
entryEditorTree.select( 7 );
entryEditorTree.contextMenu( "Delete Value" ).click();
SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return !entryEditorTree.cell( 7, 0 ).equals( "description" )
&& entryEditorTree.cell( 6, 0 ).equals( "description" )
&& entryEditorTree.cell( 6, 1 ).equals( "This is the 1st description." );
}
public String getFailureMessage()
{
return "Attribute 'description' is still there.";
}
} );
// edit 1st value
entryEditorTree.select( 6 );
SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "Edit Value" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return bot.text( "This is the 1st description." ) != null;
}
public String getFailureMessage()
{
return "Could not find description 'This is the 1st description.'";
}
} );
bot.text( "This is the 1st description." ).setText( "This is the final description." );
SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return entryEditorTree.cell( 6, 0 ).equals( "description" )
&& entryEditorTree.cell( 6, 1 ).equals( "This is the final description." );
}
public String getFailureMessage()
{
return "Could not find attribute 'description:This is the final description.'";
}
} );
// delete 1st value/attribute
entryEditorTree.select( 6 );
entryEditorTree.contextMenu( "Delete Attribute" ).click();
SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
{
public boolean test() throws Exception
{
return !entryEditorTree.cell( 6, 0 ).equals( "description" );
}
public String getFailureMessage()
{