use of org.geotools.styling.UserLayer 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)));
}
use of org.geotools.styling.UserLayer 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());
}
use of org.geotools.styling.UserLayer 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);
}
use of org.geotools.styling.UserLayer 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());
}
use of org.geotools.styling.UserLayer 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));
}
Aggregations