Search in sources :

Example 21 with UserLayer

use of org.geotools.styling.UserLayer 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 22 with UserLayer

use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.

the class InLineFeatureModelTest method testSetValueAtObjectIntInt.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#setValueAt(java.lang.Object, int, int)}.
 */
@Test
public void testSetValueAtObjectIntInt() {
    DummyInlineFeatureUpdated listener = new DummyInlineFeatureUpdated();
    InLineFeatureModel model = new InLineFeatureModel(listener);
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer = (UserLayer) testData1.getSLD().layers().get(0);
    model.populate(userLayer);
    assertEquals(1, model.getRowCount());
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    model.setValueAt(null, -1, 0);
    model.setValueAt(null, 5, 0);
    model.setValueAt(null, 0, -1);
    model.setValueAt(null, 0, 5);
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    String expectedValue = "test value";
    model.setValueAt(expectedValue, 0, 1);
    String actualValue = (String) model.getValueAt(0, 1);
    assertTrue(actualValue.compareTo(expectedValue) == 0);
    assertTrue(listener.hasInlineFeatureUpdatedCalled());
}
Also used : InLineFeatureModel(com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel) DummyInlineSLDFile(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile) UserLayer(org.geotools.styling.UserLayer) Test(org.junit.Test)

Example 23 with UserLayer

use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.

the class InLineFeatureModelTest method testGetFeatureCollection.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#getFeatureCollection()}.
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#getInlineFeatures()}.
 */
@Test
public void testGetFeatureCollection() {
    DummyInlineFeatureUpdated listener = new DummyInlineFeatureUpdated();
    InLineFeatureModel model = new InLineFeatureModel(listener);
    assertNull(model.getFeatureCollection());
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer = (UserLayer) testData1.getSLD().layers().get(0);
    model.populate(userLayer);
    assertNotNull(model.getFeatureCollection());
    assertNotNull(model.getInlineFeatures());
}
Also used : InLineFeatureModel(com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel) DummyInlineSLDFile(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile) UserLayer(org.geotools.styling.UserLayer) Test(org.junit.Test)

Example 24 with UserLayer

use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.

the class InLineFeatureModelTest method testGetValueAt.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#getValueAt(int, int)}.
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#populate(org.geotools.styling.UserLayer)}.
 */
@Test
public void testGetValueAt() {
    DummyInlineFeatureUpdated listener = new DummyInlineFeatureUpdated();
    InLineFeatureModel model = new InLineFeatureModel(listener);
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer = (UserLayer) testData1.getSLD().layers().get(0);
    model.populate(userLayer);
    assertEquals(1, model.getRowCount());
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    assertNull(model.getValueAt(-1, 0));
    assertNull(model.getValueAt(5, 0));
    assertNull(model.getValueAt(0, -1));
    assertNull(model.getValueAt(0, 5));
    String actualValue = (String) model.getValueAt(0, 1);
    assertTrue(actualValue.compareTo("Pacific NW") == 0);
}
Also used : InLineFeatureModel(com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel) DummyInlineSLDFile(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile) UserLayer(org.geotools.styling.UserLayer) Test(org.junit.Test)

Example 25 with UserLayer

use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.

the class InLineFeatureModelTest method testGetRowCount.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#getRowCount()}.
 */
@Test
public void testGetRowCount() {
    InLineFeatureModel model = new InLineFeatureModel(null);
    assertEquals(0, model.getRowCount());
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer = (UserLayer) testData1.getSLD().layers().get(0);
    model.populate(userLayer);
    assertEquals(2, model.getColumnCount());
}
Also used : InLineFeatureModel(com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel) DummyInlineSLDFile(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile) UserLayer(org.geotools.styling.UserLayer) Test(org.junit.Test)

Aggregations

UserLayer (org.geotools.styling.UserLayer)29 Test (org.junit.Test)17 DummyInlineSLDFile (com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile)10 InLineFeatureModel (com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel)8 Style (org.geotools.styling.Style)6 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)6 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)4 NamedLayer (org.geotools.styling.NamedLayer)4 Rule (org.geotools.styling.Rule)4 StyledLayer (org.geotools.styling.StyledLayer)4 UndoEvent (com.sldeditor.common.undo.UndoEvent)3 IOException (java.io.IOException)3 FeatureSource (org.geotools.data.FeatureSource)3 LineSymbolizer (org.geotools.styling.LineSymbolizer)3 PointSymbolizer (org.geotools.styling.PointSymbolizer)3 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)3 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)3 SLDData (com.sldeditor.common.data.SLDData)2 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 FieldConfigInlineFeature (com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature)2