Search in sources :

Example 21 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class ExtractAttributesTest method testNotFilter.

@Test
public void testNotFilter() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
    StyledLayerDescriptor sld = createTestSLD(dummy);
    List<Rule> ruleList = getRuleList(sld);
    ExtractAttributes extract = new ExtractAttributes();
    Rule rule = DefaultSymbols.createNewRule();
    // Try with NOT
    extract = new ExtractAttributes();
    Filter filter = ff.not(ff.greater(ff.literal(42.1), ff.property("dble")));
    rule.setFilter(filter);
    ruleList.clear();
    ruleList.add(rule);
    extract.extractDefaultFields(sld);
    // Check fields extracted ok
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertEquals(1, actualFieldnameList.size());
    DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
    assertEquals(Double.class, dataSourceField.getType());
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Filter(org.opengis.filter.Filter) ExtractAttributes(com.sldeditor.datasource.impl.ExtractAttributes) Rule(org.geotools.styling.Rule) Test(org.junit.Test)

Example 22 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class SLDDataTest method testFieldList.

/**
 * Test field list.
 */
@Test
public void testFieldList() {
    List<DataSourceAttributeData> fieldList = new ArrayList<DataSourceAttributeData>();
    fieldList.add(new DataSourceAttributeData("Field 1", String.class, null));
    fieldList.add(new DataSourceAttributeData("Field 2", Double.class, null));
    SLDData data = new SLDData(null, null);
    data.setFieldList(fieldList);
    assertEquals(fieldList, data.getFieldList());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class DataSourceAttributeDataTest method testSetValue.

/**
 * Test method for {@link com.sldeditor.datasource.attribute.DataSourceAttributeData#setValue(java.lang.Object)}.
 */
@Test
public void testSetValue() {
    String expectedName = "test name";
    Class<?> expectedType = Integer.class;
    Object expectedValue1 = Integer.valueOf(42);
    DataSourceAttributeData dsa = new DataSourceAttributeData(expectedName, expectedType, expectedValue1);
    Object expectedValue2 = Integer.valueOf(69);
    dsa.setValue(expectedValue2);
    assertEquals(expectedValue2, dsa.getValue());
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Test(org.junit.Test)

Example 24 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class DataSourceAttributeDataTest method testDataSourceAttributeDataDataSourceAttributeData.

/**
 * Test method for {@link com.sldeditor.datasource.attribute.DataSourceAttributeData#DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData)}.
 */
@Test
public void testDataSourceAttributeDataDataSourceAttributeData() {
    String expectedName = "test name";
    Class<?> expectedType = Integer.class;
    Object expectedValue = Integer.valueOf(42);
    DataSourceAttributeData dsa = new DataSourceAttributeData(expectedName, expectedType, expectedValue);
    DataSourceAttributeData copyDsa = new DataSourceAttributeData(dsa);
    assertTrue(expectedName.compareTo(copyDsa.getName()) == 0);
    assertEquals(expectedType, copyDsa.getType());
    assertEquals(expectedValue, copyDsa.getValue());
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Test(org.junit.Test)

Example 25 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class DataSourceAttributeDataTest method testClone.

/**
 * Test method for {@link com.sldeditor.datasource.attribute.DataSourceAttributeData#clone()}.
 */
@Test
public void testClone() {
    String expectedName = "test name";
    Class<?> expectedType = Integer.class;
    Object expectedValue = Integer.valueOf(42);
    DataSourceAttributeData dsa = new DataSourceAttributeData(expectedName, expectedType, expectedValue);
    DataSourceAttributeData cloneDsa = dsa.clone();
    assertTrue(expectedName.compareTo(cloneDsa.getName()) == 0);
    assertEquals(expectedType, cloneDsa.getType());
    assertEquals(expectedValue, cloneDsa.getValue());
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Test(org.junit.Test)

Aggregations

DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)40 Test (org.junit.Test)23 ExtractAttributes (com.sldeditor.datasource.impl.ExtractAttributes)12 ArrayList (java.util.ArrayList)11 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)10 Rule (org.geotools.styling.Rule)8 Filter (org.opengis.filter.Filter)8 LineString (com.vividsolutions.jts.geom.LineString)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)4 DataSourceAttributeList (com.sldeditor.datasource.attribute.DataSourceAttributeList)4 Point (com.vividsolutions.jts.geom.Point)4 IOException (java.io.IOException)4 SimpleFeature (org.opengis.feature.simple.SimpleFeature)4 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)4 DataSourceImpl (com.sldeditor.datasource.impl.DataSourceImpl)3 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)3 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)3 SLDData (com.sldeditor.common.data.SLDData)2 CreateDataSourceInterface (com.sldeditor.datasource.impl.CreateDataSourceInterface)2