Search in sources :

Example 1 with VendorOptionTypeInterface

use of com.sldeditor.common.vendoroption.VendorOptionTypeInterface in project sldeditor by robward-scisys.

the class VendorOptionManagerTest method testGetDefaultVendorOption.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getDefaultVendorOption()}.
 */
@Test
public void testGetDefaultVendorOption() {
    VendorOptionTypeInterface vo = VendorOptionManager.getInstance().getDefaultVendorOption();
    assertEquals(NoVendorOption.class, vo.getClass());
}
Also used : VendorOptionTypeInterface(com.sldeditor.common.vendoroption.VendorOptionTypeInterface) Test(org.junit.Test)

Example 2 with VendorOptionTypeInterface

use of com.sldeditor.common.vendoroption.VendorOptionTypeInterface in project sldeditor by robward-scisys.

the class VendorOptionTableModelTest method testGetVendorOption.

/**
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#getVendorOption(int)}.
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#setSelectedVendorOptionVersions(java.util.List)}.
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#getVendorOptionVersionList()}.
 */
@Test
public void testGetVendorOption() {
    Map<VendorOptionTypeInterface, String> options = new LinkedHashMap<VendorOptionTypeInterface, String>();
    VendorOptionTypeInterface vendorOption = VendorOptionManager.getInstance().getClass(GeoServerVendorOption.class);
    options.put(vendorOption, vendorOption.getName());
    VendorOptionTableModel model = new VendorOptionTableModel(options, null);
    assertEquals(1, model.getRowCount());
    // Try invalid calls to getVendorOption
    assertNull(model.getVendorOption(-1));
    assertNull(model.getVendorOption(1));
    // Valid call to getVendorOption
    List<VersionData> actualList = model.getVendorOption(0);
    assertEquals(vendorOption.getVersionList().size(), actualList.size());
    assertEquals(Localisation.getString(VendorOptionTableModel.class, "common.notSet"), actualList.get(0).getVersionString());
    model.setSelectedVendorOptionVersions(null);
    List<VersionData> selectedVersionList = new ArrayList<VersionData>();
    VersionData expectedVersionData = vendorOption.getVersionList().get(1);
    selectedVersionList.add(expectedVersionData);
    model.setSelectedVendorOptionVersions(selectedVersionList);
    actualList = model.getVendorOptionVersionList();
    assertEquals(2, actualList.size());
    assertEquals(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData(), actualList.get(0));
    assertEquals(expectedVersionData.getVersionString(), actualList.get(1).getVersionString());
    // Try with unknown
    selectedVersionList = new ArrayList<VersionData>();
    expectedVersionData = VersionData.getEarliestVersion(Double.class);
    selectedVersionList.add(expectedVersionData);
    model.setSelectedVendorOptionVersions(selectedVersionList);
    actualList = model.getVendorOptionVersionList();
    assertEquals(1, actualList.size());
    assertEquals(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData(), actualList.get(0));
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) ArrayList(java.util.ArrayList) VendorOptionTableModel(com.sldeditor.common.vendoroption.selection.VendorOptionTableModel) VendorOptionTypeInterface(com.sldeditor.common.vendoroption.VendorOptionTypeInterface) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 3 with VendorOptionTypeInterface

use of com.sldeditor.common.vendoroption.VendorOptionTypeInterface in project sldeditor by robward-scisys.

the class VendorOptionTableModelTest method testSetValueAtObjectIntInt.

/**
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#setValueAt(java.lang.Object, int, int)}.
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#setSelectedVersion(com.sldeditor.common.vendoroption.VersionData, int)}.
 */
@Test
public void testSetValueAtObjectIntInt() {
    Map<VendorOptionTypeInterface, String> options = new LinkedHashMap<VendorOptionTypeInterface, String>();
    VendorOptionTypeInterface vendorOption = VendorOptionManager.getInstance().getClass(GeoServerVendorOption.class);
    options.put(vendorOption, vendorOption.getName());
    VendorOptionTableModel model = new VendorOptionTableModel(options, null);
    assertEquals(1, model.getRowCount());
    VersionData latest = VersionData.getLatestVersion(GeoServerVendorOption.class);
    VersionData earliest = VersionData.getEarliestVersion(GeoServerVendorOption.class);
    // Invalid column
    model.setValueAt(earliest, 0, 0);
    VersionData actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(latest.getVersionString(), actual.getVersionString());
    // Invalid row
    model.setValueAt(earliest, -1, 1);
    actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(latest.getVersionString(), actual.getVersionString());
    model.setValueAt(earliest, 1, 1);
    actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(latest.getVersionString(), actual.getVersionString());
    // Valid row
    model.setValueAt(earliest, 0, 1);
    actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(earliest.getVersionString(), actual.getVersionString());
    // Try setSelectedVersion
    model.setSelectedVersion(latest, 0);
    actual = (VersionData) model.getValueAt(0, 1);
    assertEquals(latest.getVersionString(), actual.getVersionString());
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionTableModel(com.sldeditor.common.vendoroption.selection.VendorOptionTableModel) VendorOptionTypeInterface(com.sldeditor.common.vendoroption.VendorOptionTypeInterface) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 4 with VendorOptionTypeInterface

use of com.sldeditor.common.vendoroption.VendorOptionTypeInterface in project sldeditor by robward-scisys.

the class VendorOptionTableModelTest method testGetValueAt.

/**
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#getValueAt(int, int)}.
 * Test method for
 * {@link com.sldeditor.common.vendoroption.selection.VendorOptionTableModel#getRowCount()}.
 */
@Test
public void testGetValueAt() {
    Map<VendorOptionTypeInterface, String> options = new LinkedHashMap<VendorOptionTypeInterface, String>();
    VendorOptionTypeInterface vendorOption = VendorOptionManager.getInstance().getClass(GeoServerVendorOption.class);
    options.put(vendorOption, vendorOption.getName());
    VendorOptionTableModel model = new VendorOptionTableModel(options, null);
    assertEquals(1, model.getRowCount());
    String actualValue1 = (String) model.getValueAt(0, 0);
    assertEquals(vendorOption.getName(), actualValue1);
    VersionData actualValue2 = (VersionData) model.getValueAt(0, 1);
    VersionData latest = VersionData.getLatestVersion(GeoServerVendorOption.class);
    assertEquals(latest.getVersionString(), actualValue2.getVersionString());
    assertNull(model.getValueAt(0, -1));
    assertNull(model.getValueAt(0, 5));
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionTableModel(com.sldeditor.common.vendoroption.selection.VendorOptionTableModel) VendorOptionTypeInterface(com.sldeditor.common.vendoroption.VendorOptionTypeInterface) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 5 with VendorOptionTypeInterface

use of com.sldeditor.common.vendoroption.VendorOptionTypeInterface in project sldeditor by robward-scisys.

the class VendorOptionTableModel method setSelectedVendorOptionVersions.

/**
 * Sets the selected vendor option versions.
 *
 * @param selectedVersionList the new selected vendor option versions
 */
public void setSelectedVendorOptionVersions(List<VersionData> selectedVersionList) {
    if (selectedVersionList != null) {
        this.selectedVersionList = new ArrayList<VersionData>();
        for (VendorOptionTypeInterface key : nameOrder) {
            boolean found = false;
            for (VersionData versionData : selectedVersionList) {
                if (versionData.getVendorOptionType() == key.getClass()) {
                    found = true;
                    this.selectedVersionList.clear();
                    this.selectedVersionList.add(versionData);
                    VendorOptionInfoManager.getInstance().setSelectedVersion(instance, versionData);
                }
            }
            if (!found) {
                VersionData notSetVersion = VersionData.getNotSetVersion(key.getClass());
                this.selectedVersionList.add(notSetVersion);
                VendorOptionInfoManager.getInstance().setSelectedVersion(instance, notSetVersion);
            }
        }
        VersionData defaultVendorOption = VendorOptionManager.getInstance().getDefaultVendorOptionVersionData();
        this.selectedVersionList.remove(defaultVendorOption);
        this.fireTableDataChanged();
    }
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionTypeInterface(com.sldeditor.common.vendoroption.VendorOptionTypeInterface)

Aggregations

VendorOptionTypeInterface (com.sldeditor.common.vendoroption.VendorOptionTypeInterface)5 VersionData (com.sldeditor.common.vendoroption.VersionData)4 Test (org.junit.Test)4 VendorOptionTableModel (com.sldeditor.common.vendoroption.selection.VendorOptionTableModel)3 LinkedHashMap (java.util.LinkedHashMap)3 ArrayList (java.util.ArrayList)1