Search in sources :

Example 1 with FeatureTypeConstraintModel

use of com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel in project sldeditor by robward-scisys.

the class FeatureTypeConstraintModelTest method testPopulate.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#populate(java.util.List)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#removeEntries(int, int)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#getFeatureTypeConstraint(int)}.
 */
@Test
public void testPopulate() {
    TestModelUpdate testUpdate = new TestModelUpdate();
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeConstraintModel model = new FeatureTypeConstraintModel(testUpdate);
    List<FeatureTypeConstraint> ftcList = null;
    model.populate(ftcList);
    ftcList = new ArrayList<FeatureTypeConstraint>();
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc1", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc2", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc3", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc4", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc5", Filter.INCLUDE, new Extent[0]));
    model.populate(ftcList);
    List<FeatureTypeConstraint> actualList = model.getFeatureTypeConstraint();
    assertEquals(5, actualList.size());
    assertTrue(actualList.get(2).getFeatureTypeName().compareTo("ftc3") == 0);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(-1, 2);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(2, 22);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(22, 2);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(2, 2);
    assertTrue(testUpdate.hasFTCUpdatedBeenCalled());
    actualList = model.getFeatureTypeConstraint();
    assertEquals(4, actualList.size());
    assertTrue(actualList.get(2).getFeatureTypeName().compareTo("ftc4") == 0);
    assertNull(model.getFeatureTypeConstraint(-1));
    assertNull(model.getFeatureTypeConstraint(6));
    FeatureTypeConstraint actualFTC = model.getFeatureTypeConstraint(1);
    assertTrue(actualFTC.getFeatureTypeName().compareTo("ftc2") == 0);
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Extent(org.geotools.styling.Extent) FeatureTypeConstraintModel(com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel) Test(org.junit.Test)

Example 2 with FeatureTypeConstraintModel

use of com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel in project sldeditor by robward-scisys.

the class FeatureTypeConstraintModelTest method testGetValueAt.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#getRowCount()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#getValueAt(int, int)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#addNewEntry()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#setValueAt(java.lang.Object, int, int)}.
 */
@Test
public void testGetValueAt() {
    TestModelUpdate testUpdate = new TestModelUpdate();
    FeatureTypeConstraintModel model = new FeatureTypeConstraintModel(testUpdate);
    assertEquals(0, model.getRowCount());
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.addNewEntry();
    assertTrue(testUpdate.hasFTCUpdatedBeenCalled());
    assertEquals(1, model.getRowCount());
    assertNull(model.getValueAt(-1, 0));
    assertNull(model.getValueAt(99, 0));
    assertNull(model.getValueAt(0, -1));
    assertNull(model.getValueAt(0, 99));
    String actualValue = (String) model.getValueAt(0, 0);
    String expectedValue1 = "Feature";
    String expectedValue2 = "Filter.INCLUDE";
    assertTrue(expectedValue1.compareTo(actualValue) == 0);
    String actualValue2 = (String) model.getValueAt(0, 1);
    assertTrue(expectedValue2.compareTo(actualValue2) == 0);
    // SetValueAt
    model.setValueAt("", -1, 0);
    model.setValueAt("", 99, 0);
    model.setValueAt("", 0, -1);
    model.setValueAt("", 0, 99);
    expectedValue1 = "Updated feature";
    expectedValue2 = "Filter.EXCLUDE";
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.setValueAt(expectedValue1, 0, 0);
    assertTrue(testUpdate.hasFTCUpdatedBeenCalled());
    model.setValueAt(Filter.EXCLUDE, 0, 1);
    actualValue = (String) model.getValueAt(0, 0);
    assertTrue(expectedValue1.compareTo(actualValue) == 0);
    // Setting filter is done a different way
    actualValue = (String) model.getValueAt(0, 1);
    assertTrue("Filter.INCLUDE".compareTo(actualValue2) == 0);
}
Also used : FeatureTypeConstraintModel(com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel) Test(org.junit.Test)

Example 3 with FeatureTypeConstraintModel

use of com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel in project sldeditor by robward-scisys.

the class FeatureTypeConstraintModelTest method testGetColumnCount.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#getColumnCount()}.
 */
@Test
public void testGetColumnCount() {
    FeatureTypeConstraintModel model = new FeatureTypeConstraintModel(null);
    assertEquals(2, model.getColumnCount());
}
Also used : FeatureTypeConstraintModel(com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel) Test(org.junit.Test)

Example 4 with FeatureTypeConstraintModel

use of com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel in project sldeditor by robward-scisys.

the class FeatureTypeConstraintModelTest method testIsCellEditable.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#isCellEditable(int, int)}.
 */
@Test
public void testIsCellEditable() {
    FeatureTypeConstraintModel model = new FeatureTypeConstraintModel(null);
    assertTrue(model.isCellEditable(0, 0));
}
Also used : FeatureTypeConstraintModel(com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel) Test(org.junit.Test)

Example 5 with FeatureTypeConstraintModel

use of com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel in project sldeditor by robward-scisys.

the class FeatureTypeConstraintModelTest method testIsFilterColumn.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#isFilterColumn(int[])}.
 */
@Test
public void testIsFilterColumn() {
    FeatureTypeConstraintModel model = new FeatureTypeConstraintModel(null);
    assertFalse(model.isFilterColumn(null));
    int[] columns = new int[3];
    columns[0] = 0;
    columns[1] = 10;
    columns[2] = -1;
    assertFalse(model.isFilterColumn(columns));
    columns[2] = 1;
    assertTrue(model.isFilterColumn(columns));
}
Also used : FeatureTypeConstraintModel(com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel) Test(org.junit.Test)

Aggregations

FeatureTypeConstraintModel (com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel)6 Test (org.junit.Test)6 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 Extent (org.geotools.styling.Extent)1 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)1 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)1