Search in sources :

Example 56 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigTimePeriodTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#generateExpression()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#populateField(com.sldeditor.filter.v2.function.temporal.TimePeriod)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    class TestFieldConfigTimePeriod extends FieldConfigTimePeriod {

        public TestFieldConfigTimePeriod(FieldConfigCommonData commonData) {
            super(commonData);
        }

        public Expression callGenerateExpression() {
            return generateExpression();
        }
    }
    TestFieldConfigTimePeriod field = new TestFieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, valueOnly));
    Expression actualExpression = field.callGenerateExpression();
    assertNotNull(actualExpression);
    // Try string values - erroneous
    field.createUI();
    field.createUI();
    String expectedValue = "test string value";
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
    actualExpression = field.callGenerateExpression();
    assertNotNull(actualExpression);
    expectedValue = "test string value as expression";
    field.populateExpression(expectedValue);
    actualExpression = field.callGenerateExpression();
    assertNotNull(actualExpression);
    // Time period values
    String timePeriod = "07-07-2016T17:42:27Z / 08-07-2016T17:42:27Z";
    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    field.setTestValue(FieldIdEnum.UNKNOWN, timePeriod);
    actualExpression = field.callGenerateExpression();
    assertTrue(timePeriod.compareTo(actualExpression.toString()) == 0);
    TimePeriod period = new TimePeriod();
    Duration start = new Duration();
    start.setDuration(0, 0, 1, 0, 32, 9);
    period.setStart(start);
    field.populateField((TimePeriod) null);
    field.populateField(period);
    actualExpression = field.callGenerateExpression();
    String expectedPeriod = period.getString();
    assertTrue(expectedPeriod.compareTo(actualExpression.toString()) == 0);
    TimePeriod timePeriodObj = new TimePeriod();
    timePeriodObj.decode(timePeriod);
    DefaultPeriod defaultPeriod = new DefaultPeriod(new DefaultInstant(new DefaultPosition(timePeriodObj.getStart().getDate())), new DefaultInstant(new DefaultPosition(timePeriodObj.getEnd().getDate())));
    field.populateExpression(defaultPeriod);
    actualExpression = field.callGenerateExpression();
    assertTrue(timePeriod.compareTo(actualExpression.toString()) == 0);
}
Also used : Expression(org.opengis.filter.expression.Expression) DefaultPeriod(org.geotools.temporal.object.DefaultPeriod) FieldConfigTimePeriod(com.sldeditor.ui.detail.config.FieldConfigTimePeriod) TimePeriod(com.sldeditor.filter.v2.function.temporal.TimePeriod) FieldConfigTimePeriod(com.sldeditor.ui.detail.config.FieldConfigTimePeriod) DefaultPosition(org.geotools.temporal.object.DefaultPosition) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) DefaultInstant(org.geotools.temporal.object.DefaultInstant) Duration(com.sldeditor.filter.v2.function.temporal.Duration) Test(org.junit.Test)

Example 57 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigTimePeriodTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigTimePeriod field = new FieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, valueOnly));
    field.attributeSelection(null);
// Does nothing
}
Also used : FieldConfigTimePeriod(com.sldeditor.ui.detail.config.FieldConfigTimePeriod) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 58 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigTimePeriodTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigTimePeriod field = new FieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, true));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    // Time period values
    String timePeriod1 = "07-07-2016T17:42:27Z / 07-07-2016T17:42:27Z";
    TimePeriod period1 = new TimePeriod();
    period1.decode(timePeriod1);
    // CHECKSTYLE:OFF
    String expectedPeriod1 = period1.getString();
    // CHECKSTYLE:ON
    field.populateField(period1);
    String timePeriod2 = "P 1 D 32 M 9 S / 08-07-2016T09:42:06Z";
    TimePeriod period2 = new TimePeriod();
    period2.decode(timePeriod2);
    // CHECKSTYLE:OFF
    String expectedPeriod2 = period2.getString();
    // CHECKSTYLE:ON
    field.populateField(period2);
    UndoManager.getInstance().undo();
    String actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedPeriod1) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(actualValue.replace(" ", "").compareTo(expectedPeriod2.replace(" ", "")) == 0);
}
Also used : FieldConfigTimePeriod(com.sldeditor.ui.detail.config.FieldConfigTimePeriod) TimePeriod(com.sldeditor.filter.v2.function.temporal.TimePeriod) FieldConfigTimePeriod(com.sldeditor.ui.detail.config.FieldConfigTimePeriod) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 59 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigVendorOptionTest method testAddToOptionBox.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigVendorOption#addToOptionBox(javax.swing.Box)}.
 */
@Test
public void testAddToOptionBox() {
    FieldConfigVendorOption field = new FieldConfigVendorOption(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", false), null);
    field.addToOptionBox(null);
}
Also used : FieldConfigVendorOption(com.sldeditor.ui.detail.config.FieldConfigVendorOption) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 60 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigVendorOptionTest method testVendorOptionsUpdated.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigVendorOption#vendorOptionsUpdated(java.util.List)}.
 */
@Test
public void testVendorOptionsUpdated() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    VendorOptionRasterFactory vendorOptionRasterFactory = new VendorOptionRasterFactory(getClass(), panel);
    // CHECKSTYLE:OFF
    List<VendorOptionInterface> veList = vendorOptionRasterFactory.getVendorOptionList("com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeOverall");
    for (VendorOptionInterface extension : veList) {
        extension.setParentPanel(panel);
    }
    FieldConfigVendorOption field = new FieldConfigVendorOption(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", false), veList);
    field.vendorOptionsUpdated(null);
    field.createUI();
    List<VersionData> vendorOptionVersionsList = new ArrayList<VersionData>();
    vendorOptionVersionsList.add(VersionData.getLatestVersion(GeoServerVendorOption.class));
    field.vendorOptionsUpdated(vendorOptionVersionsList);
}
Also used : VendorOptionRasterFactory(com.sldeditor.ui.detail.vendor.geoserver.raster.VendorOptionRasterFactory) GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) FieldConfigVendorOption(com.sldeditor.ui.detail.config.FieldConfigVendorOption) VersionData(com.sldeditor.common.vendoroption.VersionData) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) ArrayList(java.util.ArrayList) VendorOptionInterface(com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)322 Test (org.junit.Test)316 Geometry (com.vividsolutions.jts.geom.Geometry)69 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)54 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)44 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)38 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)34 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)24 StyleBuilder (org.geotools.styling.StyleBuilder)24 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)22 UndoEvent (com.sldeditor.common.undo.UndoEvent)20 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)20 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)20 Expression (org.opengis.filter.expression.Expression)20 FieldConfigWindBarbs (com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs)18 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)17 FieldConfigTTF (com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF)17 FieldConfigFilename (com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename)16 FieldConfigArrow (com.sldeditor.ui.detail.vendor.geoserver.marker.arrow.FieldConfigArrow)16 FieldConfigWKT (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.FieldConfigWKT)16