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());
}
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));
}
Aggregations