Search in sources :

Example 1 with FieldConfigDSProperties

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

the class FieldConfigDSPropertiesTest method testCreateCopy.

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

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

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigDSProperties field = new TestFieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    FieldConfigDSProperties copy = (FieldConfigDSProperties) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigDSProperties) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigDSProperties(com.sldeditor.ui.detail.config.FieldConfigDSProperties) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 2 with FieldConfigDSProperties

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

the class FieldConfigDSPropertiesTest method testSetVisible.

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

Example 3 with FieldConfigDSProperties

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

the class FieldConfigDSPropertiesTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    assertNull(field.getStringValue());
    // Now create the ui
    field.createUI();
    String expectedValue1 = "Date_2";
    field.populateField(expectedValue1);
    String expectedValue2 = "String_3";
    field.populateField(expectedValue2);
    UndoManager.getInstance().undo();
    String actualValueString = field.getStringValue();
    assertTrue(expectedValue1.compareTo(actualValueString) == 0);
    UndoManager.getInstance().redo();
    actualValueString = field.getStringValue();
    assertTrue(expectedValue2.compareTo(actualValueString) == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
    DataSourceFactory.reset();
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigDSProperties(com.sldeditor.ui.detail.config.FieldConfigDSProperties) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 4 with FieldConfigDSProperties

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

the class FieldConfigDSPropertiesTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#internal_setEnabled(boolean)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#isEnabled()}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    // 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);
    assertEquals(expectedValue, field.isEnabled());
    // Has attribute/expression dropdown
    valueOnly = false;
    FieldConfigDSProperties field2 = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    // Text field will not have been created
    expectedValue = true;
    field2.internal_setEnabled(expectedValue);
    assertTrue(field2.isEnabled());
    // Create text field
    field2.createUI();
    assertEquals(expectedValue, field2.isEnabled());
    expectedValue = true;
    field2.internal_setEnabled(expectedValue);
    // Actual value is coming from the attribute panel, not the text field
    assertEquals(expectedValue, field2.isEnabled());
}
Also used : FieldConfigDSProperties(com.sldeditor.ui.detail.config.FieldConfigDSProperties) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 5 with FieldConfigDSProperties

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

the class FieldConfigDSPropertiesTest method testGenerateExpression.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#generateExpression()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#populateField(java.lang.String)}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#getEnumValue()}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    boolean valueOnly = true;
    FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    assertNull(field.getStringValue());
    // Try without creating the ui
    field.populateExpression(null);
    field.populateField((String) null);
    field.setTestValue(null, (String) null);
    // Now create the ui
    field.createUI();
    field.createUI();
    String expectedValue1 = "String_2";
    field.populateField(expectedValue1);
    String actualValueString = field.getStringValue();
    assertTrue(expectedValue1.compareTo(actualValueString) == 0);
    String expectedValue2 = "String_1";
    field.populateExpression(expectedValue2);
    actualValueString = field.getStringValue();
    assertTrue(expectedValue2.compareTo(actualValueString) == 0);
    String expectedValue3 = "Date_2";
    field.populateExpression(CommonFactoryFinder.getFilterFactory().property(expectedValue3));
    actualValueString = field.getStringValue();
    assertTrue(expectedValue3.compareTo(actualValueString) == 0);
    String expectedValue4 = "Date_1";
    field.populateExpression(CommonFactoryFinder.getFilterFactory().literal(expectedValue4));
    actualValueString = field.getStringValue();
    assertTrue(expectedValue4.compareTo(actualValueString) == 0);
    DataSourceFactory.reset();
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) FieldConfigDSProperties(com.sldeditor.ui.detail.config.FieldConfigDSProperties) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)6 FieldConfigDSProperties (com.sldeditor.ui.detail.config.FieldConfigDSProperties)6 Test (org.junit.Test)6 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)2 CreateDataSourceInterface (com.sldeditor.datasource.impl.CreateDataSourceInterface)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1