Commit d5af975e authored by Luna Riegel's avatar Luna Riegel
Browse files

Fix: Fix test failures

parent e178e81e
......@@ -1259,7 +1259,7 @@ public class MeshSurfaceUtilsTest {
public void testKaiserwallComplexBuilding() throws CityGmlParseException, InvalidGmlFileException {
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/KaiserwallComplexBuilding.gml", config);
Building building = model.getBuildings().get(0);
Building building = model.getBuildings().toList().get(0);
Geometry geom = building.getBuildingInstallations().get(0).getGeometries().get(0);
assertNotNull(geom);
MeshSurface surface = MeshSurface.of(geom);
......
package de.hft.stuttgart.citydoctor2.database;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
public class CacheManager {
private static FeatureCache cache = null;
public static CityObjectCache getFeatureCache(String filename) {
private CacheManager() {}
public static FeatureCache getFeatureCache(File file) {
if (file == null){
throw new IllegalArgumentException("File is null");
}
String filename = FilenameUtils.removeExtension(file.getName());
if (cache == null){
cache = new FeatureCache(filename);
} else {
......@@ -13,7 +23,7 @@ public class CacheManager {
return cache;
}
public static CityObjectCache getUnconnectedCache(){
public static UnconnectedCache getUnconnectedCache(){
return new UnconnectedCache();
}
......
......@@ -69,7 +69,7 @@ public class CityDoctorModel {
private final CityObjectCache cache;
public CityDoctorModel(ParserConfiguration config, File file) {
this(config, file, CacheManager.getFeatureCache(FilenameUtils.removeExtension(file.getName())));
this(config, file, CacheManager.getFeatureCache(file));
}
public CityDoctorModel(ParserConfiguration config, File file, CityObjectCache cache) {
......@@ -244,6 +244,18 @@ public class CityDoctorModel {
cache.put(coBuilding);
}
public void removeFeature(GmlId id){
buildings.remove(id);
vegetation.remove(id);
bridges.remove(id);
land.remove(id);
roads.remove(id);
tunnels.remove(id);
water.remove(id);
cityfurniture.remove(id);
genericObjects.remove(id);
}
public Stream<Building> getBuildings() {
return buildings.stream().map(co -> (Building) cache.get(co));
}
......@@ -459,6 +471,7 @@ public class CityDoctorModel {
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in transportation objects");
}
cache.replace(currentFeature.getGmlId(), nextFeature);
roads.set(index, nextFeature.getGmlId());
}
......@@ -467,6 +480,7 @@ public class CityDoctorModel {
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in tunnels");
}
cache.replace(currentFeature.getGmlId(), nextFeature);
tunnels.set(index, nextFeature.getGmlId());
}
......@@ -475,6 +489,7 @@ public class CityDoctorModel {
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in bridges");
}
cache.replace(currentFeature.getGmlId(), nextFeature);
bridges.set(index, nextFeature.getGmlId());
}
......@@ -483,6 +498,7 @@ public class CityDoctorModel {
if (index == -1) {
throw new IllegalStateException(COULD_NOT_FIND_FEATURE + currentFeature + " in buildings");
}
cache.replace(currentFeature.getGmlId(), nextFeature);
buildings.set(index, nextFeature.getGmlId());
}
......
......@@ -45,6 +45,7 @@ import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.ImplicitGeometryHolder;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
......@@ -842,8 +843,13 @@ public class CityGmlParser {
}
private static void drainCityModel(CityDoctorModel model, CityGmlConsumer cityObjectConsumer) {
List<GmlId> id = new ArrayList<>();
model.createFeatureStream().forEach(co -> {
cityObjectConsumer.accept(co);
id.add(co.getGmlId());
});
id.forEach(model::removeFeature);
model.createFeatureStream().forEach(cityObjectConsumer::accept);
}
......
......@@ -32,6 +32,7 @@ import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.core.AbstractFeatureProperty;
import org.citygml4j.core.model.core.CityModel;
import org.citygml4j.xml.writer.CityGMLWriteException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
......@@ -63,28 +64,39 @@ import de.hft.stuttgart.quality.model.types.ValidationPlan;
public class CityDoctorModelTest {
private File mockFile;
private ParserConfiguration config;
@Before
public void setUp(){
mockFile = Mockito.mock(File.class);
Mockito.when(mockFile.getName()).thenReturn("test");
config = new ParserConfiguration(8, false);
}
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test(expected = IllegalArgumentException.class)
public void testCityDoctorModelNoConfig() {
new CityDoctorModel(null, null);
new CityDoctorModel(null, mockFile);
}
@Test(expected = IllegalArgumentException.class)
public void testCityDoctorModelNoFile() {
new CityDoctorModel(config, null);
}
@Test
public void testSetValidated() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
model.setValidated(Mockito.mock(ValidationPlan.class));
assertTrue(model.isValidated());
}
@Test
public void testAddGlobalError() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
CheckError err = Mockito.mock(CheckError.class);
model.addGlobalError(err);
assertEquals(err, model.getGlobalErrors().get(0));
......@@ -92,9 +104,7 @@ public class CityDoctorModelTest {
@Test
public void testAddGlobalErrors() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
CheckError err1 = Mockito.mock(CheckError.class);
CheckError err2 = Mockito.mock(CheckError.class);
List<CheckError> errors = new ArrayList<>();
......@@ -107,19 +117,17 @@ public class CityDoctorModelTest {
@Test
public void testGetFile() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
assertEquals(f, model.getFile());
CityDoctorModel model = new CityDoctorModel(config, mockFile);
assertEquals(mockFile, model.getFile());
}
@Test
public void testCreateFeatureStream() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Building b = Mockito.mock(Building.class);
Mockito.when(b.getGmlId()).thenReturn(new GmlId("b"));
Vegetation v = Mockito.mock(Vegetation.class);
Mockito.when(v.getGmlId()).thenReturn(new GmlId("v"));
model.addBuilding(b);
model.addVegetation(v);
assertTrue(model.createFeatureStream().anyMatch(c -> c == b));
......@@ -129,9 +137,7 @@ public class CityDoctorModelTest {
@Test
public void testSaveAsWithoutValidation() throws CityGMLWriteException, ADEException,
IOException, CityGmlParseException, InvalidGmlFileException, CityDoctorWriteException {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
model.setParsedCityGMLVersion(CityGMLVersion.v2_0);
CityModel cModel = new CityModel();
model.setCityModel(cModel);
......@@ -155,9 +161,7 @@ public class CityDoctorModelTest {
@Test
public void testSaveAsWithValidation() throws CityGMLWriteException, ADEException,
IOException, CityGmlParseException, InvalidGmlFileException, CityDoctorWriteException {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
model.setParsedCityGMLVersion(CityGMLVersion.v2_0);
CityModel cModel = new CityModel();
ValidationPlan plan = new ValidationPlan();
......@@ -234,9 +238,7 @@ public class CityDoctorModelTest {
@Test
public void testCollectErrors() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Building b = new Building();
model.addBuilding(b);
CheckError error = Mockito.mock(CheckError.class);
......@@ -247,18 +249,14 @@ public class CityDoctorModelTest {
@Test
public void testGetFileName() {
File f = new File("test");
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
assertEquals("test", model.getFileName());
assertEquals(f, model.getFile());
assertEquals(mockFile, model.getFile());
}
@Test
public void testSetCityModel() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
CityModel cModel = Mockito.mock(CityModel.class);
model.setCityModel(cModel);
assertEquals(cModel, model.getCityModel());
......@@ -266,40 +264,36 @@ public class CityDoctorModelTest {
@Test
public void testAddBuilding() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Building b = Mockito.mock(Building.class);
Mockito.when(b.getGmlId()).thenReturn(new GmlId("b"));
model.addBuilding(b);
assertEquals(b, model.getBuildings().toList().get(0));
}
@Test
public void testAddBridge() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
BridgeObject b = Mockito.mock(BridgeObject.class);
Mockito.when(b.getGmlId()).thenReturn(new GmlId("b"));
model.addBridge(b);
assertEquals(b, model.getBridges().toList().get(0));
}
@Test
public void testAddVegetation() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Vegetation veg = Mockito.mock(Vegetation.class);
Mockito.when(veg.getGmlId()).thenReturn(new GmlId("v"));
model.addVegetation(veg);
assertEquals(veg, model.getVegetation().toList().get(0));
}
@Test
public void testAddTunnel() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Tunnel tunnel = Mockito.mock(Tunnel.class);
Mockito.when(tunnel.getGmlId()).thenReturn(new GmlId("t"));
model.addTunnel(tunnel);
assertEquals(tunnel, model.getTunnels().toList().get(0));
}
......@@ -307,10 +301,9 @@ public class CityDoctorModelTest {
@Test
public void testAddTransportation() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
TransportationObject trans = Mockito.mock(TransportationObject.class);
Mockito.when(trans.getGmlId()).thenReturn(new GmlId("t"));
model.addTransportation(trans);
assertEquals(trans, model.getTransportation().toList().get(0));
}
......@@ -318,59 +311,62 @@ public class CityDoctorModelTest {
@Test
public void testAddLand() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
LandObject land = Mockito.mock(LandObject.class);
Mockito.when(land.getGmlId()).thenReturn(new GmlId("l"));
model.addLand(land);
assertEquals(land, model.getLand().toList().get(0));
}
@Test
public void testAddWater() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
WaterObject water = Mockito.mock(WaterObject.class);
Mockito.when(water.getGmlId()).thenReturn(new GmlId("w"));
model.addWater(water);
assertEquals(water, model.getWater().toList().get(0));
}
@Test
public void testAddCityFurniture() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
CityFurniture cf = Mockito.mock(CityFurniture.class);
Mockito.when(cf.getGmlId()).thenReturn(new GmlId("cf"));
model.addCityFurniture(cf);
assertEquals(cf, model.getCityFurniture().toList().get(0));
}
@Test
public void testAddGenericCityObject() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
GenericCityObject gen = Mockito.mock(GenericCityObject.class);
Mockito.when(gen.getGmlId()).thenReturn(new GmlId("g"));
model.addGenericCityObject(gen);
assertEquals(gen, model.getGenericCityObjects().toList().get(0));
}
@Test
public void testGetNumberOfFeatures() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Building b = Mockito.mock(Building.class);
Mockito.when(b.getGmlId()).thenReturn(new GmlId("b"));
BridgeObject bo = Mockito.mock(BridgeObject.class);
Mockito.when(bo.getGmlId()).thenReturn(new GmlId("bo"));
Vegetation veg = Mockito.mock(Vegetation.class);
Mockito.when(veg.getGmlId()).thenReturn(new GmlId("ve"));
Tunnel tunnel = Mockito.mock(Tunnel.class);
Mockito.when(tunnel.getGmlId()).thenReturn(new GmlId("t"));
TransportationObject trans = Mockito.mock(TransportationObject.class);
Mockito.when(trans.getGmlId()).thenReturn(new GmlId("tr"));
LandObject land = Mockito.mock(LandObject.class);
Mockito.when(land.getGmlId()).thenReturn(new GmlId("l"));
WaterObject water = Mockito.mock(WaterObject.class);
Mockito.when(water.getGmlId()).thenReturn(new GmlId("w"));
CityFurniture cf = Mockito.mock(CityFurniture.class);
Mockito.when(cf.getGmlId()).thenReturn(new GmlId("cf"));
GenericCityObject generic = Mockito.mock(GenericCityObject.class);
Mockito.when(generic.getGmlId()).thenReturn(new GmlId("g"));
model.addBuilding(b);
model.addBridge(bo);
......@@ -388,19 +384,18 @@ public class CityDoctorModelTest {
@Test
public void testGetParserConfig() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
assertEquals(config, model.getParserConfig());
}
@Test
public void testReplaceBuilding() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Building b1 = Mockito.mock(Building.class);
Mockito.when(b1.getGmlId()).thenReturn(new GmlId("b1"));
Building b2 = Mockito.mock(Building.class);
Mockito.when(b2.getGmlId()).thenReturn(new GmlId("b2"));
model.addBuilding(b1);
assertEquals(b1, model.getBuildings().toList().get(0));
model.replaceFeature(b1, b2);
......@@ -410,9 +405,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceBuildingMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Building b1 = Mockito.mock(Building.class);
Building b2 = Mockito.mock(Building.class);
model.replaceFeature(b1, b2);
......@@ -420,11 +413,11 @@ public class CityDoctorModelTest {
@Test
public void testReplaceBridge() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
BridgeObject b1 = Mockito.mock(BridgeObject.class);
Mockito.when(b1.getGmlId()).thenReturn(new GmlId("b1"));
BridgeObject b2 = Mockito.mock(BridgeObject.class);
Mockito.when(b2.getGmlId()).thenReturn(new GmlId("b2"));
model.addBridge(b1);
assertEquals(b1, model.getBridges().toList().get(0));
model.replaceFeature(b1, b2);
......@@ -434,9 +427,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceBridgeMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
BridgeObject b1 = Mockito.mock(BridgeObject.class);
BridgeObject b2 = Mockito.mock(BridgeObject.class);
model.replaceFeature(b1, b2);
......@@ -444,11 +435,12 @@ public class CityDoctorModelTest {
@Test
public void testReplaceVegetation() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Vegetation v1 = Mockito.mock(Vegetation.class);
Mockito.when(v1.getGmlId()).thenReturn(new GmlId("v1"));
Vegetation v2 = Mockito.mock(Vegetation.class);
Mockito.when(v2.getGmlId()).thenReturn(new GmlId("v2"));
model.addVegetation(v1);
assertEquals(v1, model.getVegetation().toList().get(0));
model.replaceFeature(v1, v2);
......@@ -458,9 +450,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceVegetationMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Vegetation v1 = Mockito.mock(Vegetation.class);
Vegetation v2 = Mockito.mock(Vegetation.class);
model.replaceFeature(v1, v2);
......@@ -468,11 +458,12 @@ public class CityDoctorModelTest {
@Test
public void testReplaceTunnel() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Tunnel t1 = Mockito.mock(Tunnel.class);
Mockito.when(t1.getGmlId()).thenReturn(new GmlId("t1"));
Tunnel t2 = Mockito.mock(Tunnel.class);
Mockito.when(t2.getGmlId()).thenReturn(new GmlId("t2"));
model.addTunnel(t1);
assertEquals(t1, model.getTunnels().toList().get(0));
model.replaceFeature(t1, t2);
......@@ -482,9 +473,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceTunnelMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
Tunnel t1 = Mockito.mock(Tunnel.class);
Tunnel t2 = Mockito.mock(Tunnel.class);
model.replaceFeature(t1, t2);
......@@ -492,11 +481,12 @@ public class CityDoctorModelTest {
@Test
public void testReplaceTransportation() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
TransportationObject t1 = Mockito.mock(TransportationObject.class);
Mockito.when(t1.getGmlId()).thenReturn(new GmlId("t1"));
TransportationObject t2 = Mockito.mock(TransportationObject.class);
Mockito.when(t2.getGmlId()).thenReturn(new GmlId("t2"));
model.addTransportation(t1);
assertEquals(t1, model.getTransportation().toList().get(0));
model.replaceFeature(t1, t2);
......@@ -506,9 +496,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceTransportationMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
TransportationObject t1 = Mockito.mock(TransportationObject.class);
TransportationObject t2 = Mockito.mock(TransportationObject.class);
model.replaceFeature(t1, t2);
......@@ -516,11 +504,12 @@ public class CityDoctorModelTest {
@Test
public void testReplaceLand() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
LandObject lo1 = Mockito.mock(LandObject.class);
Mockito.when(lo1.getGmlId()).thenReturn(new GmlId("lo1"));
LandObject lo2 = Mockito.mock(LandObject.class);
Mockito.when(lo2.getGmlId()).thenReturn(new GmlId("lo2"));
model.addLand(lo1);
assertEquals(lo1, model.getLand().toList().get(0));
model.replaceFeature(lo1, lo2);
......@@ -530,9 +519,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceLandMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
LandObject lo1 = Mockito.mock(LandObject.class);
LandObject lo2 = Mockito.mock(LandObject.class);
model.replaceFeature(lo1, lo2);
......@@ -540,11 +527,12 @@ public class CityDoctorModelTest {
@Test
public void testReplaceWater() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
WaterObject t1 = Mockito.mock(WaterObject.class);
Mockito.when(t1.getGmlId()).thenReturn(new GmlId("t1"));
WaterObject t2 = Mockito.mock(WaterObject.class);
Mockito.when(t2.getGmlId()).thenReturn(new GmlId("t2"));
model.addWater(t1);
assertEquals(t1, model.getWater().toList().get(0));
model.replaceFeature(t1, t2);
......@@ -554,9 +542,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceWaterMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
WaterObject t1 = Mockito.mock(WaterObject.class);
WaterObject t2 = Mockito.mock(WaterObject.class);
model.replaceFeature(t1, t2);
......@@ -564,11 +550,12 @@ public class CityDoctorModelTest {
@Test
public void testReplaceCityFurniture() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
CityFurniture cf1 = Mockito.mock(CityFurniture.class);
Mockito.when(cf1.getGmlId()).thenReturn(new GmlId("cf1"));
CityFurniture cf2 = Mockito.mock(CityFurniture.class);
Mockito.when(cf2.getGmlId()).thenReturn(new GmlId("cf2"));
model.addCityFurniture(cf1);
assertEquals(cf1, model.getCityFurniture().toList().get(0));
model.replaceFeature(cf1, cf2);
......@@ -578,9 +565,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceCityFurnitureMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
CityFurniture cf1 = Mockito.mock(CityFurniture.class);
CityFurniture cf2 = Mockito.mock(CityFurniture.class);
model.replaceFeature(cf1, cf2);
......@@ -588,11 +573,12 @@ public class CityDoctorModelTest {
@Test
public void testReplaceGenericCityObject() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
GenericCityObject gco1 = Mockito.mock(GenericCityObject.class);
Mockito.when(gco1.getGmlId()).thenReturn(new GmlId("gco1"));
GenericCityObject gco2 = Mockito.mock(GenericCityObject.class);
Mockito.when(gco2.getGmlId()).thenReturn(new GmlId("gco2"));
model.addGenericCityObject(gco1);
assertEquals(gco1, model.getGenericCityObjects().toList().get(0));
model.replaceFeature(gco1, gco2);
......@@ -602,9 +588,7 @@ public class CityDoctorModelTest {
@Test(expected = IllegalStateException.class)
public void testReplaceGenericCityObjectMissing() {
File f = Mockito.mock(File.class);
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = new CityDoctorModel(config, f);
CityDoctorModel model = new CityDoctorModel(config, mockFile);
GenericCityObject gco1 = Mockito.mock(GenericCityObject.class);
GenericCityObject gco2 = Mockito.mock(GenericCityObject.class);
model.replaceFeature(gco1, gco2);
......
......@@ -45,12 +45,12 @@ public class FilterTest {
Checker c = new Checker(config, model);
c.runChecks();
Building b = model.getBuildings().get(0);
Building b = model.getBuildings().toList().get(0);
Geometry geom = b.getGeometries().get(0);
assertFalse(geom.hasCheckResults());
TransportationObject to = model.getTransportation().get(0);
TransportationObject to = model.getTransportation().toList().get(0);
Geometry geom2 = to.getGeometries().get(0);
assertTrue(geom2.getPolygons().get(0).hasCheckResults());
......@@ -65,12 +65,12 @@ public class FilterTest {
Checker c = new Checker(config, model);
c.runChecks();
Building b = model.getBuildings().get(0);
Building b = model.getBuildings().toList().get(0);
Geometry geom = b.getGeometries().get(0);
assertFalse(geom.hasCheckResults());
TransportationObject to = model.getTransportation().get(0);
TransportationObject to = model.getTransportation().toList().get(0);
Geometry geom2 = to.getGeometries().get(0);
assertTrue(geom2.getPolygons().get(0).hasCheckResults());
......
......@@ -35,7 +35,7 @@ public class SolidSelfIntCheckFalsePositiveBigMeshTest {
CityDoctorModel m = CityGmlParser.parseCityGmlFile(gml_filepath, config.getParserConfiguration());
Checker c = new Checker(config, m);
c.runChecks();
Building building = m.getBuildings().get(0);
Building building = m.getBuildings().toList().get(0);
/*
* The examples have no actual self-intersections, but can contain other actual model defects.
* If an error is detected, it is thus required to check if the
......
......@@ -75,7 +75,7 @@ public class SolidSelfIntCheckTest {
CityDoctorModel m = CityGmlParser.parseCityGmlFile("src/test/resources/SolidSelfIntTest1.gml", config.getParserConfiguration());
Checker c = new Checker(config, m);
c.runChecks();
assertFalse(m.getBuildings().get(0).containsAnyError());
assertFalse(m.getBuildings().toList().get(0).containsAnyError());
}
......@@ -85,7 +85,7 @@ public class SolidSelfIntCheckTest {
CityDoctorModel m = CityGmlParser.parseCityGmlFile(gml_filepath, config.getParserConfiguration());
Checker c = new Checker(config, m);
c.runChecks();
Building building = m.getBuildings().get(0);
Building building = m.getBuildings().toList().get(0);
/*
* The examples have no actual self-intersections, but can contain other actual model defects.
* If an error is detected, it is thus required to check if the
......
......@@ -48,7 +48,7 @@ public class AllPolygonWrongOrientedTest {
Checker c = new Checker(config, model);
c.runChecks();
Building b = model.getBuildings().get(0);
Building b = model.getBuildings().toList().get(0);
assertFalse(b.containsError(CheckId.C_GE_S_ALL_POLYGONS_WRONG_ORIENTATION));
}
......
......@@ -51,7 +51,7 @@ public class ConCompCheckTest extends TestCleanUp {
Checker c = new Checker(m);
c.runChecks();
Geometry geom = m.getBuildings().get(0).getGeometries().get(0);
Geometry geom = m.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = geom.getCheckResult(CheckId.C_GE_S_MULTIPLE_CONNECTED_COMPONENTS);
assertNotNull(cr);
assertEquals(ResultStatus.ERROR, cr.getResultStatus());
......@@ -65,7 +65,7 @@ public class ConCompCheckTest extends TestCleanUp {
Checker c = new Checker(m);
c.runChecks();
Geometry geom = m.getBuildings().get(0).getGeometries().get(0);
Geometry geom = m.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = geom.getCheckResult(CheckId.C_GE_S_MULTIPLE_CONNECTED_COMPONENTS);
assertNotNull(cr);
assertEquals(ResultStatus.ERROR, cr.getResultStatus());
......
......@@ -79,7 +79,7 @@ public class DupPointsCheckTest {
@Test
public void testDupPoints3() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel m = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS.gml");
for (Polygon p : m.getBuildings().get(0).getGeometries().get(0).getPolygons()) {
for (Polygon p : m.getBuildings().toList().get(0).getGeometries().get(0).getPolygons()) {
LinearRing r = p.getExteriorRing();
CheckResult cr = r.getCheckResult(CheckId.C_GE_R_DUPLICATE_POINT);
assertEquals(ResultStatus.OK, cr.getResultStatus());
......
......@@ -43,7 +43,7 @@ public class HoleOutsideSystemTest {
@Test
public void testHoleOutside1() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS-GE-gml-PO-0001-T0002.gml");
for (Polygon p : c.getBuildings().get(0).getGeometries().get(0).getPolygons()) {
for (Polygon p : c.getBuildings().toList().get(0).getGeometries().get(0).getPolygons()) {
CheckResult cr = p.getCheckResult(CheckId.C_GE_P_HOLE_OUTSIDE);
assertEquals(ResultStatus.OK, cr.getResultStatus());
}
......
......@@ -43,7 +43,7 @@ public class InnerRingsNestedSystemTest {
@Test
public void innerRingsNested1() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS-GE-gml-PO-0001-T0002.gml");
for (Polygon p : c.getBuildings().get(0).getGeometries().get(0).getPolygons()) {
for (Polygon p : c.getBuildings().toList().get(0).getGeometries().get(0).getPolygons()) {
CheckResult cr = p.getCheckResult(CheckId.C_GE_P_INNER_RINGS_NESTED);
assertEquals(ResultStatus.OK, cr.getResultStatus());
}
......
......@@ -43,7 +43,7 @@ public class InteriorDisconnectedSystemTest {
@Test
public void testInteriorDisconnected1() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS-GE-gml-PO-0001-T0002.gml");
for (Polygon p : c.getBuildings().get(0).getGeometries().get(0).getPolygons()) {
for (Polygon p : c.getBuildings().toList().get(0).getGeometries().get(0).getPolygons()) {
CheckResult cr = p.getCheckResult(CheckId.C_GE_P_INTERIOR_DISCONNECTED);
assertEquals(ResultStatus.OK, cr.getResultStatus());
}
......
......@@ -43,7 +43,7 @@ public class MultipleComponentTest {
@Test
public void testNoMultipleComponents() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS.gml");
Geometry g = c.getBuildings().get(0).getGeometries().get(0);
Geometry g = c.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = g.getCheckResult(CheckId.C_GE_S_MULTIPLE_CONNECTED_COMPONENTS);
assertEquals(ResultStatus.OK, cr.getResultStatus());
}
......@@ -51,7 +51,7 @@ public class MultipleComponentTest {
@Test
public void testMultipleComponents() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS-GE-gml-SO-0005-T0001.gml");
Geometry g = c.getBuildings().get(0).getGeometries().get(0);
Geometry g = c.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = g.getCheckResult(CheckId.C_GE_S_MULTIPLE_CONNECTED_COMPONENTS);
assertEquals(ResultStatus.ERROR, cr.getResultStatus());
assertEquals(ErrorId.GE_S_MULTIPLE_CONNECTED_COMPONENTS, cr.getError().getErrorId());
......
......@@ -46,7 +46,7 @@ public class NonManifoldEdgeSystemTest {
@Test
public void testNonManifoldEdge1() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS.gml");
Geometry g = c.getBuildings().get(0).getGeometries().get(0);
Geometry g = c.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = g.getCheckResult(CheckId.C_GE_S_NON_MANIFOLD_EDGE);
assertEquals(ResultStatus.OK, cr.getResultStatus());
}
......@@ -59,7 +59,7 @@ public class NonManifoldEdgeSystemTest {
paramMap.put(RequirementId.R_GE_P_NON_PLANAR.toString(), parameter);
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS-GE-gml-SO-0004-T0001.gml",
paramMap);
Geometry g = c.getBuildings().get(0).getGeometries().get(0);
Geometry g = c.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = g.getCheckResult(CheckId.C_GE_S_NON_MANIFOLD_EDGE);
assertEquals(ResultStatus.ERROR, cr.getResultStatus());
assertEquals(ErrorId.GE_S_NON_MANIFOLD_EDGE, cr.getError().getErrorId());
......
......@@ -43,7 +43,7 @@ public class NonManifoldVertexSystemTest {
@Test
public void testNonManifoldVertex1() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS.gml");
Geometry g = c.getBuildings().get(0).getGeometries().get(0);
Geometry g = c.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = g.getCheckResult(CheckId.C_GE_S_NON_MANIFOLD_VERTEX);
assertEquals(ResultStatus.OK, cr.getResultStatus());
}
......@@ -51,7 +51,7 @@ public class NonManifoldVertexSystemTest {
@Test
public void testNonManifoldVertex2() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS-GE-gml-SO-0003-T0001.gml");
Geometry g = c.getBuildings().get(0).getGeometries().get(0);
Geometry g = c.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = g.getCheckResult(CheckId.C_GE_S_NON_MANIFOLD_VERTEX);
assertEquals(ResultStatus.ERROR, cr.getResultStatus());
assertEquals(ErrorId.GE_S_NON_MANIFOLD_VERTEX, cr.getError().getErrorId());
......
......@@ -80,7 +80,7 @@ public class NumPointsCheckTest {
public void testNumPoints3() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS.gml");
for (Polygon p : c.getBuildings().get(0).getGeometries().get(0).getPolygons()) {
for (Polygon p : c.getBuildings().toList().get(0).getGeometries().get(0).getPolygons()) {
LinearRing r = p.getExteriorRing();
assertEquals(ResultStatus.OK, r.getCheckResult(CheckId.C_GE_R_TOO_FEW_POINTS).getResultStatus());
}
......
......@@ -43,7 +43,7 @@ public class OrientationSameSystemTest {
@Test
public void testOrientationSame1() throws CityGmlParseException, IOException, InvalidGmlFileException {
CityDoctorModel c = TestUtil.loadAndCheckCityModel("src/test/resources/SimpleSolid_SrefBS-GE-gml-PO-0001-T0002.gml");
for (Polygon p : c.getBuildings().get(0).getGeometries().get(0).getPolygons()) {
for (Polygon p : c.getBuildings().toList().get(0).getGeometries().get(0).getPolygons()) {
CheckResult cr = p.getCheckResult(CheckId.C_GE_P_ORIENTATION_RINGS_SAME);
assertEquals(ResultStatus.OK, cr.getResultStatus());
}
......
......@@ -71,7 +71,7 @@ public class OuterEdgeCheckTest {
expectedErrorEdges.add(new Vertex(1.0, 0.0, 3.5));
expectedErrorEdges.add(new Vertex(2.0, 0.0, 3.0));
Geometry geom = m.getBuildings().get(0).getGeometries().get(0);
Geometry geom = m.getBuildings().toList().get(0).getGeometries().get(0);
CheckResult cr = geom.getCheckResult(CheckId.C_GE_S_NOT_CLOSED);
Assert.assertEquals(ResultStatus.ERROR, cr.getResultStatus());
}
......
Supports Markdown
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