Search in sources :

Example 1 with MapBoxTool

use of com.sldeditor.tool.mapbox.MapBoxTool in project sldeditor by robward-scisys.

the class MapBoxToolTest method testGetPanel.

/**
 * Test method for {@link com.sldeditor.tool.mapbox.MapBoxTool#getPanel()}.
 */
@Test
public void testGetPanel() {
    MapBoxTool tool = new MapBoxTool();
    assertTrue(tool.getPanel() != null);
}
Also used : MapBoxTool(com.sldeditor.tool.mapbox.MapBoxTool) Test(org.junit.Test)

Example 2 with MapBoxTool

use of com.sldeditor.tool.mapbox.MapBoxTool in project sldeditor by robward-scisys.

the class MapBoxToolTest method testGetToolName.

/**
 * Test method for {@link com.sldeditor.tool.mapbox.MapBoxTool#getToolName()}.
 */
@Test
public void testGetToolName() {
    MapBoxTool tool = new MapBoxTool();
    String toolName = tool.getToolName();
    assertTrue(toolName.compareTo("com.sldeditor.tool.mapbox.MapBoxTool") == 0);
}
Also used : MapBoxTool(com.sldeditor.tool.mapbox.MapBoxTool) Test(org.junit.Test)

Example 3 with MapBoxTool

use of com.sldeditor.tool.mapbox.MapBoxTool in project sldeditor by robward-scisys.

the class MapBoxToolTest method testSupports.

/**
 * Test method for
 * {@link com.sldeditor.tool.mapbox.MapBoxTool#supports(java.util.List, java.util.List, java.util.List)}.
 */
@Test
public void testSupports() {
    MapBoxTool tool = new MapBoxTool();
    assertFalse(tool.supports(null, null, null));
    File testFile1 = null;
    File testFile2 = null;
    File testFile3 = null;
    try {
        testFile1 = File.createTempFile("invalid", ".tst");
        testFile2 = File.createTempFile("valid", ".sld");
        testFile3 = File.createTempFile("valid", ".json");
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    // Try with invalid file
    try {
        List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
        assertNotNull(testFile1);
        nodeTypeList.add(new FileTreeNode(testFile1.getParentFile(), testFile1.getName()));
        assertFalse(tool.supports(null, nodeTypeList, null));
    } catch (SecurityException | FileNotFoundException e) {
        e.printStackTrace();
    }
    // Try with valid mapbox file
    try {
        List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
        nodeTypeList.add(new FileTreeNode(testFile3.getParentFile(), testFile3.getName()));
        assertTrue(tool.supports(null, nodeTypeList, null));
    } catch (SecurityException | FileNotFoundException e) {
        e.printStackTrace();
    }
    // Try with several files
    try {
        List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
        nodeTypeList.add(new FileTreeNode(testFile1.getParentFile(), testFile1.getName()));
        nodeTypeList.add(new FileTreeNode(testFile2.getParentFile(), testFile2.getName()));
        nodeTypeList.add(new FileTreeNode(testFile3.getParentFile(), testFile3.getName()));
        assertFalse(tool.supports(null, nodeTypeList, null));
    } catch (SecurityException | FileNotFoundException e) {
        e.printStackTrace();
    }
    testFile1.delete();
    testFile2.delete();
    testFile3.delete();
}
Also used : MapBoxTool(com.sldeditor.tool.mapbox.MapBoxTool) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) NodeInterface(com.sldeditor.common.NodeInterface) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) Test(org.junit.Test)

Example 4 with MapBoxTool

use of com.sldeditor.tool.mapbox.MapBoxTool in project sldeditor by robward-scisys.

the class MapBoxToolTest method testSetSelectedItems.

/**
 * Test method for
 * {@link com.sldeditor.tool.mapbox.MapBoxTool#setSelectedItems(java.util.List, java.util.List)}.
 */
@Test
public void testSetSelectedItems() {
    MapBoxTool tool = new MapBoxTool();
    JPanel panel = tool.getPanel();
    ToolButton toSLD = null;
    for (Component c : panel.getComponents()) {
        if (c instanceof ToolButton) {
            ToolButton button = (ToolButton) c;
            String toolTipText = button.getToolTipText();
            if (toolTipText.compareTo(Localisation.getString(MapBoxTool.class, "MapBoxTool.exportToSLD")) == 0) {
                toSLD = button;
            }
        }
    }
    File testFile1 = null;
    File testFile3 = null;
    try {
        testFile1 = File.createTempFile("invalid", ".tst");
        testFile3 = File.createTempFile("valid", ".json");
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    // Should both be disabled
    assertFalse(toSLD.isEnabled());
    tool.setSelectedItems(null, null);
    // Invalid file
    List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
    SLDData sldData1 = new SLDData(null, null);
    sldData1.setSLDFile(testFile1);
    sldDataList.add(sldData1);
    tool.setSelectedItems(null, sldDataList);
    // Should both be disabled
    assertFalse(toSLD.isEnabled());
    /*
         * // Try with valid mapbox file sldDataList = new ArrayList<SLDDataInterface>(); SLDData
         * sldData3 = getSLDDataFile("/point/mapbox/circleStyleTest.json");
         * sldDataList.add(sldData3); tool.setSelectedItems(null, sldDataList);
         * 
         * // SLD should be enabled assertTrue(toSLD.isEnabled()); toSLD.doClick();
         * 
         * // Try with valid sld files sldDataList = new ArrayList<SLDDataInterface>();
         * sldDataList.add(sldData3); tool.setSelectedItems(null, sldDataList);
         * 
         * // SLD should be enabled assertTrue(toSLD.isEnabled());
         */
    testFile1.delete();
    testFile3.delete();
// tidyUpTempFiles(sldData3.getSLDFile());
}
Also used : JPanel(javax.swing.JPanel) SLDData(com.sldeditor.common.data.SLDData) ToolButton(com.sldeditor.tool.ToolButton) SLDDataInterface(com.sldeditor.common.SLDDataInterface) MapBoxTool(com.sldeditor.tool.mapbox.MapBoxTool) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Component(java.awt.Component) File(java.io.File) Test(org.junit.Test)

Aggregations

MapBoxTool (com.sldeditor.tool.mapbox.MapBoxTool)4 Test (org.junit.Test)4 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 NodeInterface (com.sldeditor.common.NodeInterface)1 SLDDataInterface (com.sldeditor.common.SLDDataInterface)1 SLDData (com.sldeditor.common.data.SLDData)1 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)1 ToolButton (com.sldeditor.tool.ToolButton)1 Component (java.awt.Component)1 FileNotFoundException (java.io.FileNotFoundException)1 JPanel (javax.swing.JPanel)1