Buggy code:
public class AccountTest { @ ClassRule public static KeycloakRule keycloakRule = new KeycloakRule ( new KeycloakSetup ( ) { @ Override public void config ( RealmManager manager , RealmModel adminstrationRealm , RealmModel appRealm ) { } } ) ; private static final UriBuilder BASE = UriBuilder . fromUri ( "http:////localhost:8081//auth" ) ; private static final String ACCOUNT_URL = RealmsResource . accountUrl ( AccountTest . BASE . clone ( ) ) . build ( "test" ) . toString ( ) ; public static String ACCOUNT_REDIRECT = AccountService . loginRedirectUrl ( AccountTest . BASE . clone ( ) ) . build ( "test" ) . toString ( ) ; @ Rule public AssertEvents events = new AssertEvents ( AccountTest . keycloakRule ) ; @ Rule public WebRule webRule = new WebRule ( this ) ; @ WebResource protected WebDriver driver ; @ WebResource protected OAuthClient oauth ; @ WebResource protected AppPage appPage ; @ WebResource protected LoginPage loginPage ; @ WebResource protected RegisterPage registerPage ; @ WebResource protected AccountPasswordPage changePasswordPage ; @ WebResource protected AccountUpdateProfilePage profilePage ; @ WebResource protected AccountTotpPage totpPage ; @ WebResource protected AccountLogPage logPage ; @ WebResource protected AccountSessionsPage sessionsPage ; @ WebResource protected ErrorPage errorPage ; private TimeBasedOTP totp = new TimeBasedOTP ( ) ; private String userId ; @ Before public void before ( ) { } @ After public void after ( ) { } public void runit ( ) throws Exception { } @ Test public void returnToAppFromQueryParam ( ) { } @ Test public void changePassword ( ) { changePasswordPage . open ( ) ; loginPage . login ( "test-user@localhost" , "password" ) ; String sessionId = events . expectLogin ( ) . client ( "account" ) . detail ( REDIRECT_URI , ( ( AccountTest . ACCOUNT_REDIRECT ) + "?path=password" ) ) . assertEvent ( ) . getSessionId ( ) ; changePasswordPage . changePassword ( "" , "new-password" , "new-password" ) ; Assert . assertEquals ( "Please<seq2seq4repair_space>specify<seq2seq4repair_space>password." , profilePage . getError ( ) ) ; changePasswordPage . changePassword ( "password" , "new-password" , "new-password2" ) ; Assert . assertEquals ( "Password<seq2seq4repair_space>confirmation<seq2seq4repair_space>doesn't<seq2seq4repair_space>match" , profilePage . getError ( ) ) ; changePasswordPage . changePassword ( "password" , "new-password" , "new-password" ) ; Assert . assertEquals ( "Your<seq2seq4repair_space>password<seq2seq4repair_space>has<seq2seq4repair_space>been<seq2seq4repair_space>updated" , profilePage . getSuccess ( ) ) ; events . expectAccount ( UPDATE_PASSWORD ) . assertEvent ( ) ; changePasswordPage . logout ( ) ; events . expectLogout ( sessionId ) . detail ( REDIRECT_URI , changePasswordPage . getPath ( ) ) . assertEvent ( ) ; loginPage . open ( ) ; loginPage . login ( "test-user@localhost" , "password" ) ; Assert . assertEquals ( "Invalid<seq2seq4repair_space>username<seq2seq4repair_space>or<seq2seq4repair_space>password." , loginPage . getError ( ) ) ; <START_BUG> events . expectLogin ( ) . session ( ( ( String ) ( null ) ) ) . error ( "invalid_user_credentials" ) . removeDetail ( CODE_ID ) . assertEvent ( ) ; <END_BUG> loginPage . open ( ) ; loginPage . login ( "test-user@localhost" , "new-password" ) ; Assert . assertEquals ( AUTH_RESPONSE , appPage . getRequestType ( ) ) ; events . expectLogin ( ) . assertEvent ( ) ; } @ Test public void changePasswordWithPasswordPolicy ( ) { } @ Test public void changeProfile ( ) { } @ Test public void setupTotp ( ) { } @ Test public void changeProfileNoAccess ( ) throws Exception { } @ Test public void viewLog ( ) { } @ Test public void sessions ( ) { } }

Fix:
events . expectLogin ( ) . session ( ( ( String ) ( null ) ) ) . error ( "invalid_user_credentials" ) . assertEvent ( ) ;