Search in sources :

Example 1 with DummyInternalSLDFile3

use of com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3 in project sldeditor by robward-scisys.

the class RenderPanelImplTest method testVectorData.

/**
 * Test method for {@link com.sldeditor.render.RenderPanelImpl#RenderPanelImpl()}.
 */
@Test
void testVectorData() {
    RenderPanelImpl render = new RenderPanelImpl(false);
    render.setSize(200, 200);
    RenderPanelImpl.setUnderTest(false);
    DummyInternalSLDFile3 testSLD = new DummyInternalSLDFile3();
    DataSourceInterface dataSource = DataSourceFactory.getDataSource();
    dataSource.connect("test", SLDEditorFile.getInstance(), CheckAttributeFactory.getCheckList());
    SelectedSymbol.getInstance().setSld(testSLD.getSLD());
    render.renderSymbol();
    render.dataSourceLoaded(GeometryTypeEnum.POINT, false);
    render.dataSourceLoaded(GeometryTypeEnum.POINT, false);
    render.useAntiAliasUpdated(true);
    assertNotNull(render.getRuleRenderOptions());
    render.backgroundColourUpdate(null);
    render.backgroundColourUpdate(Color.BLUE);
    RenderPanelImpl.setUnderTest(true);
    DataSourceFactory.reset();
    SelectedSymbol.destroyInstance();
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) RenderPanelImpl(com.sldeditor.render.RenderPanelImpl) DummyInternalSLDFile3(com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3) Test(org.junit.jupiter.api.Test)

Example 2 with DummyInternalSLDFile3

use of com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3 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)

Example 3 with DummyInternalSLDFile3

use of com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3 in project sldeditor by robward-scisys.

the class BatchUpdateFontPanelTest method testPopulateUpdateFontSize.

/**
 * Test method for {@link
 * com.sldeditor.tool.batchupdatefont.BatchUpdateFontPanel#populate(java.util.List)}.
 */
@Test
void testPopulateUpdateFontSize() {
    TestSLDEditorInterface app = new TestSLDEditorInterface();
    TestBatchUpdateFontPanel testObj = new TestBatchUpdateFontPanel(app);
    List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
    DummyInternalSLDFile3 dummy = new DummyInternalSLDFile3();
    sldDataList.add(dummy.getSLDData());
    Double originalFontSize = getFontSize(dummy.getSLDData());
    testObj.populate(sldDataList);
    testObj.testSaveData();
    assertNull(app.savedParent);
    Double expectedFontSizeIncrease = 24.0;
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    String originalFontname = "Serif";
    String originalFontStyle = "normal";
    String originalFontWeight = "normal";
    Font expectedFont = styleFactory.createFont(ff.literal(originalFontname), ff.literal(originalFontStyle), ff.literal(originalFontWeight), ff.literal(expectedFontSizeIncrease));
    testObj.setUpdateFontSize(expectedFont);
    testObj.testApplyData();
    testObj.testSaveData();
    Double actualFontSize = getFontSize(app.savedSldData);
    Double expectedFontSize = originalFontSize + expectedFontSizeIncrease;
    assertEquals(actualFontSize.doubleValue(), expectedFontSize.doubleValue());
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ArrayList(java.util.ArrayList) DummyInternalSLDFile3(com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3) FilterFactory(org.opengis.filter.FilterFactory) Font(org.geotools.styling.Font) Test(org.junit.jupiter.api.Test)

Example 4 with DummyInternalSLDFile3

use of com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3 in project sldeditor by robward-scisys.

the class BatchUpdateFontPanelTest method testPopulateUpdateFontData.

/**
 * Test method for {@link
 * com.sldeditor.tool.batchupdatefont.BatchUpdateFontPanel#populate(java.util.List)}.
 */
@Test
void testPopulateUpdateFontData() {
    TestSLDEditorInterface app = new TestSLDEditorInterface();
    TestBatchUpdateFontPanel testObj = new TestBatchUpdateFontPanel(app);
    List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
    DummyInternalSLDFile3 dummy = new DummyInternalSLDFile3();
    sldDataList.add(dummy.getSLDData());
    testObj.populate(sldDataList);
    testObj.testSaveData();
    assertNull(app.savedParent);
    Double expectedFontSizeIncrease = 24.0;
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    String[] families = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    String originalFontname = families[0];
    String originalFontStyle = "normal";
    String originalFontWeight = "normal";
    Font expectedFont = styleFactory.createFont(ff.literal(originalFontname), ff.literal(originalFontStyle), ff.literal(originalFontWeight), ff.literal(expectedFontSizeIncrease));
    testObj.setUpdateFont(expectedFont);
    testObj.testApplyData();
    testObj.testSaveData();
    assertEquals(originalFontname, getFontName(app.savedSldData));
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ArrayList(java.util.ArrayList) DummyInternalSLDFile3(com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3) FilterFactory(org.opengis.filter.FilterFactory) Font(org.geotools.styling.Font) Test(org.junit.jupiter.api.Test)

Aggregations

DummyInternalSLDFile3 (com.sldeditor.test.unit.datasource.impl.DummyInternalSLDFile3)4 Test (org.junit.jupiter.api.Test)4 SLDDataInterface (com.sldeditor.common.SLDDataInterface)3 ArrayList (java.util.ArrayList)3 Font (org.geotools.styling.Font)2 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)2 FilterFactory (org.opengis.filter.FilterFactory)2 DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)1 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)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 RenderPanelImpl (com.sldeditor.render.RenderPanelImpl)1 HashMap (java.util.HashMap)1