Commit 9e205757 authored by Matthias Betz's avatar Matthias Betz
Browse files

fixing handling of boundary surfaces in bridges

added tests for BridgeObject
parent a138df4b
Pipeline #4355 passed with stage
in 2 minutes and 15 seconds
......@@ -74,6 +74,9 @@ public class BridgeObject extends CityObject {
setSolidAccordingToLod(geom, solid);
}
}
for (BoundarySurface bs : boundarySurfaces) {
bs.reCreateGeometries(factory, config);
}
}
private void setMultiSurfaceAccordingToLod(Geometry geom, MultiSurface ms) {
......@@ -164,6 +167,9 @@ public class BridgeObject extends CityObject {
if (c.canExecute(this)) {
c.check(this);
}
for (BoundarySurface bs : boundarySurfaces) {
bs.accept(c);
}
}
/**
......@@ -204,6 +210,9 @@ public class BridgeObject extends CityObject {
ab.unsetLod2Solid();
ab.unsetLod3Solid();
ab.unsetLod4Solid();
for (BoundarySurface bs : boundarySurfaces) {
bs.unsetGmlGeometries();
}
}
public void setGmlObject(AbstractBridge aBridge) {
......@@ -214,7 +223,7 @@ public class BridgeObject extends CityObject {
public String toString() {
return "BridgeObject [type=" + type + ", id=" + getGmlId() + "]";
}
@Override
public void prepareForChecking() {
super.prepareForChecking();
......@@ -222,7 +231,7 @@ public class BridgeObject extends CityObject {
bs.prepareForChecking();
}
}
@Override
public void clearMetaInformation() {
super.clearMetaInformation();
......
......@@ -23,10 +23,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.citygml4j.factory.GMLGeometryFactory;
......@@ -45,14 +45,12 @@ import org.citygml4j.model.gml.geometry.primitives.SurfaceProperty;
import org.junit.Test;
import org.mockito.Mockito;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.Requirement;
import de.hft.stuttgart.citydoctor2.check.RequirementType;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.test.util.AbstractCheck;
public class AbstractBuildingTest {
......@@ -67,27 +65,7 @@ public class AbstractBuildingTest {
AtomicInteger abCounter = new AtomicInteger(0);
AtomicInteger bsCounter = new AtomicInteger(0);
AtomicInteger biCounter = new AtomicInteger(0);
Check c = new Check() {
@Override
public Set<Requirement> appliesToRequirements() {
return null;
}
@Override
public CheckId getCheckId() {
return null;
}
@Override
public RequirementType getType() {
return null;
}
@Override
public Check createNewInstance() {
return null;
}
AbstractCheck c = new AbstractCheck() {
@Override
public void check(AbstractBuilding ab) {
......@@ -104,27 +82,7 @@ public class AbstractBuildingTest {
assertEquals(1, bsCounter.intValue());
assertEquals(0, biCounter.intValue());
Check c2 = new Check() {
@Override
public Set<Requirement> appliesToRequirements() {
return null;
}
@Override
public CheckId getCheckId() {
return null;
}
@Override
public RequirementType getType() {
return null;
}
@Override
public Check createNewInstance() {
return null;
}
AbstractCheck c2 = new AbstractCheck() {
@Override
public void check(BuildingInstallation bi) {
......@@ -137,8 +95,8 @@ public class AbstractBuildingTest {
@Test
public void testPrepareForChecking() {
BuildingInstallation biMock = Mockito.mock(BuildingInstallation.class);
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
......@@ -152,8 +110,8 @@ public class AbstractBuildingTest {
@Test
public void testClearMetaInformation() {
BuildingInstallation biMock = Mockito.mock(BuildingInstallation.class);
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
......@@ -171,8 +129,7 @@ public class AbstractBuildingTest {
private static final long serialVersionUID = -448362592456318541L;
};
assertFalse(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
ab.addCheckResult(
new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, Mockito.mock(CheckError.class)));
ab.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, mock(CheckError.class)));
assertTrue(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
}
......@@ -181,7 +138,7 @@ public class AbstractBuildingTest {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
ab.addBoundarySurface(bsMock);
assertFalse(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
Mockito.when(bsMock.containsError(CheckId.C_GE_P_HOLE_OUTSIDE)).thenReturn(true);
......@@ -193,7 +150,7 @@ public class AbstractBuildingTest {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
BuildingInstallation biMock = Mockito.mock(BuildingInstallation.class);
BuildingInstallation biMock = mock(BuildingInstallation.class);
ab.addBuildingInstallation(biMock);
assertFalse(ab.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
Mockito.when(biMock.containsError(CheckId.C_GE_P_HOLE_OUTSIDE)).thenReturn(true);
......@@ -202,8 +159,8 @@ public class AbstractBuildingTest {
@Test
public void testClearAllContainedCheckResults() {
BuildingInstallation biMock = Mockito.mock(BuildingInstallation.class);
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
......@@ -228,7 +185,7 @@ public class AbstractBuildingTest {
ab.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.OK, null));
assertFalse(ab.containsAnyError());
ab.addCheckResult(
new CheckResult(CheckId.C_GE_P_INNER_RINGS_NESTED, ResultStatus.ERROR, Mockito.mock(CheckError.class)));
new CheckResult(CheckId.C_GE_P_INNER_RINGS_NESTED, ResultStatus.ERROR, mock(CheckError.class)));
assertTrue(ab.containsAnyError());
}
......@@ -237,7 +194,7 @@ public class AbstractBuildingTest {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
ab.addBoundarySurface(bsMock);
assertFalse(ab.containsAnyError());
Mockito.when(bsMock.containsAnyError()).thenReturn(true);
......@@ -249,7 +206,7 @@ public class AbstractBuildingTest {
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
BuildingInstallation biMock = Mockito.mock(BuildingInstallation.class);
BuildingInstallation biMock = mock(BuildingInstallation.class);
ab.addBuildingInstallation(biMock);
assertFalse(ab.containsAnyError());
Mockito.when(biMock.containsAnyError()).thenReturn(true);
......@@ -258,16 +215,15 @@ public class AbstractBuildingTest {
@Test
public void testCollectContainedErrors() {
BuildingInstallation biMock = Mockito.mock(BuildingInstallation.class);
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
ab.addBoundarySurface(bsMock);
ab.addBuildingInstallation(biMock);
ab.addCheckResult(
new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, Mockito.mock(CheckError.class)));
ab.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, mock(CheckError.class)));
List<CheckError> errors = new ArrayList<>();
ab.collectContainedErrors(errors);
Mockito.verify(biMock, Mockito.times(1)).collectContainedErrors(errors);
......@@ -302,12 +258,8 @@ public class AbstractBuildingTest {
AbstractRing ring = gmlPoly.getExterior().getRing();
org.citygml4j.model.gml.geometry.primitives.LinearRing gmlRing = (org.citygml4j.model.gml.geometry.primitives.LinearRing) ring;
DirectPositionList posList = gmlRing.getPosList();
double[] expectedValues = new double[] {
427583.301, 6003502.571, 9.711,
427583.304, 6003502.574, 9.713,
427583.304, 6003502.574, 4.097,
427583.301, 6003502.571, 4.097,
427583.301, 6003502.571, 9.711};
double[] expectedValues = new double[] { 427583.301, 6003502.571, 9.711, 427583.304, 6003502.574, 9.713,
427583.304, 6003502.574, 4.097, 427583.301, 6003502.571, 4.097, 427583.301, 6003502.571, 9.711 };
List<Double> values = posList.getValue();
for (int i = 0; i < values.size(); i++) {
assertEquals(expectedValues[i], values.get(i), 0.00000001);
......@@ -333,7 +285,7 @@ public class AbstractBuildingTest {
@Test
public void testReCreateGeometriesBs() {
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
......@@ -348,11 +300,11 @@ public class AbstractBuildingTest {
ab.reCreateGeometries(factory, config);
Mockito.verify(bsMock).reCreateGeometries(factory, config);
}
@Test
public void testReCreateGeometriesEmptyBs() {
WallSurface ws = new WallSurface();
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
Mockito.when(bsMock.getGmlObject()).thenReturn(ws);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
......@@ -370,10 +322,10 @@ public class AbstractBuildingTest {
ab.reCreateGeometries(factory, config);
assertEquals(2, gmlAb.getBoundedBySurface().size());
}
@Test
public void testReCreateGeometriesEmptyBi() {
BuildingInstallation biMock = Mockito.mock(BuildingInstallation.class);
BuildingInstallation biMock = mock(BuildingInstallation.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
};
......@@ -385,11 +337,11 @@ public class AbstractBuildingTest {
ab.reCreateGeometries(factory, config);
Mockito.verify(biMock).reCreateGeometries(factory, config);
}
@Test
public void testUnsetGmlGeometries() {
BuildingInstallation biMock = Mockito.mock(BuildingInstallation.class);
BoundarySurface bsMock = Mockito.mock(BoundarySurface.class);
BuildingInstallation biMock = mock(BuildingInstallation.class);
BoundarySurface bsMock = mock(BoundarySurface.class);
AbstractBuilding ab = new AbstractBuilding() {
private static final long serialVersionUID = -448362592456318541L;
......
......@@ -26,7 +26,6 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.citygml4j.factory.GMLGeometryFactory;
......@@ -36,14 +35,12 @@ import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty;
import org.junit.Test;
import org.mockito.Mockito;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.Requirement;
import de.hft.stuttgart.citydoctor2.check.RequirementType;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.test.util.AbstractCheck;
public class BoundarySurfaceTest {
......@@ -53,27 +50,7 @@ public class BoundarySurfaceTest {
Opening oMock = Mockito.mock(Opening.class);
bs.addOpening(oMock);
AtomicInteger bsCounter = new AtomicInteger(0);
Check c = new Check() {
@Override
public Set<Requirement> appliesToRequirements() {
return null;
}
@Override
public CheckId getCheckId() {
return null;
}
@Override
public RequirementType getType() {
return null;
}
@Override
public Check createNewInstance() {
return null;
}
AbstractCheck c = new AbstractCheck() {
@Override
public void check(BoundarySurface bs) {
......@@ -91,27 +68,7 @@ public class BoundarySurfaceTest {
Opening oMock = Mockito.mock(Opening.class);
bs.addOpening(oMock);
AtomicInteger bsCounter = new AtomicInteger(0);
Check c = new Check() {
@Override
public Set<Requirement> appliesToRequirements() {
return null;
}
@Override
public CheckId getCheckId() {
return null;
}
@Override
public RequirementType getType() {
return null;
}
@Override
public Check createNewInstance() {
return null;
}
AbstractCheck c = new AbstractCheck() {
@Override
public void check(BridgeObject bo) {
......
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.datastructure;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import org.citygml4j.factory.GMLGeometryFactory;
import org.citygml4j.model.citygml.bridge.AbstractBridge;
import org.citygml4j.model.citygml.bridge.Bridge;
import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject.BridgeType;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.test.util.AbstractCheck;
public class BridgeObjectTest {
@Test
public void testAccept() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
bo.addBoundarySurface(new BoundarySurface(null));
AtomicInteger boCounter = new AtomicInteger(0);
AtomicInteger bsCounter = new AtomicInteger(0);
AbstractCheck c = new AbstractCheck() {
@Override
public void check(BridgeObject bo) {
boCounter.incrementAndGet();
}
@Override
public void check(BoundarySurface bs) {
bsCounter.incrementAndGet();
}
};
bo.accept(c);
assertEquals(1, boCounter.intValue());
assertEquals(1, bsCounter.intValue());
AtomicInteger boCounter2 = new AtomicInteger(0);
c = new AbstractCheck();
bo.accept(c);
assertEquals(0, boCounter2.intValue());
}
@Test
public void testPrepareForChecking() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
bo.prepareForChecking();
verify(bsMock).prepareForChecking();
}
@Test
public void testClearMetaInformation() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
bo.clearMetaInformation();
verify(bsMock).clearMetaInformation();
}
@Test
public void testContainsError() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
assertFalse(bo.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
bo.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, mock(CheckError.class)));
assertTrue(bo.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
}
@Test
public void testContainsError2() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
assertFalse(bo.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
when(bsMock.containsError(CheckId.C_GE_P_HOLE_OUTSIDE)).thenReturn(true);
assertTrue(bo.containsError(CheckId.C_GE_P_HOLE_OUTSIDE));
}
@Test
public void testClearAllContainedCheckResults() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
bo.clearAllContainedCheckResults();
verify(bsMock).clearAllContainedCheckResults();
}
@Test
public void testContainsAnyError() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
bo.containsAnyError();
verify(bsMock).containsAnyError();
when(bsMock.containsAnyError()).thenReturn(true);
assertTrue(bo.containsAnyError());
BridgeObject bo2 = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
bo2.addCheckResult(new CheckResult(CheckId.C_GE_P_HOLE_OUTSIDE, ResultStatus.ERROR, mock(CheckError.class)));
assertTrue(bo2.containsAnyError());
}
@Test
public void testCollectContainedErrors() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
ArrayList<CheckError> errors = new ArrayList<>();
bo.collectContainedErrors(errors);
verify(bsMock).collectContainedErrors(errors);
}
@Test
public void testReCreateGeometries() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
GMLGeometryFactory factoryMock = mock(GMLGeometryFactory.class);
ParserConfiguration configMock = mock(ParserConfiguration.class);
bo.reCreateGeometries(factoryMock, configMock);
verify(bsMock).reCreateGeometries(factoryMock, configMock);
}
@Test
public void testReCreateGeometriesMultiSurfaceLod1() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD1);
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod1MultiSurface());
assertNotNull(ab.getLod1MultiSurface().getGeometry());
}
@Test
public void testReCreateGeometriesMultiSurfaceLod2() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD2);
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod2MultiSurface());
assertNotNull(ab.getLod2MultiSurface().getGeometry());
}
@Test
public void testReCreateGeometriesMultiSurfaceLod3() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD3);
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod3MultiSurface());
assertNotNull(ab.getLod3MultiSurface().getGeometry());
}
@Test
public void testReCreateGeometriesMultiSurfaceLod4() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.MULTI_SURFACE, Lod.LOD4);
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod4MultiSurface());
assertNotNull(ab.getLod4MultiSurface().getGeometry());
}
@Test
public void testReCreateGeometriesSolidLod1() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD1);
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod1Solid());
assertNotNull(ab.getLod1Solid().getGeometry());
}
@Test
public void testReCreateGeometriesSolidLod2() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD2);
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod2Solid());
assertNotNull(ab.getLod2Solid().getGeometry());
}
@Test
public void testReCreateGeometriesSolidLod3() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD3);
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod3Solid());
assertNotNull(ab.getLod3Solid().getGeometry());
}
@Test
public void testReCreateGeometriesSolidLod4() {
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, mock(AbstractBridge.class));
Geometry geom = GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD4);
AbstractBridge ab = new Bridge();
bo.setGmlObject(ab);
bo.addGeometry(geom);
GMLGeometryFactory factory = new GMLGeometryFactory();
ParserConfiguration config = new ParserConfiguration(8, false);
bo.reCreateGeometries(factory, config);
assertNotNull(ab.getLod4Solid());
assertNotNull(ab.getLod4Solid().getGeometry());
}
@Test
public void testUnsetGmlGeometries() {
AbstractBridge abMock = mock(AbstractBridge.class);
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, abMock);
BoundarySurface bsMock = mock(BoundarySurface.class);
bo.addBoundarySurface(bsMock);
bo.unsetGmlGeometries();
verify(bsMock).unsetGmlGeometries();
verify(abMock).unsetLod1MultiSurface();
verify(abMock).unsetLod2MultiSurface();
verify(abMock).unsetLod3MultiSurface();
verify(abMock).unsetLod4MultiSurface();
verify(abMock).unsetLod1Solid();
verify(abMock).unsetLod2Solid();
verify(abMock).unsetLod3Solid();
verify(abMock).unsetLod4Solid();
}
@Test
public void testGetFeatureType() {
AbstractBridge abMock = mock(AbstractBridge.class);
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, abMock);
assertEquals(FeatureType.BRIDGE, bo.getFeatureType());
}
@Test
public void testGetType() {
AbstractBridge abMock = mock(AbstractBridge.class);
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, abMock);
assertEquals(BridgeType.BRIDGE, bo.getType());
bo.setType(BridgeType.BRIDGE_PART);
assertEquals(BridgeType.BRIDGE_PART, bo.getType());
}
@Test
public void testGetGmlObject() {
AbstractBridge abMock = mock(AbstractBridge.class);
BridgeObject bo = new BridgeObject(BridgeType.BRIDGE, abMock);
assertEquals(abMock, bo.getGmlObject());
AbstractBridge abMock2 = mock(AbstractBridge.class);
bo.setGmlObject(abMock2);
assertEquals(abMock2, bo.getGmlObject());
}
}
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.test.util;
import java.util.Set;
import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.Requirement;
import de.hft.stuttgart.citydoctor2.check.RequirementType;
public class AbstractCheck extends Check {
@Override
public Set<Requirement> appliesToRequirements() {
return null;
}
@Override
public CheckId getCheckId() {
return null;
}
@Override
public RequirementType getType() {
return null;
}
@Override
public Check createNewInstance() {
return null;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment