use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class DataSourceAttributeDataTest method testDataSourceAttributeDataNameClassOfQObject.
/**
* Test method for {@link com.sldeditor.datasource.attribute.DataSourceAttributeData#DataSourceAttributeData(org.opengis.feature.type.Name, java.lang.Class, java.lang.Object)}.
*/
@Test
public void testDataSourceAttributeDataNameClassOfQObject() {
String expectedName = "test name";
Class<?> expectedType = Integer.class;
Object expectedValue = Integer.valueOf(42);
DataSourceAttributeData dsa = new DataSourceAttributeData(expectedName, expectedType, expectedValue);
assertTrue(expectedName.compareTo(dsa.getName()) == 0);
assertEquals(expectedType, dsa.getType());
assertEquals(expectedValue, dsa.getValue());
}
use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class DataSourceAttributeDataTest method testSetName.
/**
* Test method for {@link com.sldeditor.datasource.attribute.DataSourceAttributeData#setName(org.opengis.feature.type.Name)}.
*/
@Test
public void testSetName() {
String expectedName1 = "test name";
Class<?> expectedType = Integer.class;
Object expectedValue = Integer.valueOf(42);
DataSourceAttributeData dsa = new DataSourceAttributeData(expectedName1, expectedType, expectedValue);
String expectedName2 = "updated test name";
dsa.setName(expectedName2);
assertTrue(expectedName2.compareTo(dsa.getName()) == 0);
}
use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class DataSourceAttributeListTest method testDataSourceAttributeList.
/**
* Test method for
* {@link com.sldeditor.datasource.attribute.DataSourceAttributeList#DataSourceAttributeList()}.
*/
@Test
public void testDataSourceAttributeList() {
List<DataSourceAttributeData> expectedAttributeList = new ArrayList<DataSourceAttributeData>();
expectedAttributeList.add(new DataSourceAttributeData("field 1", String.class, "test value"));
expectedAttributeList.add(new DataSourceAttributeData("field 2", Double.class, 42.0));
expectedAttributeList.add(new DataSourceAttributeData("field 3", Integer.class, 22));
expectedAttributeList.add(new DataSourceAttributeData("field 4", Long.class, 454));
DataSourceAttributeList dsaList = new DataSourceAttributeList();
dsaList.setData(expectedAttributeList);
assertEquals(expectedAttributeList, dsaList.getData());
}
use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class DataSourceAttributeModelTest method testPopulate.
/**
* Test method for {@link com.sldeditor.datasource.config.DataSourceAttributeModel#populate(java.util.List)}.
* Test method for {@link com.sldeditor.datasource.config.DataSourceAttributeModel#getValueAt(int, int)}.
* Test method for {@link com.sldeditor.datasource.config.DataSourceAttributeModel#setValueAt(java.lang.Object, int, int)}.
* Test method for {@link com.sldeditor.datasource.config.DataSourceAttributeModel#retrieveData()}.
* Test method for {@link com.sldeditor.datasource.config.DataSourceAttributeModel#getAttributeData()}.
*/
@Test
public void testPopulate() {
DataSourceAttributeModel model = new DataSourceAttributeModel();
assertEquals(0, model.getRowCount());
String expectedName1 = "test name1";
Class<?> expectedType1 = Integer.class;
Object expectedValue1 = Integer.valueOf(42);
DataSourceAttributeData dsa1 = new DataSourceAttributeData(expectedName1, expectedType1, expectedValue1);
String expectedName2 = "test name2";
Class<?> expectedType2 = Integer.class;
Object expectedValue2 = Integer.valueOf(53);
DataSourceAttributeData dsa2 = new DataSourceAttributeData(expectedName2, expectedType2, expectedValue2);
List<DataSourceAttributeData> attributeList = new ArrayList<DataSourceAttributeData>();
attributeList.add(dsa1);
attributeList.add(dsa2);
model.populate(null);
model.populate(attributeList);
assertEquals(attributeList.size(), model.getRowCount());
// Check get value at
assertNull(model.getValueAt(0, 9));
assertNull(model.getValueAt(0, -1));
assertNull(model.getValueAt(-1, 0));
assertNull(model.getValueAt(attributeList.size(), 0));
assertTrue(expectedName1.compareTo(((String) model.getValueAt(0, 0))) == 0);
String actualType = (String) model.getValueAt(0, 1);
assertTrue(expectedType1.getSimpleName().compareTo(actualType) == 0);
assertEquals(expectedValue1, model.getValueAt(0, 2));
assertTrue(expectedName2.compareTo(((String) model.getValueAt(1, 0))) == 0);
actualType = (String) model.getValueAt(1, 1);
assertTrue(expectedType2.getSimpleName().compareTo(actualType) == 0);
assertEquals(expectedValue2, model.getValueAt(1, 2));
// Check set value at
// Set Value At - illegal values
model.setValueAt(null, 0, 9);
model.setValueAt(null, 0, -1);
model.setValueAt(null, -1, 0);
model.setValueAt(null, attributeList.size(), 0);
// Set Value At - legal values
String expectedName3 = "test name3";
Class<?> expectedType3 = String.class;
model.setValueAt(expectedName3, 0, 0);
assertTrue(expectedName3.compareTo(((String) model.getValueAt(0, 0))) == 0);
model.setValueAt(expectedType3.getSimpleName(), 1, 1);
actualType = (String) model.getValueAt(1, 1);
assertTrue(expectedType3.getSimpleName().compareTo(actualType) == 0);
Object expectedValue3 = String.valueOf(42);
model.setValueAt(expectedValue3, 1, 2);
assertEquals(expectedValue3, model.getValueAt(1, 2));
// Retrieve data
List<DataSourceAttributeData> actualAttributeList = model.retrieveData();
assertEquals(attributeList.size(), actualAttributeList.size());
assertTrue(expectedName3.compareTo(actualAttributeList.get(0).getName()) == 0);
assertEquals(expectedType3, actualAttributeList.get(1).getType());
assertEquals(expectedValue3, actualAttributeList.get(1).getValue());
// Get attribute data
DataSourceAttributeListInterface attributeDataImpl = model.getAttributeData();
actualAttributeList = attributeDataImpl.getData();
assertEquals(attributeList.size(), actualAttributeList.size());
assertTrue(expectedName3.compareTo(actualAttributeList.get(0).getName()) == 0);
assertEquals(expectedType3, actualAttributeList.get(1).getType());
assertEquals(expectedValue3, actualAttributeList.get(1).getValue());
// Try and set an unknown type
model.setValueAt(DataSourceAttributeModel.class.getSimpleName(), 0, 1);
assertNull(model.getValueAt(0, 1));
}
use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class CreateInternalDataSource method addFields.
/**
* Adds the fields.
*
* @param attrDescList the attribute descriptor list
* @param b the feature type builder
* @param fieldList the field list
*/
private void addFields(List<AttributeDescriptor> attrDescList, ExtendedSimpleFeatureTypeBuilder b, List<DataSourceAttributeData> fieldList) {
for (DataSourceAttributeData field : fieldList) {
Class<?> fieldType = field.getType();
if (!isGeometryField(field.getType())) {
AttributeDescriptor attributeDescriptor = b.createAttributeDescriptor(field.getName(), fieldType);
attrDescList.add(attributeDescriptor);
}
}
}
Aggregations