Search in sources :

Example 31 with VersionData

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

the class PrefManagerTest method testFinish.

/**
 * Test method for {@link com.sldeditor.common.preferences.PrefManager#finish()}.
 */
@Test
public void testFinish() {
    PrefManager.initialise(null);
    PrefManager.getInstance().finish();
    DummyPropertyManager propertyManager = new DummyPropertyManager();
    PrefManager.initialise(propertyManager);
    // Set up data as if it had been read in
    PrefData prefData = new PrefData();
    prefData.setUseAntiAlias(true);
    Color backgroundColour = Color.GRAY;
    prefData.setBackgroundColour(backgroundColour);
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
    vendorOptionList.add(VersionData.getEarliestVersion(GeoServerVendorOption.class));
    prefData.setVendorOptionVersionList(vendorOptionList);
    String uiLayoutClass = "perfect curve";
    prefData.setUiLayoutClass(uiLayoutClass);
    String lastFolderViewed = "secret";
    prefData.setLastFolderViewed(lastFolderViewed);
    prefData.setLastViewedKey(PrefDataLastViewedEnum.FOLDER);
    prefData.setSaveLastFolderView(true);
    PrefManager.getInstance().setPrefData(prefData);
    PrefManager.getInstance().finish();
    // Try GeoServer as last item viewed
    prefData.setLastViewedKey(PrefDataLastViewedEnum.GEOSERVER);
    PrefManager.getInstance().setPrefData(prefData);
    PrefManager.getInstance().finish();
}
Also used : GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) PrefData(com.sldeditor.common.preferences.PrefData) VersionData(com.sldeditor.common.vendoroption.VersionData) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 32 with VersionData

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

the class SLDDataTest method testVendorOptionList.

/**
 * Test vendor option list.
 */
@Test
public void testVendorOptionList() {
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VersionData.getLatestVersion(this.getClass()));
    SLDData data = new SLDData(null, null);
    data.setVendorOptionList(vendorOptionList);
    assertEquals(vendorOptionList, data.getVendorOptionList());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) VersionData(com.sldeditor.common.vendoroption.VersionData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 33 with VersionData

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

the class PrefManagerTest method testUndoAction.

/**
 * Test method for {@link com.sldeditor.common.preferences.PrefManager#undoAction(com.sldeditor.common.undo.UndoInterface)}. Test method for
 * {@link com.sldeditor.common.preferences.PrefManager#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    PrefManager.initialise(null);
    PrefManager.getInstance().finish();
    DummyPropertyManager propertyManager = new DummyPropertyManager();
    PrefManager.initialise(propertyManager);
    // Set up data as if it had been read in
    PrefData prefData = new PrefData();
    prefData.setUseAntiAlias(true);
    Color backgroundColour = Color.GRAY;
    prefData.setBackgroundColour(backgroundColour);
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
    vendorOptionList.add(VersionData.getEarliestVersion(GeoServerVendorOption.class));
    prefData.setVendorOptionVersionList(vendorOptionList);
    String uiLayoutClass = "perfect curve";
    prefData.setUiLayoutClass(uiLayoutClass);
    String lastFolderViewed = "secret";
    prefData.setLastFolderViewed(lastFolderViewed);
    prefData.setLastViewedKey(PrefDataLastViewedEnum.FOLDER);
    prefData.setSaveLastFolderView(true);
    PrefManager.getInstance().setPrefData(prefData);
    PrefData copy = prefData.clone();
    copy.setLastViewedKey(PrefDataLastViewedEnum.GEOSERVER);
    PrefManager.getInstance().setPrefData(copy);
    PrefData actual = PrefManager.getInstance().getPrefData();
    assertEquals(PrefDataLastViewedEnum.GEOSERVER, actual.getLastViewedKey());
    UndoManager.getInstance().undo();
    actual = PrefManager.getInstance().getPrefData();
    assertEquals(PrefDataLastViewedEnum.FOLDER, actual.getLastViewedKey());
    UndoManager.getInstance().redo();
    actual = PrefManager.getInstance().getPrefData();
    assertEquals(PrefDataLastViewedEnum.GEOSERVER, actual.getLastViewedKey());
    // Increase the code coverage
    PrefManager.getInstance().undoAction(null);
    PrefManager.getInstance().undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    PrefManager.getInstance().redoAction(null);
    PrefManager.getInstance().redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) PrefData(com.sldeditor.common.preferences.PrefData) VersionData(com.sldeditor.common.vendoroption.VersionData) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 34 with VersionData

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

the class PrefManagerTest method testPrefData.

/**
 * Test method for {@link com.sldeditor.common.preferences.PrefManager#useAntiAlias()}.
 */
@Test
public void testPrefData() {
    PrefData prefData = new PrefData();
    prefData.setUseAntiAlias(true);
    Color backgroundColour = Color.GRAY;
    prefData.setBackgroundColour(backgroundColour);
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
    prefData.setVendorOptionVersionList(vendorOptionList);
    String uiLayoutClass = "perfect curve";
    prefData.setUiLayoutClass(uiLayoutClass);
    PrefManager.getInstance().setPrefData(prefData);
    assertEquals(backgroundColour, PrefManager.getInstance().getPrefData().getBackgroundColour());
    assertEquals(uiLayoutClass, PrefManager.getInstance().getPrefData().getUiLayoutClass());
    assertEquals(true, PrefManager.getInstance().getPrefData().isUseAntiAlias());
}
Also used : PrefData(com.sldeditor.common.preferences.PrefData) VersionData(com.sldeditor.common.vendoroption.VersionData) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 35 with VersionData

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

the class VendorOptionTableModelTest method testSetValueAtObjectIntInt.

/**
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#setValueAt(java.lang.Object, int, int)}.
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#setSelectedVersion(com.sldeditor.common.vendoroption.VersionData, int)}.
 */
@Test
public void testSetValueAtObjectIntInt() {
    Map<VendorOptionTypeInterface, String> options = new LinkedHashMap<VendorOptionTypeInterface, String>();
    VendorOptionTypeInterface vendorOption = VendorOptionManager.getInstance().getClass(GeoServerVendorOption.class);
    options.put(vendorOption, vendorOption.getName());
    VendorOptionTableModel model = new VendorOptionTableModel(options, null);
    assertEquals(1, model.getRowCount());
    VersionData latest = VersionData.getLatestVersion(GeoServerVendorOption.class);
    VersionData earliest = VersionData.getEarliestVersion(GeoServerVendorOption.class);
    // Invalid column
    model.setValueAt(earliest, 0, 0);
    VersionData actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(latest.getVersionString(), actual.getVersionString());
    // Invalid row
    model.setValueAt(earliest, -1, 1);
    actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(latest.getVersionString(), actual.getVersionString());
    model.setValueAt(earliest, 1, 1);
    actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(latest.getVersionString(), actual.getVersionString());
    // Valid row
    model.setValueAt(earliest, 0, 1);
    actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(earliest.getVersionString(), actual.getVersionString());
    // Try setSelectedVersion
    model.setSelectedVersion(latest, 0);
    actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(latest.getVersionString(), actual.getVersionString());
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionTableModel(com.sldeditor.common.vendoroption.selection.VendorOptionTableModel) VendorOptionTypeInterface(com.sldeditor.common.vendoroption.VendorOptionTypeInterface) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Aggregations

VersionData (com.sldeditor.common.vendoroption.VersionData)56 Test (org.junit.Test)36 ArrayList (java.util.ArrayList)26 VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)13 GeoServerVendorOption (com.sldeditor.common.vendoroption.GeoServerVendorOption)9 PrefData (com.sldeditor.common.preferences.PrefData)7 VendorOptionInfo (com.sldeditor.common.vendoroption.info.VendorOptionInfo)5 Color (java.awt.Color)5 SLDData (com.sldeditor.common.data.SLDData)4 VendorOptionTypeInterface (com.sldeditor.common.vendoroption.VendorOptionTypeInterface)4 File (java.io.File)4 VendorOptionTableModel (com.sldeditor.common.vendoroption.selection.VendorOptionTableModel)3 ValueComboBoxDataGroup (com.sldeditor.ui.widgets.ValueComboBoxDataGroup)3 IOException (java.io.IOException)3 LinkedHashMap (java.util.LinkedHashMap)3 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)2 StyleWrapper (com.sldeditor.common.data.StyleWrapper)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1