Search in sources :

Example 16 with VersionData

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

the class GeoServerVendorOptionTest method testGetVersionStringList.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.GeoServerVendorOption#getVersionStringList()}.
 * Test method for {@link com.sldeditor.common.vendoroption.GeoServerVendorOption#addVersion(com.sldeditor.common.vendoroption.VersionData)}.
 * Test method for {@link com.sldeditor.common.vendoroption.GeoServerVendorOption#getVersion(java.lang.String)}.
 * Test method for {@link com.sldeditor.common.vendoroption.GeoServerVendorOption#getVersionList()}.
 */
@Test
public void testGetVersionStringList() {
    GeoServerVendorOption vendorOption = new GeoServerVendorOption();
    assertEquals(0, vendorOption.getVersionStringList().size());
    assertEquals(0, vendorOption.getVersionList().size());
    // This should be ignored
    vendorOption.addVersion(null);
    assertEquals(0, vendorOption.getVersionStringList().size());
    assertEquals(0, vendorOption.getVersionList().size());
    VersionData versionData1 = new VersionData();
    vendorOption.addVersion(versionData1);
    assertEquals(1, vendorOption.getVersionStringList().size());
    assertEquals(1, vendorOption.getVersionList().size());
    VersionData versionData2 = new VersionData();
    vendorOption.addVersion(versionData2);
    assertEquals(2, vendorOption.getVersionStringList().size());
    assertEquals(2, vendorOption.getVersionList().size());
    List<VersionData> voList = vendorOption.getVersionList();
    assertEquals(versionData1, voList.get(0));
    assertEquals(versionData2, voList.get(1));
    List<String> voStringList = vendorOption.getVersionStringList();
    assertEquals(versionData1.getVersionString(), voStringList.get(0));
    assertEquals(versionData2.getVersionString(), voStringList.get(1));
}
Also used : GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) VersionData(com.sldeditor.common.vendoroption.VersionData) Test(org.junit.Test)

Example 17 with VersionData

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

the class VendorOptionManagerTest method testGetTitle.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getTitle()}.
 */
@Test
public void testGetTitle() {
    StringBuilder expectedValue = new StringBuilder();
    expectedValue.append("- ");
    expectedValue.append(Localisation.getString(ParseXML.class, "ParseXML.vendorOption"));
    expectedValue.append(" ");
    String actualValue = VendorOptionManager.getInstance().getTitle(null);
    assertTrue(expectedValue.toString().compareTo(actualValue) == 0);
    // Now try with some real values
    VersionData noVO = VersionData.getDecodedString("com.sldeditor.common.vendoroption.NoVendorOption@Latest");
    VendorOptionVersion noVOV = new VendorOptionVersion(NoVendorOption.class, noVO);
    actualValue = VendorOptionManager.getInstance().getTitle(noVOV);
    StringBuilder expectedValue1 = new StringBuilder();
    expectedValue1.append(expectedValue.toString());
    expectedValue1.append("(Strict SLD Latest)");
    assertTrue(expectedValue1.toString().compareTo(actualValue) == 0);
    VersionData geoServerVOMin = VersionData.getDecodedString("com.sldeditor.common.vendoroption.GeoServerVendorOption@2.4.2");
    VersionData geoServerVOMax = VersionData.getDecodedString("com.sldeditor.common.vendoroption.GeoServerVendorOption@2.9.0");
    VendorOptionVersion geoServerVOV = new VendorOptionVersion(GeoServerVendorOption.class, geoServerVOMin, geoServerVOMax);
    actualValue = VendorOptionManager.getInstance().getTitle(geoServerVOV);
    StringBuilder expectedValue2 = new StringBuilder();
    expectedValue2.append(expectedValue.toString());
    expectedValue2.append("(GeoServer 2.4.2-2.9.0)");
    assertTrue(expectedValue2.toString().compareTo(actualValue) == 0);
}
Also used : ParseXML(com.sldeditor.common.xml.ParseXML) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Test(org.junit.Test)

Example 18 with VersionData

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

the class VendorOptionManagerTest method testLoadSLDFile.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getVendorOptionVersion()}.
 */
@Test
public void testLoadSLDFile() {
    VendorOptionManager.destroyInstance();
    PrefData prefData = PrefManager.getInstance().getPrefData();
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    VersionData actualPrefVO = VersionData.decode(GeoServerVendorOption.class, "2.4.2");
    vendorOptionList.add(actualPrefVO);
    prefData.setVendorOptionVersionList(vendorOptionList);
    PrefManager.getInstance().setPrefData(prefData);
    SLDData sldData = new SLDData(null, null);
    StyledLayerDescriptor sld = null;
    VendorOptionManager.getInstance().addVendorOptionListener(obj);
    obj.vendorOptionVersionsList.clear();
    // No SLD Editor file, SLD is empty so it should you PrefManager default set above
    VendorOptionManager.getInstance().loadSLDFile(null, sld, sldData);
    assertEquals(1, obj.vendorOptionVersionsList.size());
    assertEquals(actualPrefVO, obj.vendorOptionVersionsList.get(0));
    // No SLD Editor file, SLD contains PointSymboliser with vendor
    // option so it should use the SLD vendor option
    obj.vendorOptionVersionsList.clear();
    sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);
    PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    VersionData testVersionData = VersionData.decode(GeoServerVendorOption.class, "2.8.0");
    VendorOptionManager.getInstance().loadSLDFile(new GetMinimumVersionInterface() {

        @Override
        public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
            VendorOptionInfo vendorOptionInfo = new VendorOptionInfo("qgis://", new VendorOptionVersion(testVersionData.getVendorOptionType(), testVersionData), "");
            VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, vendorOptionInfo);
            vendorOptionsPresentList.add(voPresent);
        }
    }, sld, sldData);
    assertEquals(1, obj.vendorOptionVersionsList.size());
    assertEquals(testVersionData, obj.vendorOptionVersionsList.get(0));
    // Now set the SLD Editor file vendor option
    obj.vendorOptionVersionsList.clear();
    List<VersionData> sldEditorVendorOptionList = new ArrayList<VersionData>();
    VersionData testVersionData2 = VersionData.decode(GeoServerVendorOption.class, "2.10.0");
    sldEditorVendorOptionList.add(testVersionData2);
    sldEditorVendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
    sldData.setVendorOptionList(sldEditorVendorOptionList);
    sldData.setSldEditorFile(new File("."));
    VendorOptionManager.getInstance().loadSLDFile(new GetMinimumVersionInterface() {

        @Override
        public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
            VendorOptionInfo vendorOptionInfo = new VendorOptionInfo("qgis://", new VendorOptionVersion(testVersionData.getVendorOptionType(), testVersionData), "");
            VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, vendorOptionInfo);
            vendorOptionsPresentList.add(voPresent);
        }
    }, sld, sldData);
    Collections.sort(obj.vendorOptionVersionsList);
    assertEquals(2, obj.vendorOptionVersionsList.size());
    assertEquals(testVersionData2, obj.vendorOptionVersionsList.get(obj.vendorOptionVersionsList.size() - 1));
    // Increase code coverage
    VendorOptionManager.getInstance().loadSLDFile(null, null, null);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) PointSymbolizer(org.geotools.styling.PointSymbolizer) VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) ArrayList(java.util.ArrayList) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) PrefData(com.sldeditor.common.preferences.PrefData) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) GetMinimumVersionInterface(com.sldeditor.ui.panels.GetMinimumVersionInterface) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) VendorOptionInfo(com.sldeditor.common.vendoroption.info.VendorOptionInfo) File(java.io.File) Test(org.junit.Test)

Example 19 with VersionData

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

the class VendorOptionVersionTest method testVendorOptionVersionClassOfQVersionData.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionVersion#VendorOptionVersion(java.lang.Class, com.sldeditor.common.vendoroption.VersionData)}.
 */
@Test
public void testVendorOptionVersionClassOfQVersionData() {
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VendorOptionVersion vo = new VendorOptionVersion(getClass(), versionDataMin);
    assertEquals(versionDataMin, vo.getLatest());
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Test(org.junit.Test)

Example 20 with VersionData

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

the class VendorOptionVersionTest method testFromString.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionVersion#fromString(java.lang.String)}.
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionVersion#toString()}.
 */
@Test
public void testFromString() {
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
    VendorOptionVersion vo = new VendorOptionVersion(getClass(), versionDataMin, versionDataMax);
    String actualString = vo.toString();
    VendorOptionVersion decoded = VendorOptionVersion.fromString(actualString);
    assertEquals(vo.getLatest(), decoded.getLatest());
    assertEquals(vo.toString(), decoded.toString());
}
Also used : 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