Search in sources :

Example 1 with FieldConfigGeometryField

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

the class FieldConfigGeometryFieldTest method testAttributeSelection.

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

Example 2 with FieldConfigGeometryField

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

the class FieldConfigGeometryFieldTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#internal_setEnabled(boolean)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#isEnabled()}.
 */
@Test
public void testSetEnabled() {
    FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
    // Text field will not have been created
    boolean expectedValue = true;
    field.internal_setEnabled(expectedValue);
    assertTrue(field.isEnabled());
    // Create text field
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertTrue(field.isEnabled());
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigGeometryField(com.sldeditor.ui.detail.config.FieldConfigGeometryField) Test(org.junit.Test)

Example 3 with FieldConfigGeometryField

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

the class FieldConfigGeometryFieldTest method testSetVisible.

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

Example 4 with FieldConfigGeometryField

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

the class FieldConfigGeometryFieldTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#generateExpression()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#populateExpression(java.lang.Object)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#populateField(java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    class TestFieldConfigGeometryField extends FieldConfigGeometryField {

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

        public Expression callGenerateExpression() {
            return generateExpression();
        }
    }
    TestFieldConfigGeometryField field = new TestFieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", false));
    Expression actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);
    field.createUI();
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    String expectedValue = "";
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedValue.compareTo(actualExpression.toString()) == 0);
    // Attribute expression
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Expression expectedExpression = ff.property(testDataSource.getDefaultGeometryField());
    field.populateExpression(expectedExpression);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedExpression.toString().compareTo(actualExpression.toString()) == 0);
    // Literal expression
    expectedExpression = ff.literal(testDataSource.getDefaultGeometryField());
    field.populateExpression(expectedExpression);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedExpression.toString().compareTo(actualExpression.toString()) == 0);
    field.populateField((String) null);
    String stringValue = field.getStringValue();
    assertNull(stringValue);
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigGeometryField(com.sldeditor.ui.detail.config.FieldConfigGeometryField) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 5 with FieldConfigGeometryField

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

the class FieldConfigGeometryFieldTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#dataSourceLoaded(com.sldeditor.datasource.impl.GeometryTypeEnum, boolean)}.
 */
@Test
public void testUndoAction() {
    FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.undoAction(null);
    field.redoAction(null);
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    String expectedTestValue = testDataSource.getDefaultGeometryField();
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedTestValue);
    assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
    String expectedUndoTestValue = "";
    String expectedRedoTestValue = testDataSource.getDefaultGeometryField();
    UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
    field.undoAction(undoEvent);
    assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
    field.redoAction(undoEvent);
    assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigGeometryField(com.sldeditor.ui.detail.config.FieldConfigGeometryField) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 FieldConfigGeometryField (com.sldeditor.ui.detail.config.FieldConfigGeometryField)7 Test (org.junit.Test)7 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)3 CreateDataSourceInterface (com.sldeditor.datasource.impl.CreateDataSourceInterface)3 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 FilterFactory (org.opengis.filter.FilterFactory)1 Expression (org.opengis.filter.expression.Expression)1