Search in sources :

Example 1 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile in project sldeditor by robward-scisys.

the class FieldConfigInlineFeatureTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigInlineFeature field = new FieldConfigInlineFeature(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, null, true));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer1 = (UserLayer) testData1.getSLD().layers().get(0);
    field.populateField(userLayer1);
    String expectedValue1 = InlineFeatureUtils.getInlineFeaturesText(userLayer1);
    String actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue1) == 0);
    DummyInlineSLDFile2 testData2 = new DummyInlineSLDFile2();
    UserLayer userLayer2 = (UserLayer) testData2.getSLD().layers().get(0);
    field.populateField(userLayer2);
    String expectedValue2 = InlineFeatureUtils.getInlineFeaturesText(userLayer2);
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue2) == 0);
    UndoManager.getInstance().undo();
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue1) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue2) == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(42.0), Integer.valueOf(11)));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(454.0), Integer.valueOf(69)));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) DummyInlineSLDFile2(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile2) 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 2 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile in project sldeditor by robward-scisys.

the class InLineFeatureModelTest method testUpdateGeometry.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#updateGeometry(int, com.vividsolutions.jts.geom.Geometry)}.
 */
@Test
public void testUpdateGeometry() {
    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);
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    model.updateGeometry(0, null);
    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 3 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile in project sldeditor by robward-scisys.

the class InLineFeatureModelTest method testUpdateCRS.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#updateCRS(com.sldeditor.ui.widgets.ValueComboBoxData)}.
 */
@Test
public void testUpdateCRS() {
    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);
    model.updateCRS(null);
    assertNull(userLayer.getInlineFeatureType().getGeometryDescriptor().getCoordinateReferenceSystem());
    ValueComboBoxData expectedCRS = new ValueComboBoxData("EPSG:2000", "Test CRS", VendorOptionManager.getInstance().getDefaultVendorOptionVersion());
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    model.updateCRS(expectedCRS);
    assertTrue(listener.hasInlineFeatureUpdatedCalled());
    String newCRSCode = userLayer.getInlineFeatureType().getGeometryDescriptor().getCoordinateReferenceSystem().getCoordinateSystem().getName().getCode();
    assertNotNull(newCRSCode);
}
Also used : InLineFeatureModel(com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel) DummyInlineSLDFile(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile) UserLayer(org.geotools.styling.UserLayer) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

Example 4 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile in project sldeditor by robward-scisys.

the class InLineFeatureModelTest method testRemoveColumn.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#removeColumn(java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#getColumnNames()}.
 */
@Test
public void testRemoveColumn() {
    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);
    // Geometry column not returned, so column name count 1 less than column count
    assertEquals(2, model.getColumnCount());
    assertEquals(1, model.getColumnNames().size());
    model.addNewColumn();
    assertTrue(listener.hasInlineFeatureUpdatedCalled());
    assertEquals(2, model.getColumnNames().size());
    model.removeColumn("unknown column");
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    assertEquals(2, model.getColumnNames().size());
    // Remove the last column that was just added
    model.removeColumn(model.getColumnNames().get(model.getColumnNames().size() - 1));
    assertTrue(listener.hasInlineFeatureUpdatedCalled());
    assertEquals(1, model.getColumnNames().size());
}
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 5 with DummyInlineSLDFile

use of com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile in project sldeditor by robward-scisys.

the class InLineFeatureModelTest method testGetColumnCount.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#getColumnCount()}.
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#getColumnName(int)}.
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#addNewColumn()}.
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#getGeometryFieldIndex()}.
 */
@Test
public void testGetColumnCount() {
    DummyInlineFeatureUpdated listener = new DummyInlineFeatureUpdated();
    InLineFeatureModel model = new InLineFeatureModel(listener);
    assertEquals(0, model.getColumnCount());
    // Currently no feature collection
    model.addNewColumn();
    assertEquals(0, model.getColumnCount());
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer = (UserLayer) testData1.getSLD().layers().get(0);
    model.populate(userLayer);
    assertEquals(2, model.getColumnCount());
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    model.addNewColumn();
    assertEquals(3, model.getColumnCount());
    assertTrue(listener.hasInlineFeatureUpdatedCalled());
    assertEquals(0, model.getGeometryFieldIndex());
    assertNotNull(model.getColumnName(0));
    assertNull(model.getColumnName(-1));
    assertNull(model.getColumnName(5));
}
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