Search in sources :

Example 31 with SettingsNode

use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.

the class SettingsNodeVersionWrapper method convertNodes.

/*package*/
static List<SettingsNode> convertNodes(List<SettingsNodeVersion1> nodes) {
    List<SettingsNode> settingsNodes = new ArrayList<SettingsNode>();
    Iterator<SettingsNodeVersion1> iterator = nodes.iterator();
    while (iterator.hasNext()) {
        SettingsNodeVersion1 nodeVersion1 = iterator.next();
        settingsNodes.add(new SettingsNodeVersionWrapper(nodeVersion1));
    }
    return settingsNodes;
}
Also used : SettingsNodeVersion1(org.gradle.openapi.external.ui.SettingsNodeVersion1) SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode) ArrayList(java.util.ArrayList)

Example 32 with SettingsNode

use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.

the class DOM4JSettingsNodeTest method testGetChildNode.

/**
     * This tests that getChildNode works. We'll add some nodes and make sure they are found correctly. We'll also add a
     * duplicate named node. It should never be returned because getChildNode only finds the first one. Lastly, we'll
     * call getChildNode for a node that doesn't exist. It shouldn't be returned.
     */
public void testGetChildNode() {
    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(//this is a duplicate and should never be found via getChildNode.
    SAMPLE_NAME_2);
    assertNotNull(Dom4JUtility.getChild(rootElement, DOM4JSettingsNode.TAG_NAME, DOM4JSettingsNode.NAME_ATTRIBUTE, SAMPLE_NAME_1));
    assertNotNull(Dom4JUtility.getChild(rootElement, DOM4JSettingsNode.TAG_NAME, DOM4JSettingsNode.NAME_ATTRIBUTE, SAMPLE_NAME_2));
    assertNotNull(Dom4JUtility.getChild(rootElement, DOM4JSettingsNode.TAG_NAME, DOM4JSettingsNode.NAME_ATTRIBUTE, SAMPLE_NAME_3));
    assertNotNull(rootNode.getChildNode(SAMPLE_NAME_1));
    assertNotNull(rootNode.getChildNode(SAMPLE_NAME_2));
    assertNotNull(rootNode.getChildNode(SAMPLE_NAME_3));
    SettingsNode foundNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
    assertEquals(foundNode1, childNode1);
    SettingsNode foundNode2 = rootNode.getChildNode(SAMPLE_NAME_2);
    assertEquals(foundNode2, childNode2);
    SettingsNode foundNode3 = rootNode.getChildNode(SAMPLE_NAME_3);
    assertEquals(foundNode3, childNode3);
    //look for the duplicated
    SettingsNode foundNode2B = rootNode.getChildNode(SAMPLE_NAME_2);
    //should still be childNode2.
    assertEquals(foundNode2B, childNode2);
    //this one shouldn't be found.
    SettingsNode foundNode4 = rootNode.getChildNode("notpresent");
    assertNull(foundNode4);
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode) DOM4JSettingsNode(org.gradle.gradleplugin.foundation.settings.DOM4JSettingsNode)

Example 33 with SettingsNode

use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.

the class DOM4JSettingsNodeTest method testName.

/**
     * 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());
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode) DOM4JSettingsNode(org.gradle.gradleplugin.foundation.settings.DOM4JSettingsNode)

Example 34 with SettingsNode

use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.

the class DOM4JSettingsNodeTest method testValue.

/**
     * 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());
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode) DOM4JSettingsNode(org.gradle.gradleplugin.foundation.settings.DOM4JSettingsNode)

Example 35 with SettingsNode

use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.

the class DOM4JSettingsNodeTest method testSetValueOfChildAsInt.

/**
     * This tests setValueOfChildAsInt. We're going to make sure the value is set as well as that repeated calls to this
     * don't add child nodes.
     */
public void testSetValueOfChildAsInt() {
    //make sure we have no children first
    List<SettingsNode> children = rootNode.getChildNodes();
    assertEquals(0, children.size());
    //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());
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode) DOM4JSettingsNode(org.gradle.gradleplugin.foundation.settings.DOM4JSettingsNode)

Aggregations

SettingsNode (org.gradle.gradleplugin.foundation.settings.SettingsNode)35 DOM4JSettingsNode (org.gradle.gradleplugin.foundation.settings.DOM4JSettingsNode)19 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 SettingsNodeVersion1 (org.gradle.openapi.external.ui.SettingsNodeVersion1)1