Search in sources :

Example 1 with DummyInlineSLDFile2

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

Aggregations

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