Search in sources :

Example 1 with SLDDataFlavour

use of com.sldeditor.datasource.extension.filesystem.dataflavour.SLDDataFlavour in project sldeditor by robward-scisys.

the class TransferredDataTest method testGetDataListSize.

/**
 * Test method for {@link com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData#getDataListSize()}.
 */
@Test
public void testGetDataListSize() {
    TransferredData data = new TransferredData();
    assertEquals(0, data.getDataListSize());
    Integer userObject1 = Integer.valueOf(42);
    Double userObject2 = Double.valueOf(42.0);
    String userObject3 = "xxxx";
    SLDDataFlavour dataFlavour1 = new SLDDataFlavour(getClass(), "humanPresentableName");
    SLDDataFlavour dataFlavour2 = new SLDDataFlavour(getClass(), "humanPresentableName");
    SLDDataFlavour dataFlavour3 = new SLDDataFlavour(getClass(), "humanPresentableName");
    TreePath treePath1 = new TreePath("test1");
    TreePath treePath2 = new TreePath("test2");
    TreePath treePath3 = new TreePath("test3");
    data.addData(treePath1, userObject1, dataFlavour1);
    data.addData(treePath2, userObject2, dataFlavour2);
    data.addData(treePath3, userObject3, dataFlavour3);
    assertEquals(3, data.getDataListSize());
    assertEquals(dataFlavour2, data.getDataFlavour(1));
    assertNull(data.getDataFlavour(-1));
    assertNull(data.getDataFlavour(11));
    assertEquals(userObject3, data.getUserObject(2));
    assertNull(data.getUserObject(-1));
    assertNull(data.getUserObject(11));
    assertEquals(treePath1, data.getTreePath(0));
    assertNull(data.getTreePath(-1));
    assertNull(data.getTreePath(11));
}
Also used : TransferredData(com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData) TreePath(javax.swing.tree.TreePath) SLDDataFlavour(com.sldeditor.datasource.extension.filesystem.dataflavour.SLDDataFlavour) Test(org.junit.Test)

Example 2 with SLDDataFlavour

use of com.sldeditor.datasource.extension.filesystem.dataflavour.SLDDataFlavour in project sldeditor by robward-scisys.

the class SLDDataFlavourTest method testSLDDataFlavour.

/**
 * Test method for {@link com.sldeditor.datasource.extension.filesystem.dataflavour.SLDDataFlavour#SLDDataFlavour()}.
 */
@Test
public void testSLDDataFlavour() {
    SLDDataFlavour actual1 = new SLDDataFlavour();
    String mimeType = "application/json";
    String humanPresentableName = "humanPresentableName";
    ClassLoader classLoader = SLDDataFlavourTest.class.getClassLoader();
    SLDDataFlavour actual2 = null;
    try {
        actual2 = new SLDDataFlavour(mimeType, humanPresentableName, classLoader);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    SLDDataFlavour actual4 = null;
    SLDDataFlavour actual4a = null;
    try {
        actual4 = new SLDDataFlavour(mimeType);
        actual4a = new SLDDataFlavour(mimeType);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    SLDDataFlavour actual5 = new SLDDataFlavour(getClass(), humanPresentableName);
    SLDDataFlavour actual6 = new SLDDataFlavour(getClass(), humanPresentableName);
    DataFlavor tmp = null;
    assertFalse(actual1.equals(tmp));
    assertFalse(actual1.equals(actual2));
    assertTrue(actual5.equals(actual6));
    assertTrue(actual4a.equals(actual4));
    SLDDataFlavour actual3 = new SLDDataFlavour(mimeType, humanPresentableName);
    SLDDataFlavour actual3a = new SLDDataFlavour(mimeType, humanPresentableName);
    SLDDataFlavour actual3b = new SLDDataFlavour(mimeType, "different");
    assertTrue(actual3a.equals(actual3));
    assertFalse(actual3b.equals(actual3));
}
Also used : SLDDataFlavour(com.sldeditor.datasource.extension.filesystem.dataflavour.SLDDataFlavour) DataFlavor(java.awt.datatransfer.DataFlavor) Test(org.junit.Test)

Aggregations

SLDDataFlavour (com.sldeditor.datasource.extension.filesystem.dataflavour.SLDDataFlavour)2 Test (org.junit.Test)2 TransferredData (com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 TreePath (javax.swing.tree.TreePath)1