.item( "/users/users", "Users" ).and()
.item( "/loggers", "Loggers" ).and()
.group( "/administration", "Administration" ).and()
.item( "/administration/system-info", "System info" );
Menu menu = builder.build();
assertEquals( 3, menu.size() );
Menu administration = menu.getItems().get( 0 );
verify( administration, "/administration", "Administration", "/administration" );
verify( administration.getFirstItem(), "/administration/system-info", "System info",
"/administration/system-info" );
verify( menu.getItems().get( 1 ), "/loggers", "Loggers", "/loggers" );
Menu userManagement = menu.getItems().get( 2 );
verify( userManagement, "/users", "User management", "/users" );
verify( userManagement.getItems().get( 0 ), "/users/roles", "User roles", "/users/roles" );
verify( userManagement.getItems().get( 1 ), "/users/users", "Users", "/users/users" );
builder.move( "/users", "/administration/users" )
.move( "/loggers", "/administration/loggers" );
// Items should have been moved, but still the same data
menu = builder.build();
assertEquals( 1, menu.size() );
administration = menu.getItems().get( 0 );
verify( administration, "/administration", "Administration", "/administration" );
assertEquals( 3, administration.size() );
verify( administration.getItems().get( 0 ), "/loggers", "Loggers", "/loggers" );
verify( administration.getItems().get( 1 ), "/administration/system-info", "System info",
"/administration/system-info" );
userManagement = administration.getItems().get( 2 );
verify( userManagement, "/users", "User management", "/users" );
verify( userManagement.getItems().get( 0 ), "/users/roles", "User roles", "/users/roles" );
verify( userManagement.getItems().get( 1 ), "/users/users", "Users", "/users/users" );
// Moving back should be possible, builder itself should not have been modified by previous build
builder.undoMove( "/loggers" );
menu = builder.build();
assertEquals( 2, menu.size() );
administration = menu.getItems().get( 0 );
verify( administration, "/administration", "Administration", "/administration" );
assertEquals( 2, administration.size() );
verify( administration.getItems().get( 0 ), "/administration/system-info", "System info",
"/administration/system-info" );
userManagement = administration.getItems().get( 1 );
verify( userManagement, "/users", "User management", "/users" );
verify( userManagement.getItems().get( 0 ), "/users/roles", "User roles", "/users/roles" );
verify( userManagement.getItems().get( 1 ), "/users/users", "Users", "/users/users" );
verify( menu.getItems().get( 1 ), "/loggers", "Loggers", "/loggers" );
}