Search in sources :

Example 1 with FieldConfigTimePeriod

use of com.sldeditor.ui.detail.config.FieldConfigTimePeriod 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 2 with FieldConfigTimePeriod

use of com.sldeditor.ui.detail.config.FieldConfigTimePeriod 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 3 with FieldConfigTimePeriod

use of com.sldeditor.ui.detail.config.FieldConfigTimePeriod 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 4 with FieldConfigTimePeriod

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

the class FieldConfigTimePeriodTest method testSetVisible.

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

Example 5 with FieldConfigTimePeriod

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

the class FieldConfigTimePeriodTest method testCreateCopy.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testCreateCopy() {
    boolean valueOnly = true;
    class TestFieldConfigTimePeriod extends FieldConfigTimePeriod {

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

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigTimePeriod field = new TestFieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, valueOnly));
    FieldConfigTimePeriod copy = (FieldConfigTimePeriod) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigTimePeriod) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertNull(copy.getLabel());
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigTimePeriod(com.sldeditor.ui.detail.config.FieldConfigTimePeriod) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 FieldConfigTimePeriod (com.sldeditor.ui.detail.config.FieldConfigTimePeriod)7 Test (org.junit.Test)7 TimePeriod (com.sldeditor.filter.v2.function.temporal.TimePeriod)2 Duration (com.sldeditor.filter.v2.function.temporal.Duration)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 DefaultInstant (org.geotools.temporal.object.DefaultInstant)1 DefaultPeriod (org.geotools.temporal.object.DefaultPeriod)1 DefaultPosition (org.geotools.temporal.object.DefaultPosition)1 Expression (org.opengis.filter.expression.Expression)1