Search in sources :

Example 11 with GeoServerWorkspaceNode

use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.

the class GeoServerInputTest method testCopyNodes.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#copyNodes(com.sldeditor.common.NodeInterface, java.util.Map)}.
 */
@Test
public void testCopyNodes() {
    GeoServerInput input = new GeoServerInput(null);
    GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
    FSTree tree = new FSTree();
    DefaultMutableTreeNode rootNode;
    rootNode = new DefaultMutableTreeNode("Root");
    DefaultTreeModel model = new DefaultTreeModel(rootNode);
    input.populate(tree, model, rootNode);
    URL url = SLDFileHandlerTest.class.getResource("/sld/point_attribute.sld");
    List<SLDDataInterface> sldDataList = input.open(url);
    assertNull(sldDataList);
    GeoServerConnection connection1 = new GeoServerConnection();
    connection1.setConnectionName("test connection 1");
    // Add some GeoServer connections
    input.addNewConnection(connection1);
    // Try null parameters
    assertFalse(input.copyNodes(null, null));
    // Try with valid parameters
    GeoServerWorkspaceNode workspaceTreeNode = new GeoServerWorkspaceNode(input, connection1, "test workspace", false);
    // Create test data
    Map<NodeInterface, List<SLDDataInterface>> copyDataMap = new HashMap<NodeInterface, List<SLDDataInterface>>();
    List<SLDDataInterface> sldToCopyList = new ArrayList<SLDDataInterface>();
    StyleWrapper styleWrapper = new StyleWrapper("workspace", "layer1");
    SLDData sldData = new SLDData(styleWrapper, "sld contents");
    sldData.setConnectionData(connection1);
    sldToCopyList.add(sldData);
    copyDataMap.put(workspaceTreeNode, sldToCopyList);
    assertFalse(input.copyNodes(workspaceTreeNode, null));
    assertFalse(input.copyNodes(null, copyDataMap));
    // Try with valid parameters
    assertTrue(input.copyNodes(workspaceTreeNode, copyDataMap));
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) HashMap(java.util.HashMap) FSTree(com.sldeditor.datasource.extension.filesystem.node.FSTree) ArrayList(java.util.ArrayList) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) ArrayList(java.util.ArrayList) List(java.util.List) NodeInterface(com.sldeditor.common.NodeInterface) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Aggregations

GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)11 SLDDataInterface (com.sldeditor.common.SLDDataInterface)5 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)5 StyleWrapper (com.sldeditor.common.data.StyleWrapper)5 List (java.util.List)5 NodeInterface (com.sldeditor.common.NodeInterface)3 SLDData (com.sldeditor.common.data.SLDData)3 GeoServerClientInterface (com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 Test (org.junit.Test)3 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)2 FSTree (com.sldeditor.datasource.extension.filesystem.node.FSTree)2 GeoServerLayerHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerHeadingNode)2 GeoServerLayerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)2 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)2 GeoServerStyleHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode)2 GeoServerStyleNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode)2 GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)2