Search in sources :

Example 1 with MissingSLDAttributes

use of com.sldeditor.datasource.checks.MissingSLDAttributes in project sldeditor by robward-scisys.

the class MissingSLDAttributesTest method testCheckAttributes.

/**
 * Test method for {@link
 * com.sldeditor.datasource.checks.MissingSLDAttributes#checkAttributes(com.sldeditor.datasource.SLDEditorFileInterface)}.
 */
@Test
void testCheckAttributes() {
    MissingSLDAttributes obj = new MissingSLDAttributes();
    obj.checkAttributes(null);
    DummyInternalSLDFile3 testSLD = new DummyInternalSLDFile3();
    SLDDataInterface sldData = testSLD.getSLDData();
    SLDEditorFile.destroyInstance();
    SelectedSymbol.destroyInstance();
    SelectedSymbol.getInstance().setSld(testSLD.getSLD());
    SLDEditorFile editorFile = SLDEditorFile.getInstance();
    Map<String, Object> propertyMap = new HashMap<String, Object>();
    propertyMap.put("field1", "value1");
    propertyMap.put("field2", "value2");
    propertyMap.put("field3", "value3");
    DataSourceConnectorInterface dsc = new DataSourceConnector();
    DataSourceProperties dsp = new DataSourceProperties(dsc);
    dsp.setPropertyMap(propertyMap);
    List<DataSourceAttributeData> fieldList = new ArrayList<DataSourceAttributeData>();
    fieldList.add(new DataSourceAttributeData("Field 1", String.class, null));
    fieldList.add(new DataSourceAttributeData("Field 2", Double.class, null));
    fieldList.add(new DataSourceAttributeData("Field 3", Double.class, null));
    // Try when no fields have been specified
    obj.checkAttributes(editorFile);
    editorFile.setSLDData(sldData);
    obj.checkAttributes(editorFile);
    // Specify the field list
    sldData.setFieldList(fieldList);
    sldData.setDataSourceProperties(dsp);
    editorFile.setDataSource(dsp);
    obj.checkAttributes(editorFile);
    // Tidy up
    SLDEditorFile.destroyInstance();
    SelectedSymbol.destroyInstance();
}
Also used : DataSourceConnector(com.sldeditor.datasource.connector.instance.DataSourceConnector) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MissingSLDAttributes(com.sldeditor.datasource.checks.MissingSLDAttributes) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) DataSourceProperties(com.sldeditor.datasource.impl.DataSourceProperties) DummyInternalSLDFile3(com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3) SLDDataInterface(com.sldeditor.common.SLDDataInterface) DataSourceConnectorInterface(com.sldeditor.common.DataSourceConnectorInterface) Test(org.junit.jupiter.api.Test)

Aggregations

DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)1 SLDDataInterface (com.sldeditor.common.SLDDataInterface)1 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)1 DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)1 MissingSLDAttributes (com.sldeditor.datasource.checks.MissingSLDAttributes)1 DataSourceConnector (com.sldeditor.datasource.connector.instance.DataSourceConnector)1 DataSourceProperties (com.sldeditor.datasource.impl.DataSourceProperties)1 DummyInternalSLDFile3 (com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1