Commit f95ca9ff authored by Matthias Betz's avatar Matthias Betz
Browse files

fixed error adapter

fixed tests
added service meta inf
fixed various other issues
parent af713a75
...@@ -33,7 +33,7 @@ public class CityObjectPropertiesAdapter implements ObjectBuilder<CityObjectProp ...@@ -33,7 +33,7 @@ public class CityObjectPropertiesAdapter implements ObjectBuilder<CityObjectProp
return; return;
} }
switch (name.getLocalPart()) { switch (name.getLocalPart()) {
case "validationResult" -> object.setValidationResult(reader.getObjectUsingBuilder(ValidationResultPropertyAdapter.class)); case "ValidationResult" -> object.setValidationResult(reader.getObjectUsingBuilder(ValidationResultPropertyAdapter.class));
default -> throw new IllegalStateException("Cannot handle name " + name + " when building CityObjectProperties element"); default -> throw new IllegalStateException("Cannot handle name " + name + " when building CityObjectProperties element");
} }
} }
......
package de.hft.stuttgart.quality.adapter.types; package de.hft.stuttgart.quality.adapter.types;
import de.hft.stuttgart.quality.model.enums.ErrorId; import javax.xml.namespace.QName;
import de.hft.stuttgart.quality.model.types.Error;
import de.hft.stuttgart.quality.QualityADEModule; import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException; import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder; import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException; import org.xmlobjects.serializer.ObjectSerializeException;
...@@ -16,8 +15,11 @@ import org.xmlobjects.xml.Attributes; ...@@ -16,8 +15,11 @@ import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element; import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces; import org.xmlobjects.xml.Namespaces;
import javax.xml.namespace.QName; import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.enums.ErrorId;
import de.hft.stuttgart.quality.model.types.Error;
@XMLElement(name = "Error", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class ErrorAdapter implements ObjectBuilder<Error>, ObjectSerializer<Error> { public class ErrorAdapter implements ObjectBuilder<Error>, ObjectSerializer<Error> {
@Override @Override
...@@ -38,6 +40,11 @@ public class ErrorAdapter implements ObjectBuilder<Error>, ObjectSerializer<Erro ...@@ -38,6 +40,11 @@ public class ErrorAdapter implements ObjectBuilder<Error>, ObjectSerializer<Erro
} }
} }
@Override
public Element createElement(Error object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Error");
}
@Override @Override
public void writeChildElements(Error object, Namespaces namespaces, XMLWriter writer) public void writeChildElements(Error object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException { throws ObjectSerializeException, XMLWriteException {
......
...@@ -16,7 +16,9 @@ import org.xmlobjects.xml.Element; ...@@ -16,7 +16,9 @@ import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces; import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule; import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.ErrorPropertyAdapter;
import de.hft.stuttgart.quality.adapter.properties.FeatureStatisticsPropertyAdapter; import de.hft.stuttgart.quality.adapter.properties.FeatureStatisticsPropertyAdapter;
import de.hft.stuttgart.quality.model.properties.ErrorProperty;
import de.hft.stuttgart.quality.model.types.Statistics; import de.hft.stuttgart.quality.model.types.Statistics;
@XMLElement(name = "Statistics", namespaceURI = QualityADEModule.NAMESPACE_URI) @XMLElement(name = "Statistics", namespaceURI = QualityADEModule.NAMESPACE_URI)
...@@ -46,6 +48,7 @@ public class StatisticsAdapter implements ObjectBuilder<Statistics>, ObjectSeria ...@@ -46,6 +48,7 @@ public class StatisticsAdapter implements ObjectBuilder<Statistics>, ObjectSeria
.setNumErrorWaterObjects(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class)); .setNumErrorWaterObjects(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class));
case "numErrorTransportation" -> object case "numErrorTransportation" -> object
.setNumErrorTransportation(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class)); .setNumErrorTransportation(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class));
case "error" -> object.getErrors().add(reader.getObjectUsingBuilder(ErrorPropertyAdapter.class));
default -> throw new IllegalStateException("Cannot handle name " + name + " when building Statistics element"); default -> throw new IllegalStateException("Cannot handle name " + name + " when building Statistics element");
} }
} }
...@@ -82,5 +85,9 @@ public class StatisticsAdapter implements ObjectBuilder<Statistics>, ObjectSeria ...@@ -82,5 +85,9 @@ public class StatisticsAdapter implements ObjectBuilder<Statistics>, ObjectSeria
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "numErrorTransportation"), writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "numErrorTransportation"),
object.getNumErrorTransportation(), FeatureStatisticsPropertyAdapter.class, namespaces); object.getNumErrorTransportation(), FeatureStatisticsPropertyAdapter.class, namespaces);
} }
for (ErrorProperty errorProp : object.getErrors()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "error"), errorProp,
ErrorPropertyAdapter.class, namespaces);
}
} }
} }
...@@ -28,6 +28,15 @@ public class FeatureStatistics extends GMLObject implements ADEObject { ...@@ -28,6 +28,15 @@ public class FeatureStatistics extends GMLObject implements ADEObject {
private int numChecked; private int numChecked;
private int numErrors; private int numErrors;
public FeatureStatistics() {
// constructor for serialization
}
public FeatureStatistics(int numChecked, int numErrors) {
this.numChecked = numChecked;
this.numErrors = numErrors;
}
public int getNumChecked() { public int getNumChecked() {
return numChecked; return numChecked;
} }
......
de.hft.stuttgart.quality.QualityADEContext
\ No newline at end of file
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package de.hft.stuttgart.quality; package de.hft.stuttgart.quality;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
...@@ -22,10 +23,15 @@ import java.io.ByteArrayOutputStream; ...@@ -22,10 +23,15 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.transform.Source; import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema; import javax.xml.validation.Schema;
...@@ -37,11 +43,17 @@ import org.citygml4j.core.ade.ADERegistry; ...@@ -37,11 +43,17 @@ import org.citygml4j.core.ade.ADERegistry;
import org.citygml4j.core.model.CityGMLVersion; import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.building.Building; import org.citygml4j.core.model.building.Building;
import org.citygml4j.core.model.core.AbstractCityObjectProperty; import org.citygml4j.core.model.core.AbstractCityObjectProperty;
import org.citygml4j.core.model.core.AbstractFeature;
import org.citygml4j.core.model.core.AbstractFeatureProperty; import org.citygml4j.core.model.core.AbstractFeatureProperty;
import org.citygml4j.core.model.core.CityModel; import org.citygml4j.core.model.core.CityModel;
import org.citygml4j.core.util.CityGMLConstants;
import org.citygml4j.xml.CityGMLContext; import org.citygml4j.xml.CityGMLContext;
import org.citygml4j.xml.CityGMLContextException; import org.citygml4j.xml.CityGMLContextException;
import org.citygml4j.xml.module.citygml.CoreModule; import org.citygml4j.xml.module.citygml.CoreModule;
import org.citygml4j.xml.reader.ChunkOptions;
import org.citygml4j.xml.reader.CityGMLInputFactory;
import org.citygml4j.xml.reader.CityGMLReadException;
import org.citygml4j.xml.reader.CityGMLReader;
import org.citygml4j.xml.schema.CityGMLSchemaHandler; import org.citygml4j.xml.schema.CityGMLSchemaHandler;
import org.citygml4j.xml.writer.CityGMLOutputFactory; import org.citygml4j.xml.writer.CityGMLOutputFactory;
import org.citygml4j.xml.writer.CityGMLWriteException; import org.citygml4j.xml.writer.CityGMLWriteException;
...@@ -57,6 +69,7 @@ import org.xmlobjects.gml.model.measures.Angle; ...@@ -57,6 +69,7 @@ import org.xmlobjects.gml.model.measures.Angle;
import org.xmlobjects.gml.model.measures.Length; import org.xmlobjects.gml.model.measures.Length;
import org.xmlobjects.schema.SchemaHandlerException; import org.xmlobjects.schema.SchemaHandlerException;
import de.hft.stuttgart.quality.model.enums.ErrorId;
import de.hft.stuttgart.quality.model.enums.RequirementId; import de.hft.stuttgart.quality.model.enums.RequirementId;
import de.hft.stuttgart.quality.model.enums.ResultType; import de.hft.stuttgart.quality.model.enums.ResultType;
import de.hft.stuttgart.quality.model.enums.RingSelfIntType; import de.hft.stuttgart.quality.model.enums.RingSelfIntType;
...@@ -65,6 +78,7 @@ import de.hft.stuttgart.quality.model.properties.AbstractErrorProperty; ...@@ -65,6 +78,7 @@ import de.hft.stuttgart.quality.model.properties.AbstractErrorProperty;
import de.hft.stuttgart.quality.model.properties.CheckingProperty; import de.hft.stuttgart.quality.model.properties.CheckingProperty;
import de.hft.stuttgart.quality.model.properties.EdgeListProperty; import de.hft.stuttgart.quality.model.properties.EdgeListProperty;
import de.hft.stuttgart.quality.model.properties.EdgeProperty; import de.hft.stuttgart.quality.model.properties.EdgeProperty;
import de.hft.stuttgart.quality.model.properties.ErrorProperty;
import de.hft.stuttgart.quality.model.properties.FeatureStatisticsProperty; import de.hft.stuttgart.quality.model.properties.FeatureStatisticsProperty;
import de.hft.stuttgart.quality.model.properties.FilterProperty; import de.hft.stuttgart.quality.model.properties.FilterProperty;
import de.hft.stuttgart.quality.model.properties.GlobalParametersProperty; import de.hft.stuttgart.quality.model.properties.GlobalParametersProperty;
...@@ -112,15 +126,44 @@ import de.hft.stuttgart.quality.model.types.ValidationResult; ...@@ -112,15 +126,44 @@ import de.hft.stuttgart.quality.model.types.ValidationResult;
class QualityAdeTests { class QualityAdeTests {
private static final String CITY_OBJECT_MEMBER = "cityObjectMember";
private static List<QName> chunkProperties = new ArrayList<>();
static {
chunkProperties.add(new QName(CityGMLConstants.CITYGML_1_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER));
chunkProperties.add(new QName(CityGMLConstants.CITYGML_2_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER));
chunkProperties.add(new QName(CityGMLConstants.CITYGML_3_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER));
}
@BeforeAll @BeforeAll
static void setUsLocale() throws ADEException { static void setUsLocale() throws ADEException {
Locale.setDefault(Locale.US); Locale.setDefault(Locale.US);
ADERegistry.getInstance().loadADE(new QualityADEContext()); ADERegistry.getInstance().loadADE(new QualityADEContext());
} }
@Test
void testReadingModel() throws CityGMLContextException, CityGMLReadException {
CityGMLContext context = CityGMLContext.newInstance();
CityGMLInputFactory in = context.createCityGMLInputFactory()
.withChunking(ChunkOptions.chunkByProperties(chunkProperties).skipCityModel(false));
Path file = Paths.get("src/test/resources/SimpleSolid_Error_QualityADE.gml");
try (CityGMLReader reader = in.createCityGMLReader(file)) {
while (reader.hasNext()) {
AbstractFeature feature = reader.next();
if (feature instanceof Building) {
List<CityObjectProperties> adeProperties = feature.getADEProperties(CityObjectProperties.class);
assertEquals(1, adeProperties.size());
}
}
}
}
@Test @Test
void testAllPolygonsOrientedWrong() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testAllPolygonsOrientedWrong() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -133,7 +176,8 @@ class QualityAdeTests { ...@@ -133,7 +176,8 @@ class QualityAdeTests {
} }
@Test @Test
void testConsecutivePointsSameError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testConsecutivePointsSameError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -148,7 +192,8 @@ class QualityAdeTests { ...@@ -148,7 +192,8 @@ class QualityAdeTests {
} }
@Test @Test
void testHoleOutsideError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testHoleOutsideError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException,
IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -162,7 +207,8 @@ class QualityAdeTests { ...@@ -162,7 +207,8 @@ class QualityAdeTests {
} }
@Test @Test
void testInnerRingsNestedError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testInnerRingsNestedError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException,
IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -177,7 +223,8 @@ class QualityAdeTests { ...@@ -177,7 +223,8 @@ class QualityAdeTests {
} }
@Test @Test
void testInteriorDisconnectedError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testInteriorDisconnectedError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -190,7 +237,8 @@ class QualityAdeTests { ...@@ -190,7 +237,8 @@ class QualityAdeTests {
} }
@Test @Test
void testIntersectingRingsError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testIntersectingRingsError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException,
IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -205,7 +253,8 @@ class QualityAdeTests { ...@@ -205,7 +253,8 @@ class QualityAdeTests {
} }
@Test @Test
void testMultipleComponentsError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testMultipleComponentsError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -222,7 +271,8 @@ class QualityAdeTests { ...@@ -222,7 +271,8 @@ class QualityAdeTests {
} }
@Test @Test
void testNonManifoldEdgeError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testNonManifoldEdgeError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException,
IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -242,7 +292,8 @@ class QualityAdeTests { ...@@ -242,7 +292,8 @@ class QualityAdeTests {
} }
@Test @Test
void testNonManifoldVertexError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testNonManifoldVertexError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException,
IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -256,7 +307,8 @@ class QualityAdeTests { ...@@ -256,7 +307,8 @@ class QualityAdeTests {
} }
@Test @Test
void testOrientationRingsSameError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testOrientationRingsSameError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -270,7 +322,8 @@ class QualityAdeTests { ...@@ -270,7 +322,8 @@ class QualityAdeTests {
} }
@Test @Test
void testPlanarDistancePlaneError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testPlanarDistancePlaneError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -285,7 +338,8 @@ class QualityAdeTests { ...@@ -285,7 +338,8 @@ class QualityAdeTests {
} }
@Test @Test
void testPlanarNormalsDeviationError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testPlanarNormalsDeviationError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -299,7 +353,8 @@ class QualityAdeTests { ...@@ -299,7 +353,8 @@ class QualityAdeTests {
} }
@Test @Test
void testPolygonWrongOrientationError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testPolygonWrongOrientationError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -318,7 +373,8 @@ class QualityAdeTests { ...@@ -318,7 +373,8 @@ class QualityAdeTests {
} }
@Test @Test
void testRingNotClosedError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testRingNotClosedError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException,
IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -331,7 +387,8 @@ class QualityAdeTests { ...@@ -331,7 +387,8 @@ class QualityAdeTests {
} }
@Test @Test
void testRingSelfIntersectionError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testRingSelfIntersectionError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -351,7 +408,8 @@ class QualityAdeTests { ...@@ -351,7 +408,8 @@ class QualityAdeTests {
} }
@Test @Test
void testRingTooFewPointsError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testRingTooFewPointsError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException,
IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -364,7 +422,8 @@ class QualityAdeTests { ...@@ -364,7 +422,8 @@ class QualityAdeTests {
} }
@Test @Test
void testSemanticAttributeMissingError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testSemanticAttributeMissingError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -379,7 +438,8 @@ class QualityAdeTests { ...@@ -379,7 +438,8 @@ class QualityAdeTests {
} }
@Test @Test
void testSemanticAttributeWrongValueError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testSemanticAttributeWrongValueError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -394,7 +454,8 @@ class QualityAdeTests { ...@@ -394,7 +454,8 @@ class QualityAdeTests {
} }
@Test @Test
void testSolidNotClosedError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testSolidNotClosedError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException,
IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -413,7 +474,8 @@ class QualityAdeTests { ...@@ -413,7 +474,8 @@ class QualityAdeTests {
} }
@Test @Test
void testSolidSelfIntersectionError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testSolidSelfIntersectionError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -428,7 +490,8 @@ class QualityAdeTests { ...@@ -428,7 +490,8 @@ class QualityAdeTests {
} }
@Test @Test
void testSolidTooFewPolygonsError() throws ADEException, CityGMLContextException, CityGMLWriteException, SAXException, IOException, SchemaHandlerException { void testSolidTooFewPolygonsError() throws ADEException, CityGMLContextException, CityGMLWriteException,
SAXException, IOException, SchemaHandlerException {
CityModel model = new CityModel(); CityModel model = new CityModel();
ValidationResult res = fillCityModel(model); ValidationResult res = fillCityModel(model);
...@@ -440,9 +503,8 @@ class QualityAdeTests { ...@@ -440,9 +503,8 @@ class QualityAdeTests {
assertTrue(validate(new ByteArrayInputStream(buf))); assertTrue(validate(new ByteArrayInputStream(buf)));
} }
private boolean validate(InputStream stream)
throws SAXException, IOException, CityGMLContextException, SchemaHandlerException {
private boolean validate(InputStream stream) throws SAXException, IOException, CityGMLContextException, SchemaHandlerException {
CityGMLContext context = CityGMLContext.newInstance(); CityGMLContext context = CityGMLContext.newInstance();
...@@ -476,12 +538,10 @@ class QualityAdeTests { ...@@ -476,12 +538,10 @@ class QualityAdeTests {
} }
}); });
validator.validate(new StreamSource(stream)); validator.validate(new StreamSource(stream));
return !foundErrors[0]; return !foundErrors[0];
} }
private byte[] writeModel(CityModel model) throws ADEException, CityGMLContextException, CityGMLWriteException { private byte[] writeModel(CityModel model) throws ADEException, CityGMLContextException, CityGMLWriteException {
CityGMLContext context = CityGMLContext.newInstance(); CityGMLContext context = CityGMLContext.newInstance();
...@@ -490,10 +550,9 @@ class QualityAdeTests { ...@@ -490,10 +550,9 @@ class QualityAdeTests {
ByteArrayOutputStream outStream = new ByteArrayOutputStream(); ByteArrayOutputStream outStream = new ByteArrayOutputStream();
try (CityGMLWriter writer = out.createCityGMLWriter(outStream, StandardCharsets.UTF_8.name())) { try (CityGMLWriter writer = out.createCityGMLWriter(outStream, StandardCharsets.UTF_8.name())) {
writer.withIndent(" ") writer.withIndent(" ")
.withSchemaLocation(QualityADEModule.NAMESPACE_URI, getClass().getResource("/qualityAde.xsd").toString()) .withSchemaLocation(QualityADEModule.NAMESPACE_URI,
.withDefaultPrefixes() getClass().getResource("/qualityAde.xsd").toString())
.withDefaultNamespace(CoreModule.of(version).getNamespaceURI()) .withDefaultPrefixes().withDefaultNamespace(CoreModule.of(version).getNamespaceURI()).write(model);
.write(model);
} }
return outStream.toByteArray(); return outStream.toByteArray();
} }
...@@ -513,6 +572,11 @@ class QualityAdeTests { ...@@ -513,6 +572,11 @@ class QualityAdeTests {
stats.setNumErrorBridgeObjects(new FeatureStatisticsProperty(fStats)); stats.setNumErrorBridgeObjects(new FeatureStatisticsProperty(fStats));
v.setStatistics(new StatisticsProperty(stats)); v.setStatistics(new StatisticsProperty(stats));
de.hft.stuttgart.quality.model.types.Error err = new de.hft.stuttgart.quality.model.types.Error();
err.setName(ErrorId.GE_P_HOLE_OUTSIDE);
err.setOccurrences(1);
stats.getErrors().add(new ErrorProperty(err));
Requirement req = new Requirement(); Requirement req = new Requirement();
req.setEnabled(true); req.setEnabled(true);
req.setRequirementType(RequirementId.R_GE_P_HOLE_OUTSIDE); req.setRequirementType(RequirementId.R_GE_P_HOLE_OUTSIDE);
...@@ -535,7 +599,6 @@ class QualityAdeTests { ...@@ -535,7 +599,6 @@ class QualityAdeTests {
v.setValidationPlan(new ValidationPlanProperty(plan)); v.setValidationPlan(new ValidationPlanProperty(plan));
Building b = new Building(); Building b = new Building();
b.setId("testId"); b.setId("testId");
model.getCityObjectMembers().add(new AbstractCityObjectProperty(b)); model.getCityObjectMembers().add(new AbstractCityObjectProperty(b));
......
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