assertEquals( sourceNode, resultNode );
}
public void testVisitNodeWithChildAndVisitor()
{
DependencyNode sourceNode = createNode( "g:a:t:1" );
DependencyNode sourceChildNode = createNode( "g:b:t:1" );
sourceNode.addChild( sourceChildNode );
Mock nextVisitorMock = mock( DependencyNodeVisitor.class );
nextVisitorMock.expects( once() ).method( "visit" ).with( eq( sourceNode ) ).will( returnValue( true ) ).id( "1" );
nextVisitorMock.expects( once() ).method( "visit" ).with( eq( sourceChildNode ) ).after( "1" ).will( returnValue( true ) ).id( "2" );
nextVisitorMock.expects( once() ).method( "endVisit" ).with( eq( sourceChildNode ) ).after( "2" ).will( returnValue( true ) ).id( "3" );
nextVisitorMock.expects( once() ).method( "endVisit" ).with( eq( sourceNode ) ).after( "3" ).will( returnValue( true ) );
DependencyNodeVisitor nextVisitor = (DependencyNodeVisitor) nextVisitorMock.proxy();
visitor = new BuildingDependencyNodeVisitor( nextVisitor );
visitor.visit( sourceNode );
visitor.visit( sourceChildNode );
visitor.endVisit( sourceChildNode );
visitor.endVisit( sourceNode );
DependencyNode resultNode = visitor.getDependencyTree();
assertNotSame( sourceNode, resultNode );
assertEquals( sourceNode, resultNode );
}