Node mockNode = mock( Node.class );
Node parentNode = mock( Node.class );
Node versionNode = mock( Node.class );
Version mockVersion = mock( Version.class );
Version mockVersion2 = mock( Version.class );
VersionManagerImpl versionManager = mock( VersionManagerImpl.class );
VersionHistory mockVersionHistory = mock( VersionHistory.class );
IPentahoSession pentahoSession = mock( IPentahoSession.class );
when( pentahoSession.getName() ).thenReturn( username );
when( sessionMock.getNodeByIdentifier( anyString() ) ).thenReturn( mockNode );
String[] mockVersionLabels = { "label1" };
when( mockVersionHistory.getVersionLabels( mockVersion ) ).thenReturn( mockVersionLabels );
when( mockVersionHistory.getVersionableIdentifier() ).thenReturn( versionableIdentifier );
Version[] mockVersionsList = { mockVersion, mockVersion2 };
Version[] mockVersionsList2 = { mockVersion };
when( mockVersion.getSuccessors() ).thenReturn( mockVersionsList, mockVersionsList2, null );
when( mockVersion.getNode( (String) anyObject() ) ).thenReturn( versionNode );
when( mockVersion.getName() ).thenReturn( versionName );
when( mockVersion.getCreated() ).thenReturn( cal );
when( versionManager.getVersionHistory( mockNode.getPath() ) ).thenReturn( mockVersionHistory );
when( workspaceMock.getVersionManager() ).thenReturn( versionManager );
when( mockVersionHistory.getRootVersion() ).thenReturn( mockVersion );
when( mockNode.getParent() ).thenReturn( parentNode );
when( mockNode.getIdentifier() ).thenReturn( mockNodeId );