Search in sources :

Example 1 with UserLayerDetails

use of com.sldeditor.ui.detail.UserLayerDetails in project sldeditor by robward-scisys.

the class UserLayerDetailsTest method testUserLayerDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#UserLayerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#preLoadSymbol()}.
 */
@Test
public void testUserLayerDetails() {
    UserLayerDetails panel = new UserLayerDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    UserLayer userLayer = DefaultSymbols.createNewUserLayer();
    String expectedUserValue = "user layer test value";
    userLayer.setName(expectedUserValue);
    userLayer.addUserStyle(DefaultSymbols.createNewStyle());
    sld.layers().add(userLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(userLayer);
    SelectedSymbol.getInstance().setStyledLayer(userLayer);
    panel.populate(SelectedSymbol.getInstance());
    panel.dataChanged(null);
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(FieldIdEnum.INLINE_FEATURE);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertTrue(expectedUserValue.compareTo(nameField.getStringValue()) == 0);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
    assertTrue("".compareTo(nameField.getStringValue()) == 0);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) UserLayerDetails(com.sldeditor.ui.detail.UserLayerDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) UserLayer(org.geotools.styling.UserLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Aggregations

GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 UserLayerDetails (com.sldeditor.ui.detail.UserLayerDetails)1 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)1 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)1 UserLayer (org.geotools.styling.UserLayer)1 Test (org.junit.Test)1