Search in sources :

Example 6 with VendorOptionVersion

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

the class VendorOptionManagerTest method testGetDefaultVendorOptionVersion.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getDefaultVendorOptionVersion()}.
 */
@Test
public void testGetDefaultVendorOptionVersion() {
    VendorOptionVersion vo = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
    assertEquals("Latest", vo.getLatest().getVersionString());
}
Also used : VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Test(org.junit.Test)

Example 7 with VendorOptionVersion

use of com.sldeditor.common.vendoroption.VendorOptionVersion 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 8 with VendorOptionVersion

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

the class VendorOptionManagerTest method testGetVendorOptionVersionClassOfQ.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getVendorOptionVersion(java.lang.Class)}.
 */
@Test
public void testGetVendorOptionVersionClassOfQ() {
    assertNull(VendorOptionManager.getInstance().getVendorOptionVersion(null));
    VendorOptionVersion vo = VendorOptionManager.getInstance().getVendorOptionVersion(NoVendorOption.class);
    assertEquals("Latest", vo.getLatest().getVersionString());
    VendorOptionVersion voGS = VendorOptionManager.getInstance().getVendorOptionVersion(GeoServerVendorOption.class);
    assertEquals("Latest", voGS.getLatest().getVersionString());
}
Also used : VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Test(org.junit.Test)

Example 9 with VendorOptionVersion

use of com.sldeditor.common.vendoroption.VendorOptionVersion 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 10 with VendorOptionVersion

use of com.sldeditor.common.vendoroption.VendorOptionVersion 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)

Aggregations

VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)23 Test (org.junit.Test)16 VersionData (com.sldeditor.common.vendoroption.VersionData)13 ArrayList (java.util.ArrayList)8 VendorOptionPresent (com.sldeditor.common.vendoroption.minversion.VendorOptionPresent)4 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)4 VendorOptionInfo (com.sldeditor.common.vendoroption.info.VendorOptionInfo)3 FeatureTypeStyleDetails (com.sldeditor.ui.detail.FeatureTypeStyleDetails)3 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)3 GeoServerVendorOption (com.sldeditor.common.vendoroption.GeoServerVendorOption)2 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)2 File (java.io.File)2 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)1 SLDData (com.sldeditor.common.data.SLDData)1 PrefData (com.sldeditor.common.preferences.PrefData)1 VendorOptionInfoModel (com.sldeditor.common.vendoroption.info.VendorOptionInfoModel)1 ParseXML (com.sldeditor.common.xml.ParseXML)1 XMLFieldConfigString (com.sldeditor.common.xml.ui.XMLFieldConfigString)1 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)1 EnvVar (com.sldeditor.filter.v2.envvar.EnvVar)1