Search in sources :

Example 6 with FieldConfigInlineFeature

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

the class FieldConfigInlineFeatureTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#generateExpression()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#populateExpression(java.lang.Object)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#populateField(java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    FieldConfigInlineFeature field = new FieldConfigInlineFeature(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, null, true));
    String testValue = null;
    field.populate(null);
    field.setTestValue(FieldIdEnum.UNKNOWN, testValue);
    field.populateField(testValue);
    field.createUI();
    UserLayer userLayer1 = DefaultSymbols.createNewUserLayer();
    field.populateField(userLayer1);
    String actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo("") == 0);
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer2 = (UserLayer) testData1.getSLD().layers().get(0);
    Controller.getInstance().setPopulating(true);
    field.populateField(userLayer2);
    String expectedValue2 = InlineFeatureUtils.getInlineFeaturesText(userLayer2);
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue2) == 0);
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue2);
    actualValue = field.getStringValue();
    // The fids are different
    assertTrue(expectedValue2.compareTo(actualValue) != 0);
    field.populateExpression((String) null);
    field.populateExpression((Integer) null);
    String expectedValue3 = "test inline value3";
    field.populateExpression(expectedValue3);
    Controller.getInstance().setPopulating(false);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) DummyInlineSLDFile(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile) UserLayer(org.geotools.styling.UserLayer) FieldConfigInlineFeature(com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature) Test(org.junit.Test)

Example 7 with FieldConfigInlineFeature

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

the class FieldConfigInlineFeatureTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#revertToDefaultValue()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#setDefaultValue(java.lang.String)}.
 */
@Test
public void testRevertToDefaultValue() {
    FieldConfigInlineFeature field = new FieldConfigInlineFeature(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, null, true));
    field.revertToDefaultValue();
    assertNull(field.getStringValue());
    field.createUI();
    field.revertToDefaultValue();
    assertNotNull(field.getStringValue());
    assertTrue(field.getStringValue().isEmpty());
    String expectedValue = "test inline data";
    field.setDefaultValue(expectedValue);
    field.revertToDefaultValue();
    assertNotNull(field.getStringValue());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigInlineFeature(com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature) Test(org.junit.Test)

Example 8 with FieldConfigInlineFeature

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

the class FieldConfigInlineFeatureTest method testAttributeSelection.

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

Aggregations

FieldConfigInlineFeature (com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature)8 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 Geometry (com.vividsolutions.jts.geom.Geometry)7 Test (org.junit.Test)7 DummyInlineSLDFile (com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile)2 UserLayer (org.geotools.styling.UserLayer)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 XMLFieldConfigBoolean (com.sldeditor.common.xml.ui.XMLFieldConfigBoolean)1 XMLFieldConfigColour (com.sldeditor.common.xml.ui.XMLFieldConfigColour)1 XMLFieldConfigColourMap (com.sldeditor.common.xml.ui.XMLFieldConfigColourMap)1 XMLFieldConfigDSProperties (com.sldeditor.common.xml.ui.XMLFieldConfigDSProperties)1 XMLFieldConfigDouble (com.sldeditor.common.xml.ui.XMLFieldConfigDouble)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigFeatureTypeConstraint (com.sldeditor.common.xml.ui.XMLFieldConfigFeatureTypeConstraint)1 XMLFieldConfigFont (com.sldeditor.common.xml.ui.XMLFieldConfigFont)1 XMLFieldConfigFontPreview (com.sldeditor.common.xml.ui.XMLFieldConfigFontPreview)1 XMLFieldConfigGeometry (com.sldeditor.common.xml.ui.XMLFieldConfigGeometry)1