Package org.gradle.gradleplugin.foundation.settings

Examples of org.gradle.gradleplugin.foundation.settings.SettingsNode


        //try it with no nodes
        List<SettingsNode> children = rootNode.getChildNodes();
        assertEquals(0, children.size());

        //add some test nodes
        SettingsNode childNode1 = rootNode.addChild(SAMPLE_NAME_1);
        SettingsNode childNode2 = rootNode.addChild(SAMPLE_NAME_2);
        SettingsNode childNode3 = rootNode.addChild(SAMPLE_NAME_3);
        SettingsNode childNode4 = rootNode.addChild(SAMPLE_NAME_2)//this is a duplicate of childNode2

        //all should be returned
        children = rootNode.getChildNodes();
        TestUtility.assertListContents(children, childNode1, childNode2, childNode3, childNode4);

        //add some more nodes
        SettingsNode childNode5 = rootNode.addChild(SAMPLE_NAME_1);
        SettingsNode childNode6 = rootNode.addChild(SAMPLE_NAME_2);

        //again, all should be returned
        children = rootNode.getChildNodes();
        TestUtility.assertListContents(children, childNode1, childNode2, childNode3, childNode4, childNode5,
                childNode6);
View Full Code Here


        //try it with no nodes
        List<SettingsNode> children = rootNode.getChildNodes();
        assertEquals(0, children.size());

        //add some test nodes
        SettingsNode childNode1 = rootNode.addChild(SAMPLE_NAME_1);
        SettingsNode childNode2 = rootNode.addChild(SAMPLE_NAME_2);
        SettingsNode childNode3 = rootNode.addChild(SAMPLE_NAME_3);
        SettingsNode childNode4 = rootNode.addChild(SAMPLE_NAME_2)//this is a duplicate of childNode2

        //only 2 and 4 match
        children = rootNode.getChildNodes(SAMPLE_NAME_2);
        TestUtility.assertListContents(children, childNode2, childNode4);

        //add some more nodes. Only 1 is a match
        SettingsNode childNode5 = rootNode.addChild(SAMPLE_NAME_1);
        SettingsNode childNode6 = rootNode.addChild(SAMPLE_NAME_2);

        //node 6 should also returned now
        children = rootNode.getChildNodes(SAMPLE_NAME_2);
        TestUtility.assertListContents(children, childNode2, childNode4, childNode6);
    }
View Full Code Here

    /**
     * This verifies that getName and setName work correctly. We call each and make sure the value is stored and
     * retrieved correctly.
     */
    public void testName() {
        SettingsNode childNode1 = rootNode.addChild(SAMPLE_NAME_1);

        assertEquals(SAMPLE_NAME_1, childNode1.getName());

        childNode1.setName(SAMPLE_NAME_3);

        assertEquals(SAMPLE_NAME_3, childNode1.getName());
    }
View Full Code Here

    /**
     * This verifies that getValue and setValue work correctly. We call each and make sure the value is stored and
     * retrieved correctly.
     */
    public void testValue() {
        SettingsNode childNode1 = rootNode.addChild(SAMPLE_NAME_1);

        assertNull(childNode1.getValue());

        childNode1.setValue("myvalue");

        assertEquals("myvalue", childNode1.getValue());

        childNode1.setValue("someothervalue");

        assertEquals("someothervalue", childNode1.getValue());
    }
View Full Code Here

        //make sure we have no children first
        List<SettingsNode> children = rootNode.getChildNodes();
        assertEquals(0, children.size());

        //add some sample nodes.
        SettingsNode childNode1 = rootNode.addChild(SAMPLE_NAME_1);
        SettingsNode childNode2 = rootNode.addChild(SAMPLE_NAME_2);
        SettingsNode childNode3 = rootNode.addChild(SAMPLE_NAME_3);
        SettingsNode childNode4 = rootNode.addChild(SAMPLE_NAME_2)//notice this has the same name as childNode2

        //make sure they're all present as expected
        children = rootNode.getChildNodes();
        TestUtility.assertListContents(children, childNode1, childNode2, childNode3, childNode4);

        //now give the two with the same names different values
        childNode2.setValue("first");
        childNode4.setValue("second");

        //delete the 'first' one with SAMPLE_NAME_2
        childNode2.removeFromParent();

        //make sure its not longer present
        children = rootNode.getChildNodes();
        TestUtility.assertListContents(children, childNode1, childNode3, childNode4);

        //make sure that we didn't delete the wrong node with SAMPLE_NAME_2. The 'second' one should still be present.
        SettingsNode foundNode = rootNode.getChildNode(SAMPLE_NAME_2);
        assertEquals("second", foundNode.getValue());

        //delete another one and make sure its no longer present
        childNode3.removeFromParent();
        children = rootNode.getChildNodes();
        TestUtility.assertListContents(children, childNode1, childNode4);
View Full Code Here

        //make sure we have no children first
        List<SettingsNode> children = rootNode.getChildNodes();
        assertEquals(0, children.size());

        //add some sample nodes.
        SettingsNode childNode1 = rootNode.addChild(SAMPLE_NAME_1);
        SettingsNode childNode2 = rootNode.addChild(SAMPLE_NAME_2);
        SettingsNode childNode3 = rootNode.addChild(SAMPLE_NAME_3);
        SettingsNode childNode4 = rootNode.addChild(SAMPLE_NAME_2);

        //make sure they're all present as expected
        children = rootNode.getChildNodes();
        TestUtility.assertListContents(children, childNode1, childNode2, childNode3, childNode4);
View Full Code Here

    /**
     * This tests getNodeAtPath. We want to make sure it locates nodes via path from several locations.
     */
    public void testGetNodeAtPath() {
        //add some sample nodes. I'm indenting these to better show the structure I'm making
        SettingsNode childNode1 = rootNode.addChild(SAMPLE_NAME_1);
        SettingsNode grandChildNodeA1 = childNode1.addChild("sub_nodeA1");
        SettingsNode greatGrandChildNodeA11 = grandChildNodeA1.addChild("sub_sub_nodeA11");
        SettingsNode greatGrandChildNodeA12 = grandChildNodeA1.addChild("sub_sub_nodeA12");
        SettingsNode grandChildNodeA2 = childNode1.addChild("sub_nodeA2");
        SettingsNode greatGrandChildNodeA21 = grandChildNodeA2.addChild("sub_sub_nodeA21");
        SettingsNode greatGrandChildNodeA22 = grandChildNodeA2.addChild("sub_sub_nodeA22");

        SettingsNode childNode2 = rootNode.addChild(SAMPLE_NAME_2);
        SettingsNode grandChildNodeB1 = childNode2.addChild("sub_nodeB1");
        SettingsNode greatGrandChildNodeB11 = grandChildNodeB1.addChild("sub_sub_nodeB11");
        SettingsNode greatGrandChildNodeB12 = grandChildNodeB1.addChild("sub_sub_nodeB12");
        SettingsNode grandChildNodeB2 = childNode2.addChild("sub_nodeB2");

        SettingsNode childNode3 = rootNode.addChild(SAMPLE_NAME_3);

        //now start searching for some nodes
        SettingsNode foundNode1 = rootNode.getNodeAtPath(SAMPLE_NAME_1, "sub_nodeA2", "sub_sub_nodeA22");
        assertEquals(greatGrandChildNodeA22, foundNode1);

        //try searching from something other than the root. It's still relative to the starting node.
        SettingsNode foundNode2 = childNode2.getNodeAtPath("sub_nodeB1", "sub_sub_nodeB11");
        assertEquals(greatGrandChildNodeB11, foundNode2);

        //try searching for something that doesn't exist at the first level of the sought path.
        SettingsNode foundNode3 = rootNode.getNodeAtPath("nonexistent", "sub_nodeA2", "sub_sub_nodeA22");
        assertNull(foundNode3);

        //try searching for something that doesn't exist at the second level of the sought path
        SettingsNode foundNode4 = rootNode.getNodeAtPath(SAMPLE_NAME_3, "sub_nodeA2", "sub_sub_nodeA22");
        assertNull(foundNode4);

        //try searching for something that doesn't exist at the last level of the sought path
        SettingsNode foundNode5 = rootNode.getNodeAtPath(SAMPLE_NAME_2, "sub_nodeB2", "sub_sub_nodeB22");
        assertNull(foundNode5);

        //try searching for a node using a single path
        SettingsNode foundNode6 = rootNode.getNodeAtPath(SAMPLE_NAME_3);
        assertEquals(childNode3, foundNode6);
    }
View Full Code Here

        //set the value of a child
        rootNode.setValueOfChild(SAMPLE_NAME_1, "myValue");

        //verify it was set properly
        SettingsNode childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("myValue", childNode1.getValue());

        //make sure there's only 1 child.
        children = rootNode.getChildNodes();
        assertEquals(1, children.size());

        //set the value again. This should set the value and NOT add an additional node
        rootNode.setValueOfChild(SAMPLE_NAME_1, "newvalue");
        childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("newvalue", childNode1.getValue());

        //make sure there's still only 1 child.
        children = rootNode.getChildNodes();
        assertEquals(1, children.size());
    }
View Full Code Here

        //now try it with one that doesn't exist. We should get the default value
        assertEquals("default4", rootNode.getValueOfChild("nonexistent", "default4"));

        //now add a single node but don't give it a value (which means its null)
        SettingsNode lastNode = rootNode.addChild("valueless");
        assertNull(lastNode.getValue());

        //now try to get its value. We should get the default value
        assertEquals("default5", rootNode.getValueOfChild("valueless", "default5"));
    }
View Full Code Here

        //set the value of a child
        rootNode.setValueOfChildAsInt(SAMPLE_NAME_1, 8);

        //verify it was set properly
        SettingsNode childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("8", childNode1.getValue());

        //make sure there's only 1 child.
        children = rootNode.getChildNodes();
        assertEquals(1, children.size());

        //set the value again. This should set the value and NOT add an additional node
        rootNode.setValueOfChildAsInt(SAMPLE_NAME_1, 39);
        childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("39", childNode1.getValue());

        //make sure there's still only 1 child.
        children = rootNode.getChildNodes();
        assertEquals(1, children.size());
    }
View Full Code Here

TOP

Related Classes of org.gradle.gradleplugin.foundation.settings.SettingsNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.