Buggy code:
public class DistributableSessionTestCase { private final UndertowSessionManager manager = mock ( UndertowSessionManager . class ) ; private final SessionConfig config = mock ( SessionConfig . class ) ; private final Session < LocalSessionContext > session = mock ( Session . class ) ; private final Batch batch = mock ( Batch . class ) ; private final Session adapter = new DistributableSession ( this . manager , this . session , this . config , this . batch ) ; @ Test public void getId ( ) { } @ Test public void requestDone ( ) { } @ Test public void getCreationTime ( ) { } @ Test public void getLastAccessedTime ( ) { } @ Test public void getMaxInactiveInterval ( ) { } @ Test public void setMaxInactiveInterval ( ) { } @ Test public void getAttribute ( ) { } @ Test public void getAuthenticatedSessionAttribute ( ) { } @ Test public void setAttribute ( ) { } @ Test public void setNewAttribute ( ) { } @ Test public void setNullAttribute ( ) { } @ Test public void setSameAttribute ( ) { } @ Test public void setAuthenticatedSessionAttribute ( ) { } @ Test public void removeAttribute ( ) { } @ Test public void removeNonExistingAttribute ( ) { } @ Test public void invalidate ( ) { } @ Test public void getSessionManager ( ) { } @ Test public void changeSessionId ( ) { HttpServerExchange exchange = new HttpServerExchange ( null ) ; SessionConfig config = mock ( SessionConfig . class ) ; SessionManager < LocalSessionContext > manager = mock ( SessionManager . class ) ; Session < LocalSessionContext > session = mock ( Session . class ) ; SessionAttributes oldAttributes = mock ( SessionAttributes . class ) ; SessionAttributes newAttributes = mock ( SessionAttributes . class ) ; SessionMetaData oldMetaData = mock ( SessionMetaData . class ) ; SessionMetaData newMetaData = mock ( SessionMetaData . class ) ; LocalSessionContext oldContext = mock ( LocalSessionContext . class ) ; LocalSessionContext newContext = mock ( LocalSessionContext . class ) ; String sessionId = "session" ; String name = "name" ; Object value = new Object ( ) ; Date date = new Date ( ) ; long interval = 10L ; AuthenticatedSession authenticatedSession = new AuthenticatedSession ( null , null ) ; ArgumentCaptor < TimeUnit > capturedUnit = ArgumentCaptor . forClass ( TimeUnit . class ) ; when ( this . manager . getSessionManager ( ) ) . thenReturn ( manager ) ; <START_BUG> when ( manager . createSessionId ( ) ) . thenReturn ( sessionId ) ; <END_BUG> when ( manager . createSession ( sessionId ) ) . thenReturn ( session ) ; when ( this . session . getAttributes ( ) ) . thenReturn ( oldAttributes ) ; when ( this . session . getMetaData ( ) ) . thenReturn ( oldMetaData ) ; when ( session . getAttributes ( ) ) . thenReturn ( newAttributes ) ; when ( session . getMetaData ( ) ) . thenReturn ( newMetaData ) ; when ( oldAttributes . getAttributeNames ( ) ) . thenReturn ( Collections . singleton ( name ) ) ; when ( oldAttributes . getAttribute ( name ) ) . thenReturn ( value ) ; when ( newAttributes . setAttribute ( name , value ) ) . thenReturn ( null ) ; when ( oldMetaData . getLastAccessedTime ( ) ) . thenReturn ( date ) ; when ( oldMetaData . getMaxInactiveInterval ( capturedUnit . capture ( ) ) ) . thenReturn ( interval ) ; when ( session . getId ( ) ) . thenReturn ( sessionId ) ; when ( this . session . getLocalContext ( ) ) . thenReturn ( oldContext ) ; when ( session . getLocalContext ( ) ) . thenReturn ( newContext ) ; when ( oldContext . getAuthenticatedSession ( ) ) . thenReturn ( authenticatedSession ) ; String result = this . adapter . changeSessionId ( exchange , config ) ; assertSame ( sessionId , result ) ; verify ( newMetaData ) . setLastAccessedTime ( date ) ; verify ( newMetaData ) . setMaxInactiveInterval ( interval , capturedUnit . getValue ( ) ) ; verify ( config ) . setSessionId ( exchange , sessionId ) ; verify ( newContext ) . setAuthenticatedSession ( same ( authenticatedSession ) ) ; } }

Fix:
when ( manager . createIdentifier ( ) ) . thenReturn ( sessionId ) ;