Search in sources :

Example 26 with NodeInterface

use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.

the class DatabaseConnectionToolTest method testDatabaseConnectionTool.

/**
 * Test method for
 * {@link com.sldeditor.tool.databaseconnection.DatabaseConnectionTool#DatabaseConnectionTool(com.sldeditor.tool.databaseconnection.DatabaseConnectStateInterface)}.
 */
@Test
public void testDatabaseConnectionTool() {
    TestDatabaseConnectState state = new TestDatabaseConnectState();
    TestDatabaseConnectionTool testObj = new TestDatabaseConnectionTool(state);
    testObj.setSelectedItems(null, null);
    List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
    DatabaseConnection connection = DatabaseConnectionFactory.createGeoPackage();
    nodeTypeList.add(new DatabaseNode(new DatabaseInput(ToolManager.getInstance()), connection));
    File parent = new File("");
    String filename = "test.gpkg";
    FileTreeNode fileTreeNode = null;
    try {
        fileTreeNode = new FileTreeNode(parent, filename);
        fileTreeNode.setFileCategory(FileTreeNodeTypeEnum.DATABASE);
        nodeTypeList.add(fileTreeNode);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    testObj.setSelectedItems(nodeTypeList, null);
    testObj.populateComplete(null);
    assertNotNull(testObj.getPanel());
    List<Class<?>> uniqueNodeTypeList = new ArrayList<Class<?>>();
    List<SLDDataInterface> sldDataList = null;
    assertFalse(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
    uniqueNodeTypeList.add(String.class);
    assertTrue(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
    nodeTypeList.remove(0);
    assertTrue(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
    testObj.testConnect();
    testObj.testDisconnect();
}
Also used : ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) DatabaseNode(com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) DatabaseConnection(com.sldeditor.common.data.DatabaseConnection) DatabaseInput(com.sldeditor.extension.filesystem.database.DatabaseInput) File(java.io.File) NodeInterface(com.sldeditor.common.NodeInterface) Test(org.junit.Test)

Aggregations

NodeInterface (com.sldeditor.common.NodeInterface)26 SLDDataInterface (com.sldeditor.common.SLDDataInterface)9 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)9 ArrayList (java.util.ArrayList)8 File (java.io.File)7 IOException (java.io.IOException)7 Test (org.junit.Test)7 TransferredData (com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData)5 FileNotFoundException (java.io.FileNotFoundException)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 TreePath (javax.swing.tree.TreePath)5 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)4 JTree (javax.swing.JTree)4 DatabaseConnection (com.sldeditor.common.data.DatabaseConnection)3 DatabaseNode (com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode)3 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)3 DataFlavor (java.awt.datatransfer.DataFlavor)3 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)3 HashMap (java.util.HashMap)3 List (java.util.List)3