Search in sources :

Example 6 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile 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 DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile 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 8 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile 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 9 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile 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 10 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile 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

DummyInlineSLDFile (com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile)10 UserLayer (org.geotools.styling.UserLayer)10 Test (org.junit.Test)10 InLineFeatureModel (com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel)8 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 FieldConfigInlineFeature (com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 DummyInlineSLDFile2 (com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile2)1 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)1