Search in sources :

Example 36 with VersionData

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

the class VendorOptionTableModelTest method testGetValueAt.

/**
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#getValueAt(int, int)}.
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#getRowCount()}.
 */
@Test
public void testGetValueAt() {
    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());
    String actualValue1 = (String) model.getValueAt(0, 0);
    assertEquals(vendorOption.getName(), actualValue1);
    VersionData actualValue2 = (VersionData) model.getValueAt(0, 1);
    VersionData latest = VersionData.getLatestVersion(GeoServerVendorOption.class);
    assertEquals(latest.getVersionString(), actualValue2.getVersionString());
    assertNull(model.getValueAt(0, -1));
    assertNull(model.getValueAt(0, 5));
}
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)

Example 37 with VersionData

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

the class VendorOptionManagerTest method testGetDefaultVendorOptionVersionData.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getDefaultVendorOptionVersionData()}.
 */
@Test
public void testGetDefaultVendorOptionVersionData() {
    VersionData versionData = VendorOptionManager.getInstance().getDefaultVendorOptionVersionData();
    assertEquals("Latest", versionData.getVersionString());
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) Test(org.junit.Test)

Example 38 with VersionData

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

the class VendorOptionManagerTest method testOverrideSelectedVendorOptions.

/**
 * Test method for
 * {@link com.sldeditor.common.vendoroption.VendorOptionManager#overrideSelectedVendorOptions(java.util.List, com.sldeditor.common.vendoroption.VendorOptionVersion)}.
 */
@Test
public void testOverrideSelectedVendorOptions() {
    VendorOptionManager.destroyInstance();
    VendorOptionManager.getInstance().addVendorOptionListener(obj);
    obj.vendorOptionVersionsList.clear();
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    VersionData actualPrefVO = VersionData.decode(GeoServerVendorOption.class, "2.4.2");
    vendorOptionList.add(actualPrefVO);
    VendorOptionManager.getInstance().setSelectedVendorOptions(vendorOptionList);
    assertEquals(1, obj.vendorOptionVersionsList.size());
    obj.vendorOptionVersionsList.clear();
    List<VersionData> vendorOptionList2 = new ArrayList<VersionData>();
    VersionData actualPrefVO2 = VersionData.decode(GeoServerVendorOption.class, "2.3.2");
    vendorOptionList2.add(actualPrefVO2);
    VendorOptionManager.getInstance().overrideSelectedVendorOptions(vendorOptionList2);
    assertEquals(1, obj.vendorOptionVersionsList.size());
    // Should now be unaffected by changes in vendor option
    obj.vendorOptionVersionsList.clear();
    VendorOptionManager.getInstance().setSelectedVendorOptions(vendorOptionList2);
    assertEquals(0, obj.vendorOptionVersionsList.size());
    VendorOptionManager.destroyInstance();
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 39 with VersionData

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

the class VendorOptionManagerTest method testIsAllowed.

/**
 * Test method for
 * {@link com.sldeditor.common.vendoroption.VendorOptionManager#isAllowed(java.util.List, com.sldeditor.common.vendoroption.VendorOptionVersion)}.
 */
@Test
public void testIsAllowed() {
    assertFalse(VendorOptionManager.getInstance().isAllowed(null, null));
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
    VendorOptionVersion vo = new VendorOptionVersion(GeoServerVendorOption.class, versionDataMin, versionDataMax);
    List<VersionData> versionList = new ArrayList<VersionData>();
    versionList.add(VersionData.decode(GeoServerVendorOption.class, "1.8.3"));
    assertFalse(VendorOptionManager.getInstance().isAllowed(versionList, vo));
    versionList.add(VersionData.decode(GeoServerVendorOption.class, "2.7.x"));
    assertTrue(VendorOptionManager.getInstance().isAllowed(versionList, vo));
}
Also used : GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 40 with VersionData

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

the class VendorOptionStatusTest method testGetVendorOptionVersionString.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionStatus#getVendorOptionVersionString(VersionData)}.
 */
@Test
public void testGetVendorOptionVersionString() {
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
    VendorOptionVersion versionData = new VendorOptionVersion(GeoServerVendorOption.class, versionDataMin, versionDataMax);
    assertEquals("", VendorOptionStatus.getVendorOptionVersionString(null));
    assertEquals("GeoServer 2.4.1-2.8.3", VendorOptionStatus.getVendorOptionVersionString(versionData));
    versionData = new VendorOptionVersion(GeoServerVendorOption.class, versionDataMin, VersionData.decode(getClass(), "Latest"));
    assertEquals("GeoServer 2.4.1-", VendorOptionStatus.getVendorOptionVersionString(versionData));
    versionData = new VendorOptionVersion(GeoServerVendorOption.class, VersionData.decode(getClass(), "Earliest"), versionDataMax);
    assertEquals("GeoServer -2.8.3", VendorOptionStatus.getVendorOptionVersionString(versionData));
}
Also used : GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) 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