Update node attribute

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Update node attribute

Benjamin R

I have a problem updating an attribute in a node that is part of a node tree. I made a small example on how I imagined it could be done:

class TestNode extends GroovyTestCase {

                public void testNodeAttributeUpdate() {

                                def someBuilder = new NodeBuilder()

                                def tree = someBuilder.Entities() {
  Entity(x:20,  y:20) {}
  Entity(x:21,  y:21) {}

                                def n = tree.Entity.find { it['@x'] == '21' }
                                assert 21 == n.attribute('y');
                                // Since n.attribute('y') returns a Integer the follwoing might work.
                                def y = n.attribute('y');
                                y = 34
                                // Unfortunatly it seems that 'y' does not represent a reference to n.attribute('y') and the test fails
                                assert 34 == n.attribute('y');

Unfortunately this does not work. Can someone help out?

Thanks Benjamin