Search in sources :

Example 1 with PrefDataLastViewedEnum

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

the class PrefDataTest method testLastViewedKey.

/**
 * Test method for {@link com.sldeditor.common.preferences.PrefData#getLastViewedKey()}.
 * Test method for {@link com.sldeditor.common.preferences.PrefData#setLastViewedKey(PrefDataLastViewedEnum)}.
 */
@Test
public void testLastViewedKey() {
    PrefData prefData = new PrefData();
    PrefDataLastViewedEnum expectedValue = PrefDataLastViewedEnum.FOLDER;
    prefData.setLastViewedKey(expectedValue);
    assertEquals(expectedValue, prefData.getLastViewedKey());
    expectedValue = PrefDataLastViewedEnum.GEOSERVER;
    prefData.setLastViewedKey(expectedValue);
    assertEquals(expectedValue, prefData.getLastViewedKey());
}
Also used : PrefData(com.sldeditor.common.preferences.PrefData) PrefDataLastViewedEnum(com.sldeditor.common.preferences.PrefDataLastViewedEnum) Test(org.junit.Test)

Example 2 with PrefDataLastViewedEnum

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

the class FileSystemExtensionTest method testUpdateForPreferences.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.FileSystemExtension#updateForPreferences(PrefData, List String)}.
 */
@Test
public void testUpdateForPreferences() {
    FileSystemExtension fsExt = new FileSystemExtension();
    FileSystemExtensionFactory.override(null);
    fsExt.initialise(null, null);
    fsExt.updateForPreferences(null, null);
    // Set up with 'save last folder view' set to false
    PrefData prefData = new PrefData();
    String lastFolderViewed = null;
    prefData.setLastFolderViewed(lastFolderViewed);
    PrefDataLastViewedEnum lastViewedKey = PrefDataLastViewedEnum.FOLDER;
    prefData.setLastViewedKey(lastViewedKey);
    prefData.setSaveLastFolderView(false);
    List<String> actualArgList = new ArrayList<String>();
    fsExt.updateForPreferences(prefData, actualArgList);
    assertTrue(actualArgList.isEmpty());
    // Set up with 'save last folder view' set to true but no folder
    prefData.setSaveLastFolderView(true);
    fsExt.updateForPreferences(prefData, actualArgList);
    assertTrue(actualArgList.isEmpty());
    // Set up with 'save last folder view' set to true but with folder
    lastFolderViewed = "last viewed";
    prefData.setLastFolderViewed(lastFolderViewed);
    fsExt.updateForPreferences(prefData, actualArgList);
    assertEquals(1, actualArgList.size());
    String expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "folder", lastFolderViewed);
    assertEquals(expected, actualArgList.get(0));
    // Set up with 'save last folder view' set to true but with GeoServer
    actualArgList.clear();
    lastViewedKey = PrefDataLastViewedEnum.GEOSERVER;
    prefData.setLastViewedKey(lastViewedKey);
    fsExt.updateForPreferences(prefData, actualArgList);
    assertEquals(1, actualArgList.size());
    expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "geoserver", lastFolderViewed);
    assertEquals(expected, actualArgList.get(0));
    // Try and replace existing argument
    // CHECKSTYLE:OFF
    String previous = lastFolderViewed;
    // CHECKSTYLE:ON
    lastFolderViewed = "new folder";
    prefData.setLastFolderViewed(lastFolderViewed);
    fsExt.updateForPreferences(prefData, actualArgList);
    assertEquals(1, actualArgList.size());
    expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "geoserver", previous);
    assertEquals(expected, actualArgList.get(0));
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) PrefData(com.sldeditor.common.preferences.PrefData) PrefDataLastViewedEnum(com.sldeditor.common.preferences.PrefDataLastViewedEnum) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

PrefData (com.sldeditor.common.preferences.PrefData)2 PrefDataLastViewedEnum (com.sldeditor.common.preferences.PrefDataLastViewedEnum)2 Test (org.junit.Test)2 FileSystemExtension (com.sldeditor.extension.filesystem.FileSystemExtension)1 ArrayList (java.util.ArrayList)1