Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
d1ff5020
Commit
d1ff5020
authored
May 24, 2025
by
Beuster
Browse files
Merge remote-tracking branch 'origin/dev' into dev_cpp_code_conversion
parents
06ad5a8e
b50c5f13
Pipeline
#11130
passed with stage
in 1 minute and 28 seconds
Changes
179
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModelTest.java
View file @
d1ff5020
...
...
@@ -255,13 +255,13 @@ public class CityDoctorModelTest {
}
@Test
public
void
test
AddBridge
()
{
public
void
test
SetCityModel
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
BridgeObject
b
=
Mockito
.
mock
(
BridgeObject
.
class
);
model
.
addBridge
(
b
);
assertEquals
(
b
,
model
.
get
Bridges
().
get
(
0
));
CityModel
cModel
=
Mockito
.
mock
(
CityModel
.
class
);
model
.
setCityModel
(
cModel
);
assertEquals
(
cModel
,
model
.
get
CityModel
(
));
}
@Test
...
...
@@ -275,25 +275,47 @@ public class CityDoctorModelTest {
}
@Test
public
void
test
SetCityModel
()
{
public
void
test
AddBridge
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityModel
cModel
=
Mockito
.
mock
(
CityModel
.
class
);
model
.
setCityModel
(
cModel
);
assertEquals
(
cModel
,
model
.
get
CityModel
(
));
BridgeObject
b
=
Mockito
.
mock
(
BridgeObject
.
class
);
model
.
addBridge
(
b
);
assertEquals
(
b
,
model
.
get
Bridges
().
get
(
0
));
}
@Test
public
void
testAdd
Water
()
{
public
void
testAdd
Vegetation
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
WaterObject
water
=
Mockito
.
mock
(
WaterObject
.
class
);
model
.
add
Water
(
water
);
assertEquals
(
water
,
model
.
get
Water
().
get
(
0
));
Vegetation
veg
=
Mockito
.
mock
(
Vegetation
.
class
);
model
.
add
Vegetation
(
veg
);
assertEquals
(
veg
,
model
.
get
Vegetation
().
get
(
0
));
}
@Test
public
void
testAddTunnel
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
Tunnel
tunnel
=
Mockito
.
mock
(
Tunnel
.
class
);
model
.
addTunnel
(
tunnel
);
assertEquals
(
tunnel
,
model
.
getTunnels
().
get
(
0
));
}
@Test
public
void
testAddTransportation
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
TransportationObject
trans
=
Mockito
.
mock
(
TransportationObject
.
class
);
model
.
addTransportation
(
trans
);
assertEquals
(
trans
,
model
.
getTransportation
().
get
(
0
));
}
@Test
public
void
testAddLand
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
...
...
@@ -305,23 +327,33 @@ public class CityDoctorModelTest {
}
@Test
public
void
testAdd
Vegetation
()
{
public
void
testAdd
Water
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
Vegetation
veg
=
Mockito
.
mock
(
Vegetation
.
class
);
model
.
add
Vegetation
(
veg
);
assertEquals
(
veg
,
model
.
get
Vegetation
().
get
(
0
));
WaterObject
water
=
Mockito
.
mock
(
WaterObject
.
class
);
model
.
add
Water
(
water
);
assertEquals
(
water
,
model
.
get
Water
().
get
(
0
));
}
@Test
public
void
testAdd
Transportation
()
{
public
void
testAdd
CityFurniture
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
TransportationObject
trans
=
Mockito
.
mock
(
TransportationObject
.
class
);
model
.
addTransportation
(
trans
);
assertEquals
(
trans
,
model
.
getTransportation
().
get
(
0
));
CityFurniture
cf
=
Mockito
.
mock
(
CityFurniture
.
class
);
model
.
addCityFurniture
(
cf
);
assertEquals
(
cf
,
model
.
getCityFurniture
().
get
(
0
));
}
@Test
public
void
testAddGenericCityObject
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
GenericCityObject
gen
=
Mockito
.
mock
(
GenericCityObject
.
class
);
model
.
addGenericCityObject
(
gen
);
assertEquals
(
gen
,
model
.
getGenericCityObjects
().
get
(
0
));
}
@Test
...
...
@@ -329,11 +361,29 @@ public class CityDoctorModelTest {
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
Building
b
=
Mockito
.
mock
(
Building
.
class
);
BridgeObject
bo
=
Mockito
.
mock
(
BridgeObject
.
class
);
Vegetation
veg
=
Mockito
.
mock
(
Vegetation
.
class
);
Tunnel
tunnel
=
Mockito
.
mock
(
Tunnel
.
class
);
TransportationObject
trans
=
Mockito
.
mock
(
TransportationObject
.
class
);
LandObject
land
=
Mockito
.
mock
(
LandObject
.
class
);
WaterObject
water
=
Mockito
.
mock
(
WaterObject
.
class
);
CityFurniture
cf
=
Mockito
.
mock
(
CityFurniture
.
class
);
GenericCityObject
generic
=
Mockito
.
mock
(
GenericCityObject
.
class
);
model
.
addBuilding
(
b
);
model
.
addBridge
(
bo
);
model
.
addVegetation
(
veg
);
model
.
addTransportation
(
trans
);
assertEquals
(
2
,
model
.
getNumberOfFeatures
());
model
.
addTunnel
(
tunnel
);
model
.
addLand
(
land
);
model
.
addWater
(
water
);
model
.
addCityFurniture
(
cf
);
model
.
addGenericCityObject
(
generic
);
assertEquals
(
9
,
model
.
getNumberOfFeatures
());
}
@Test
...
...
@@ -355,6 +405,7 @@ public class CityDoctorModelTest {
assertEquals
(
b1
,
model
.
getBuildings
().
get
(
0
));
model
.
replaceFeature
(
b1
,
b2
);
assertEquals
(
b2
,
model
.
getBuildings
().
get
(
0
));
assertEquals
(
1
,
model
.
getBuildings
().
size
());
}
@Test
(
expected
=
IllegalStateException
.
class
)
...
...
@@ -366,6 +417,30 @@ public class CityDoctorModelTest {
Building
b2
=
Mockito
.
mock
(
Building
.
class
);
model
.
replaceFeature
(
b1
,
b2
);
}
@Test
public
void
testReplaceBridge
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
BridgeObject
b1
=
Mockito
.
mock
(
BridgeObject
.
class
);
BridgeObject
b2
=
Mockito
.
mock
(
BridgeObject
.
class
);
model
.
addBridge
(
b1
);
assertEquals
(
b1
,
model
.
getBridges
().
get
(
0
));
model
.
replaceFeature
(
b1
,
b2
);
assertEquals
(
b2
,
model
.
getBridges
().
get
(
0
));
assertEquals
(
1
,
model
.
getBridges
().
size
());
}
@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
);
BridgeObject
b1
=
Mockito
.
mock
(
BridgeObject
.
class
);
BridgeObject
b2
=
Mockito
.
mock
(
BridgeObject
.
class
);
model
.
replaceFeature
(
b1
,
b2
);
}
@Test
public
void
testReplaceVegetation
()
{
...
...
@@ -378,6 +453,7 @@ public class CityDoctorModelTest {
assertEquals
(
v1
,
model
.
getVegetation
().
get
(
0
));
model
.
replaceFeature
(
v1
,
v2
);
assertEquals
(
v2
,
model
.
getVegetation
().
get
(
0
));
assertEquals
(
1
,
model
.
getVegetation
().
size
());
}
@Test
(
expected
=
IllegalStateException
.
class
)
...
...
@@ -389,6 +465,30 @@ public class CityDoctorModelTest {
Vegetation
v2
=
Mockito
.
mock
(
Vegetation
.
class
);
model
.
replaceFeature
(
v1
,
v2
);
}
@Test
public
void
testReplaceTunnel
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
Tunnel
t1
=
Mockito
.
mock
(
Tunnel
.
class
);
Tunnel
t2
=
Mockito
.
mock
(
Tunnel
.
class
);
model
.
addTunnel
(
t1
);
assertEquals
(
t1
,
model
.
getTunnels
().
get
(
0
));
model
.
replaceFeature
(
t1
,
t2
);
assertEquals
(
t2
,
model
.
getTunnels
().
get
(
0
));
assertEquals
(
1
,
model
.
getTunnels
().
size
());
}
@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
);
Tunnel
t1
=
Mockito
.
mock
(
Tunnel
.
class
);
Tunnel
t2
=
Mockito
.
mock
(
Tunnel
.
class
);
model
.
replaceFeature
(
t1
,
t2
);
}
@Test
public
void
testReplaceTransportation
()
{
...
...
@@ -401,6 +501,7 @@ public class CityDoctorModelTest {
assertEquals
(
t1
,
model
.
getTransportation
().
get
(
0
));
model
.
replaceFeature
(
t1
,
t2
);
assertEquals
(
t2
,
model
.
getTransportation
().
get
(
0
));
assertEquals
(
1
,
model
.
getTransportation
().
size
());
}
@Test
(
expected
=
IllegalStateException
.
class
)
...
...
@@ -412,6 +513,30 @@ public class CityDoctorModelTest {
TransportationObject
t2
=
Mockito
.
mock
(
TransportationObject
.
class
);
model
.
replaceFeature
(
t1
,
t2
);
}
@Test
public
void
testReplaceLand
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
LandObject
lo1
=
Mockito
.
mock
(
LandObject
.
class
);
LandObject
lo2
=
Mockito
.
mock
(
LandObject
.
class
);
model
.
addLand
(
lo1
);
assertEquals
(
lo1
,
model
.
getLand
().
get
(
0
));
model
.
replaceFeature
(
lo1
,
lo2
);
assertEquals
(
lo2
,
model
.
getLand
().
get
(
0
));
assertEquals
(
1
,
model
.
getLand
().
size
());
}
@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
);
LandObject
lo1
=
Mockito
.
mock
(
LandObject
.
class
);
LandObject
lo2
=
Mockito
.
mock
(
LandObject
.
class
);
model
.
replaceFeature
(
lo1
,
lo2
);
}
@Test
public
void
testReplaceWater
()
{
...
...
@@ -424,6 +549,7 @@ public class CityDoctorModelTest {
assertEquals
(
t1
,
model
.
getWater
().
get
(
0
));
model
.
replaceFeature
(
t1
,
t2
);
assertEquals
(
t2
,
model
.
getWater
().
get
(
0
));
assertEquals
(
1
,
model
.
getWater
().
size
());
}
@Test
(
expected
=
IllegalStateException
.
class
)
...
...
@@ -436,4 +562,52 @@ public class CityDoctorModelTest {
model
.
replaceFeature
(
t1
,
t2
);
}
@Test
public
void
testReplaceCityFurniture
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityFurniture
cf1
=
Mockito
.
mock
(
CityFurniture
.
class
);
CityFurniture
cf2
=
Mockito
.
mock
(
CityFurniture
.
class
);
model
.
addCityFurniture
(
cf1
);
assertEquals
(
cf1
,
model
.
getCityFurniture
().
get
(
0
));
model
.
replaceFeature
(
cf1
,
cf2
);
assertEquals
(
cf2
,
model
.
getCityFurniture
().
get
(
0
));
assertEquals
(
1
,
model
.
getCityFurniture
().
size
());
}
@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
);
CityFurniture
cf1
=
Mockito
.
mock
(
CityFurniture
.
class
);
CityFurniture
cf2
=
Mockito
.
mock
(
CityFurniture
.
class
);
model
.
replaceFeature
(
cf1
,
cf2
);
}
@Test
public
void
testReplaceGenericCityObject
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
GenericCityObject
gco1
=
Mockito
.
mock
(
GenericCityObject
.
class
);
GenericCityObject
gco2
=
Mockito
.
mock
(
GenericCityObject
.
class
);
model
.
addGenericCityObject
(
gco1
);
assertEquals
(
gco1
,
model
.
getGenericCityObjects
().
get
(
0
));
model
.
replaceFeature
(
gco1
,
gco2
);
assertEquals
(
gco2
,
model
.
getGenericCityObjects
().
get
(
0
));
assertEquals
(
1
,
model
.
getGenericCityObjects
().
size
());
}
@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
);
GenericCityObject
gco1
=
Mockito
.
mock
(
GenericCityObject
.
class
);
GenericCityObject
gco2
=
Mockito
.
mock
(
GenericCityObject
.
class
);
model
.
replaceFeature
(
gco1
,
gco2
);
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/CityFurnitureTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
Mockito
.
mock
;
public
class
CityFurnitureTest
{
@Test
public
void
testContainsError
()
{
CityFurniture
cf
=
new
CityFurniture
();
assertFalse
(
cf
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
cf
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
cf
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
cf
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
cf
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
cf
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
cf
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
cf
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
CityFurniture
cf
=
new
CityFurniture
();
cf
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertEquals
(
1
,
cf
.
getAllCheckResults
().
size
());
cf
.
clearAllContainedCheckResults
();
assertTrue
(
cf
.
getAllCheckResults
().
isEmpty
());
}
@Test
public
void
testContainsAnyError
()
{
CityFurniture
cf
=
new
CityFurniture
();
assertFalse
(
cf
.
containsAnyError
());
cf
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
cf
.
containsAnyError
());
cf
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
cf
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
CityFurniture
cf
=
new
CityFurniture
();
cf
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
cf
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
unsetGmlGeometries
()
{
CityFurniture
cf
=
new
CityFurniture
();
org
.
citygml4j
.
core
.
model
.
cityfurniture
.
CityFurniture
cgmlCF
=
new
org
.
citygml4j
.
core
.
model
.
cityfurniture
.
CityFurniture
();
cf
.
setGmlObject
(
cgmlCF
);
cgmlCF
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
());
cgmlCF
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
cgmlCF
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
cgmlCF
.
setLod1Solid
(
null
);
cgmlCF
.
setLod2Solid
(
null
);
cgmlCF
.
setLod3Solid
(
null
);
cgmlCF
.
getDeprecatedProperties
().
setLod1Geometry
(
null
);
cgmlCF
.
getDeprecatedProperties
().
setLod2Geometry
(
null
);
cgmlCF
.
getDeprecatedProperties
().
setLod3Geometry
(
null
);
cgmlCF
.
getDeprecatedProperties
().
setLod4Geometry
(
null
);
cf
.
clearGmlGeometries
();
assertNull
(
cgmlCF
.
getLod0MultiSurface
());
assertNull
(
cgmlCF
.
getLod2MultiSurface
());
assertNull
(
cgmlCF
.
getLod3MultiSurface
());
assertNull
(
cgmlCF
.
getLod1Solid
());
assertNull
(
cgmlCF
.
getLod2Solid
());
assertNull
(
cgmlCF
.
getLod3Solid
());
assertNull
(
cgmlCF
.
getDeprecatedProperties
().
getLod1Geometry
());
assertNull
(
cgmlCF
.
getDeprecatedProperties
().
getLod2Geometry
());
assertNull
(
cgmlCF
.
getDeprecatedProperties
().
getLod3Geometry
());
assertNull
(
cgmlCF
.
getDeprecatedProperties
().
getLod4Geometry
());
}
@Test
public
void
testReCreateGeometriesSolid
()
{
CityFurniture
cf
=
new
CityFurniture
();
org
.
citygml4j
.
core
.
model
.
cityfurniture
.
CityFurniture
cgmlCF
=
new
org
.
citygml4j
.
core
.
model
.
cityfurniture
.
CityFurniture
();
cf
.
setGmlObject
(
cgmlCF
);
cf
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
cf
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
cf
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
cf
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
cgmlCF
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
cgmlCF
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
cgmlCF
.
getLod3Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
CityFurniture
cf
=
new
CityFurniture
();
org
.
citygml4j
.
core
.
model
.
cityfurniture
.
CityFurniture
cgmlCF
=
new
org
.
citygml4j
.
core
.
model
.
cityfurniture
.
CityFurniture
();
cf
.
setGmlObject
(
cgmlCF
);
cf
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
cf
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
cf
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
cf
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
cf
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
cf
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
cgmlCF
.
getLod0MultiSurface
());
assertNotNull
(
cgmlCF
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
cgmlCF
.
getLod2MultiSurface
());
assertNotNull
(
cgmlCF
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
cgmlCF
.
getLod3MultiSurface
());
assertNotNull
(
cgmlCF
.
getLod3MultiSurface
().
getObject
());
}
}
\ No newline at end of file
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/CityObjectTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
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.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.GmlGeometryRebuilder
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor
;
import
org.citygml4j.core.model.core.AbstractCityObject
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
public
class
CityObjectTest
{
CityObject
co
;
@Test
public
void
testVisitorPropagation
()
{
Geometry
mockGeometry
=
mock
(
Geometry
.
class
);
co
.
addGeometry
(
mockGeometry
);
CheckableUtilsVisitor
check
=
new
CheckableUtilsVisitor
()
{
};
co
.
accept
(
check
);
verify
(
mockGeometry
).
accept
(
check
);
}
@Test
public
void
testContainsError
()
{
assertFalse
(
co
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
co
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
co
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
co
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
co
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
co
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
co
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
co
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
co
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertEquals
(
1
,
co
.
getAllCheckResults
().
size
());
co
.
clearAllContainedCheckResults
();
assertTrue
(
co
.
getAllCheckResults
().
isEmpty
());
}
@Test
public
void
testContainsAnyError
()
{
assertFalse
(
co
.
containsAnyError
());
co
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
co
.
containsAnyError
());
co
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
co
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
co
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
co
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testClearGmlGeometries
()
{
CityObject
spyCo
=
Mockito
.
spy
(
co
);
spyCo
.
clearGmlGeometries
();
verify
(
spyCo
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
verify
(
spyCo
).
unsetGmlGeometries
();
}
@Test
public
void
testReCreateGmlGeometries
()
{
CityObject
spyCo
=
Mockito
.
spy
(
co
);
spyCo
.
reCreateGeometries
(
mock
(
GeometryFactory
.
class
),
mock
(
ParserConfiguration
.
class
));
verify
(
spyCo
).
accept
(
any
(
GmlGeometryRebuilder
.
class
));
verify
(
spyCo
).
rebuildGeometries
(
any
(
GeometryFactory
.
class
),
any
(
ParserConfiguration
.
class
));
}
@Test
public
void
testGetHighestLodGeometry
()
{
Geometry
geometryLod1
=
new
Geometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
);
Geometry
geometryLod2
=
new
Geometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
);
Geometry
geometryLod3
=
new
Geometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
);
Geometry
geometryLod4
=
new
Geometry
(
GeometryType
.
SOLID
,
Lod
.
LOD4
);
assertNull
(
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod1
);
assertEquals
(
geometryLod1
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod2
);
assertEquals
(
geometryLod2
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod3
);
assertEquals
(
geometryLod3
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod4
);
assertEquals
(
geometryLod4
,
co
.
getHighestLodGeometry
());
setUp
();
assertNull
(
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod2
);
assertEquals
(
geometryLod2
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod1
);
assertEquals
(
geometryLod2
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod3
);
assertEquals
(
geometryLod3
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod4
);
assertEquals
(
geometryLod4
,
co
.
getHighestLodGeometry
());
setUp
();
assertNull
(
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod4
);
assertEquals
(
geometryLod4
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod1
);
assertEquals
(
geometryLod4
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod2
);
assertEquals
(
geometryLod4
,
co
.
getHighestLodGeometry
());
co
.
addGeometry
(
geometryLod3
);
assertEquals
(
geometryLod4
,
co
.
getHighestLodGeometry
());
}
@Before
public
void
setUp
()
{
co
=
new
CityObject
()
{
@Override
public
void
rebuildGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
// Stub for testing
}
@Override
public
AbstractCityObject
getGmlObject
()
{
return
null
;
}
@Override
public
void
unsetGmlGeometries
()
{
// Stub for testing
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
null
;
}
@Override
public
FeatureType
getFeatureType
()
{
return
null
;
}
};
}
}
\ No newline at end of file
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/GenericCityObjectTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.model.generics.GenericOccupiedSpace
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.SolidProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
public
class
GenericCityObjectTest
{
@Test
public
void
testVisitorPropagation
()
{
GenericCityObject
gco
=
new
GenericCityObject
();
BoundarySurface
mockSurface
=
mock
(
BoundarySurface
.
class
);
Geometry
mockGeometry
=
mock
(
Geometry
.
class
);
gco
.
addBoundarySurface
(
mockSurface
);
gco
.
addGeometry
(
mockGeometry
);
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
};
gco
.
accept
(
c
);
verify
(
mockSurface
).
accept
(
c
);
verify
(
mockGeometry
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
GenericCityObject
gco
=
new
GenericCityObject
();
assertFalse
(
gco
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
gco
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
gco
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
gco
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
gco
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
gco
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
gco
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
gco
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
GenericCityObject
gco
=
new
GenericCityObject
();
gco
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertEquals
(
1
,
gco
.
getAllCheckResults
().
size
());
gco
.
clearAllContainedCheckResults
();
assertTrue
(
gco
.
getAllCheckResults
().
isEmpty
());
}
@Test
public
void
testContainsAnyError
()
{
GenericCityObject
gco
=
new
GenericCityObject
();
assertFalse
(
gco
.
containsAnyError
());
gco
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
gco
.
containsAnyError
());
gco
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
gco
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
GenericCityObject
gco
=
new
GenericCityObject
();
gco
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
gco
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGmlGeometries
()
{
GenericCityObject
gco
=
new
GenericCityObject
();
GenericOccupiedSpace
gmlGos
=
new
GenericOccupiedSpace
();
gco
.
setGmlObject
(
gmlGos
);
gmlGos
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
());
gmlGos
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
gmlGos
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
gmlGos
.
setLod1Solid
(
new
SolidProperty
());
gmlGos
.
setLod2Solid
(
new
SolidProperty
());
gmlGos
.
setLod3Solid
(
new
SolidProperty
());
gmlGos
.
getDeprecatedProperties
().
setLod1Geometry
(
new
MultiSurfaceProperty
());
gmlGos
.
getDeprecatedProperties
().
setLod2Geometry
(
new
MultiSurfaceProperty
());
gmlGos
.
getDeprecatedProperties
().
setLod3Geometry
(
new
MultiSurfaceProperty
());
gmlGos
.
getDeprecatedProperties
().
setLod4Geometry
(
new
MultiSurfaceProperty
());
gco
.
unsetGmlGeometries
();
assertNull
(
gmlGos
.
getLod0MultiSurface
());
assertNull
(
gmlGos
.
getLod2MultiSurface
());
assertNull
(
gmlGos
.
getLod3MultiSurface
());
assertNull
(
gmlGos
.
getLod1Solid
());
assertNull
(
gmlGos
.
getLod2Solid
());
assertNull
(
gmlGos
.
getLod3Solid
());
assertNull
(
gmlGos
.
getDeprecatedProperties
().
getLod1Geometry
());
assertNull
(
gmlGos
.
getDeprecatedProperties
().
getLod2Geometry
());
assertNull
(
gmlGos
.
getDeprecatedProperties
().
getLod3Geometry
());
assertNull
(
gmlGos
.
getDeprecatedProperties
().
getLod4Geometry
());
}
@Test
public
void
testReCreateGeometriesSolid
()
{
GenericCityObject
gco
=
new
GenericCityObject
();
GenericOccupiedSpace
gmlGos
=
new
GenericOccupiedSpace
();
gco
.
setGmlObject
(
gmlGos
);
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
gco
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlGos
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlGos
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlGos
.
getLod3Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
GenericCityObject
gco
=
new
GenericCityObject
();
GenericOccupiedSpace
gmlGos
=
new
GenericOccupiedSpace
();
gco
.
setGmlObject
(
gmlGos
);
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
gco
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
gco
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlGos
.
getLod0MultiSurface
());
assertNotNull
(
gmlGos
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlGos
.
getLod2MultiSurface
());
assertNotNull
(
gmlGos
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlGos
.
getLod3MultiSurface
());
assertNotNull
(
gmlGos
.
getLod3MultiSurface
().
getObject
());
}
}
\ No newline at end of file
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/GeometryTest.java
View file @
d1ff5020
...
...
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertSame
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
...
@@ -31,6 +32,8 @@ import static org.mockito.Mockito.when;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.ClearVisitorResultsVisitor
;
import
org.citygml4j.core.model.construction.AbstractConstructionSurface
;
import
org.citygml4j.core.model.construction.WallSurface
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
...
...
@@ -44,6 +47,7 @@ import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
org.mockito.Mockito
;
/**
*
...
...
@@ -52,6 +56,20 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
*/
public
class
GeometryTest
{
@Test
public
void
testVisitorPropagation
()
{
Geometry
geom
=
new
Geometry
(
GeometryType
.
SOLID
,
Lod
.
LOD0
);
ConcretePolygon
mockPolygon
=
mock
(
ConcretePolygon
.
class
);
geom
.
addPolygon
(
mockPolygon
);
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
};
geom
.
accept
(
c
);
verify
(
mockPolygon
).
accept
(
c
);
}
@Test
public
void
testCreate
()
{
Geometry
geom
=
new
Geometry
(
GeometryType
.
SOLID
,
Lod
.
LOD0
);
...
...
@@ -282,7 +300,7 @@ public class GeometryTest {
Polygon
p
=
mock
(
Polygon
.
class
);
geom
.
addPolygon
(
p
);
geom
.
clearAllContainedCheckResults
();
verify
(
p
).
clearAllContainedCheckResults
(
);
verify
(
p
).
accept
(
any
(
ClearVisitorResultsVisitor
.
class
)
);
assertFalse
(
geom
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
...
...
@@ -292,11 +310,15 @@ public class GeometryTest {
assertFalse
(
geom
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
geom
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
geom
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
Polygon
p
=
mock
(
Polygon
.
class
);
geom
.
addPolygon
(
p
);
Polygon
p
=
new
ConcretePolygon
();
p
.
setExteriorRing
(
mock
(
LinearRing
.
class
));
Polygon
spyPoly
=
Mockito
.
spy
(
p
);
geom
.
addPolygon
(
spyPoly
);
List
<
CheckError
>
errors
=
new
ArrayList
<>();
geom
.
collectContainedErrors
(
errors
);
verify
(
p
).
collect
Contained
Errors
(
errors
);
verify
(
spyPoly
).
collectErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
...
...
@@ -306,12 +328,16 @@ public class GeometryTest {
assertFalse
(
geom
.
containsAnyError
());
geom
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
geom
.
containsAnyError
());
Polygon
p
=
mock
(
Polygon
.
class
);
geom
.
addPolygon
(
p
);
Polygon
p
=
new
ConcretePolygon
();
p
.
setExteriorRing
(
mock
(
LinearRing
.
class
));
Polygon
spyPoly
=
Mockito
.
spy
(
p
);
geom
.
addPolygon
(
spyPoly
);
geom
.
clearAllContainedCheckResults
();
assertFalse
(
geom
.
containsAnyError
());
verify
(
p
).
contain
sAnyError
();
when
(
p
.
containsAnyError
()).
thenReturn
(
true
);
verify
(
spyPoly
).
ha
sAnyError
();
spyPoly
.
addCheckResult
((
new
CheckResult
(
CheckId
.
C_GE_R_NOT_CLOSED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)))
);
assertTrue
(
geom
.
containsAnyError
());
}
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/GeometryTestUtils.java
View file @
d1ff5020
...
...
@@ -19,11 +19,29 @@
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType
;
import
org.xmlobjects.gml.model.geometry.primitives.AbstractRing
;
import
org.xmlobjects.gml.model.geometry.primitives.AbstractSolid
;
import
org.xmlobjects.gml.model.geometry.primitives.AbstractSurface
;
import
org.xmlobjects.gml.model.geometry.primitives.Shell
;
import
org.xmlobjects.gml.model.geometry.primitives.Solid
;
import
org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
GeometryTestUtils
{
private
static
final
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
};
private
GeometryTestUtils
()
{
}
public
static
double
[]
getExpectedValues
()
{
return
expectedValues
;
}
public
static
Geometry
createDummyGeometry
(
GeometryType
type
)
{
return
createDummyGeometry
(
type
,
Lod
.
LOD2
);
...
...
@@ -90,4 +108,22 @@ public class GeometryTestUtils {
return
geom
;
}
public
static
void
assertSolidMatchesExpectedValues
(
AbstractSolid
aSolid
)
{
assertTrue
(
aSolid
instanceof
Solid
);
Solid
solid
=
(
Solid
)
aSolid
;
Shell
geometry
=
solid
.
getExterior
().
getObject
();
List
<
SurfaceProperty
>
surfaceMember
=
geometry
.
getSurfaceMembers
();
assertEquals
(
1
,
surfaceMember
.
size
());
AbstractSurface
polySurface
=
surfaceMember
.
get
(
0
).
getObject
();
assertTrue
(
polySurface
instanceof
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
);
var
gmlPoly
=
(
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
)
polySurface
;
AbstractRing
ring
=
gmlPoly
.
getExterior
().
getObject
();
var
gmlRing
=
(
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
)
ring
;
List
<
Double
>
posList
=
gmlRing
.
toCoordinateList3D
();
double
[]
expectedValues
=
getExpectedValues
();
for
(
int
i
=
0
;
i
<
posList
.
size
();
i
++)
{
assertEquals
(
expectedValues
[
i
],
posList
.
get
(
i
),
0.00000001
);
}
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/ImplicitGeometryTest.java
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
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.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.Copy
;
import
org.citygml4j.core.model.core.ImplicitGeometry
;
import
org.citygml4j.core.model.core.TransformationMatrix4x4
;
import
org.junit.Before
;
...
...
@@ -13,20 +18,25 @@ import org.xmlobjects.gml.util.jama.Matrix;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
Mockito
.
mock
;
public
class
ImplicitGeometryTest
{
private
Path
path
;
private
ParserConfiguration
config
;
private
String
pathString
=
"src/test/resources/ImplicitTestGeom.gml"
;
private
Path
path
=
Paths
.
get
(
pathString
);
private
TransformationMatrix4x4
origin
;
private
LibraryObject
lib
;
private
ImplicitGeometryHolder
igh
;
@Before
public
void
setUp
()
{
path
=
Paths
.
get
(
pathString
);
config
=
new
ParserConfiguration
(
8
,
false
);
Matrix
og
=
new
Matrix
(
4
,
4
);
og
.
set
(
0
,
0
,
1
);
...
...
@@ -34,6 +44,17 @@ public class ImplicitGeometryTest {
og
.
set
(
2
,
2
,
1
);
origin
=
new
TransformationMatrix4x4
(
og
);
lib
=
LibraryObject
.
of
(
path
,
config
);
assertNotNull
(
lib
);
// Create copy for cleanup
lib
=
Copy
.
copy
(
lib
);
ImplicitGeometry
geom
=
new
ImplicitGeometry
();
geom
.
setTransformationMatrix
(
origin
);
geom
.
setReferencePoint
(
new
PointProperty
(
new
Point
(
new
DirectPosition
(
0
,
0
))));
igh
=
new
ImplicitGeometryHolder
(
geom
,
lib
);
assertNotNull
(
igh
);
}
@Test
...
...
@@ -41,47 +62,95 @@ public class ImplicitGeometryTest {
LibraryObject
lo
=
LibraryObject
.
of
(
path
,
config
);
assertNotNull
(
lo
);
LibraryObject
lo2
=
LibraryObject
.
of
(
path
,
config
);
assertNotNull
(
lo2
);
assertSame
(
lo
,
lo2
);
}
@Test
public
void
testObjectTransform
()
{
LibraryObject
lo
=
LibraryObject
.
of
(
path
,
config
);
assertNotNull
(
lo
);
ImplicitGeometry
geom
=
new
ImplicitGeometry
();
geom
.
setTransformationMatrix
(
origin
);
geom
.
setReferencePoint
(
new
PointProperty
(
new
Point
(
new
DirectPosition
(
0
,
0
))));
ImplicitGeometryHolder
igh
=
new
ImplicitGeometryHolder
(
geom
,
l
o
);
assertNotNull
(
igh
);
ImplicitGeometryHolder
transform1
=
new
ImplicitGeometryHolder
(
geom
,
l
ib
);
assertNotNull
(
transform1
);
geom
.
setReferencePoint
(
new
PointProperty
(
new
Point
(
new
DirectPosition
(
5
,
8
))));
ImplicitGeometryHolder
igh
2
=
new
ImplicitGeometryHolder
(
geom
,
l
o
);
assertNotNull
(
igh
2
);
assertNotEquals
(
igh
,
igh
2
);
BoundingBox
bb1
=
BoundingBox
.
of
(
igh
.
getPolygons
());
BoundingBox
bb2
=
BoundingBox
.
of
(
igh
2
.
getPolygons
());
ImplicitGeometryHolder
transform
2
=
new
ImplicitGeometryHolder
(
geom
,
l
ib
);
assertNotNull
(
transform
2
);
assertNotEquals
(
transform1
,
transform
2
);
BoundingBox
bb1
=
BoundingBox
.
of
(
transform1
.
getPolygons
());
BoundingBox
bb2
=
BoundingBox
.
of
(
transform
2
.
getPolygons
());
assertNotEquals
(
bb1
,
bb2
);
}
@Test
public
void
testContainsError
()
{
assertFalse
(
lib
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
lib
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
igh
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertFalse
(
"ImplicitGeometryHolder's errors should be ignored and delegate the call to the prototype geometry"
,
lib
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
lib
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
lib
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
lib
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
lib
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
null
));
assertTrue
(
lib
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
lib
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testAccept
()
{
LibraryObject
lib
=
LibraryObject
.
of
(
path
,
config
);
assertNotNull
(
lib
);
public
void
testClearAllContainedCheckResults
()
{
lib
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
ImplicitGeometry
geom
=
new
ImplicitGeometry
();
geom
.
setTransformationMatrix
(
origin
);
geom
.
setReferencePoint
(
new
PointProperty
(
new
Point
(
new
DirectPosition
(
0
,
0
))));
assertEquals
(
1
,
lib
.
getAllCheckResults
().
size
());
lib
.
clearAllContainedCheckResults
();
assertTrue
(
lib
.
getAllCheckResults
().
isEmpty
());
}
int
polyCount
=
lib
.
getPolygons
().
size
();
@Test
public
void
testContainsAnyError
()
{
assertFalse
(
lib
.
containsAnyError
());
igh
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
lib
.
containsAnyError
());
lib
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
lib
.
containsAnyError
());
igh
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertFalse
(
lib
.
containsAnyError
());
lib
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
lib
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
List
<
CheckError
>
errors
=
new
ArrayList
<>();
igh
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
igh
.
collectContainedErrors
(
errors
);
assertEquals
(
"ImplicitGeometryHolder's errors should be ignored and delegate the call to the prototype geometry"
,
0
,
errors
.
size
());
lib
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
igh
.
collectContainedErrors
(
errors
);
assertEquals
(
"ImplicitGeometryHolder's errors should be ignored and delegate the call to the prototype geometry"
,
1
,
errors
.
size
());
}
ImplicitGeometryHolder
igh
=
new
ImplicitGeometryHolder
(
geom
,
lib
);
@Test
public
void
testAccept
()
{
int
polyCount
=
lib
.
getPolygons
().
size
();
AtomicInteger
loCounter
=
new
AtomicInteger
(
0
);
AbstractCheck
c
=
new
AbstractCheck
()
{
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
@Override
public
void
check
(
Polygon
lo
)
{
loCounter
.
incrementAndGet
();
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/LandUseTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.model.landuse.LandUse
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
Mockito
.
mock
;
public
class
LandUseTest
{
private
LandUse
lu
;
private
LandObject
land
;
@Before
public
void
setUp
()
{
lu
=
new
LandUse
();
land
=
new
LandObject
(
lu
);
}
@Test
public
void
testContainsError
()
{
assertFalse
(
land
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
land
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
land
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
land
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
land
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
land
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
land
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
land
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
land
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertEquals
(
1
,
land
.
getAllCheckResults
().
size
());
land
.
clearAllContainedCheckResults
();
assertTrue
(
land
.
getAllCheckResults
().
isEmpty
());
}
@Test
public
void
testContainsAnyError
()
{
assertFalse
(
land
.
containsAnyError
());
land
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
land
.
containsAnyError
());
land
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
land
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
land
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
land
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGeometries
()
{
lu
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
());
lu
.
setLod1MultiSurface
(
new
MultiSurfaceProperty
());
lu
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
lu
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
lu
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
());
land
.
clearGmlGeometries
();
assertNull
(
lu
.
getLod0MultiSurface
());
assertNull
(
lu
.
getLod1MultiSurface
());
assertNull
(
lu
.
getLod2MultiSurface
());
assertNull
(
lu
.
getLod3MultiSurface
());
assertNull
(
lu
.
getDeprecatedProperties
().
getLod4MultiSurface
());
}
@Test
public
void
testReCreateGeometries
()
{
land
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
land
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
land
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
land
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
land
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
land
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
lu
.
getLod0MultiSurface
());
assertNotNull
(
lu
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
lu
.
getLod1MultiSurface
());
assertNotNull
(
lu
.
getLod1MultiSurface
().
getObject
());
assertNotNull
(
lu
.
getLod2MultiSurface
());
assertNotNull
(
lu
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
lu
.
getLod3MultiSurface
());
assertNotNull
(
lu
.
getLod3MultiSurface
().
getObject
());
assertNotNull
(
lu
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNotNull
(
lu
.
getDeprecatedProperties
().
getLod4MultiSurface
().
getObject
());
}
}
\ No newline at end of file
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/ReliefObjectTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
import
org.citygml4j.core.model.relief.ReliefFeature
;
import
org.junit.Test
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
public
class
ReliefObjectTest
{
@Test
public
void
testVisitorPropagationReliefObject
()
{
ReliefFeature
mockRelief
=
new
ReliefFeature
();
ReliefObject
relief
=
new
ReliefObject
(
mockRelief
);
TinObject
mockTin
=
mock
(
TinObject
.
class
);
relief
.
addComponent
(
mockTin
);
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
};
relief
.
accept
(
c
);
verify
(
mockTin
).
accept
(
c
);
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/TinObjectTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.model.relief.TINRelief
;
import
org.citygml4j.core.model.relief.TinProperty
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
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
static
org
.
mockito
.
Mockito
.
verify
;
public
class
TinObjectTest
{
@Test
public
void
testVisitorPropagation
()
{
TINRelief
tir
=
new
TINRelief
();
TinObject
tin
=
new
TinObject
(
tir
);
Geometry
mockGeometry
=
mock
(
Geometry
.
class
);
tin
.
addGeometry
(
mockGeometry
);
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
};
tin
.
accept
(
c
);
verify
(
mockGeometry
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
TINRelief
tir
=
new
TINRelief
();
TinObject
tin
=
new
TinObject
(
tir
);
assertFalse
(
tin
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
tin
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
tin
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tin
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
tin
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
tin
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
tin
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
tin
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
TINRelief
tir
=
new
TINRelief
();
TinObject
tin
=
new
TinObject
(
tir
);
tin
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertEquals
(
1
,
tin
.
getAllCheckResults
().
size
());
tin
.
clearAllContainedCheckResults
();
assertTrue
(
tin
.
getAllCheckResults
().
isEmpty
());
}
@Test
public
void
testContainsAnyError
()
{
TINRelief
tir
=
new
TINRelief
();
TinObject
tin
=
new
TinObject
(
tir
);
assertFalse
(
tin
.
containsAnyError
());
tin
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
tin
.
containsAnyError
());
tin
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tin
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
TINRelief
tir
=
new
TINRelief
();
TinObject
tin
=
new
TinObject
(
tir
);
tin
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
tin
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGeometries
()
{
TINRelief
tir
=
new
TINRelief
();
TinObject
tin
=
new
TinObject
(
tir
);
tir
.
setTin
(
new
TinProperty
());
tin
.
clearGmlGeometries
();
assertNull
(
tir
.
getTin
());
}
@Test
public
void
testReCreateGeometries
()
{
TINRelief
tir
=
new
TINRelief
();
TinObject
tin
=
new
TinObject
(
tir
);
tin
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
tin
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
tir
.
getTin
());
assertNotNull
(
tir
.
getTin
().
getObject
());
assertEquals
(
2
,
tir
.
getLod
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/TopLevelTransportFeatureTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.model.deprecated.transportation.DeprecatedPropertiesOfAbstractTransportationSpace
;
import
org.citygml4j.core.model.transportation.Railway
;
import
org.citygml4j.core.model.transportation.Road
;
import
org.citygml4j.core.model.transportation.Square
;
import
org.citygml4j.core.model.transportation.Track
;
import
org.citygml4j.core.model.transportation.Waterway
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
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
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
public
class
TopLevelTransportFeatureTest
{
@Test
public
void
testObjectConstruction
()
{
TopLevelTransportFeature
road
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Road
.
class
));
assertEquals
(
TransportationObject
.
TransportationType
.
ROAD
,
road
.
getTransportationType
());
TopLevelTransportFeature
track
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Track
.
class
));
assertEquals
(
TransportationObject
.
TransportationType
.
TRACK
,
track
.
getTransportationType
());
TopLevelTransportFeature
waterway
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Waterway
.
class
));
assertEquals
(
TransportationObject
.
TransportationType
.
WATERWAY
,
waterway
.
getTransportationType
());
TopLevelTransportFeature
railway
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Railway
.
class
));
assertEquals
(
TransportationObject
.
TransportationType
.
RAILWAY
,
railway
.
getTransportationType
());
TopLevelTransportFeature
square
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Square
.
class
));
assertEquals
(
TransportationObject
.
TransportationType
.
SQUARE
,
square
.
getTransportationType
());
}
@Test
public
void
testVisitorPropagation
()
{
Road
road
=
new
Road
();
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
road
);
TransportSection
mockSection
=
mock
(
TransportSection
.
class
);
TransportSection
mockIntersection
=
mock
(
TransportSection
.
class
);
top
.
addSection
(
mockSection
);
top
.
addIntersection
(
mockIntersection
);
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
};
top
.
accept
(
c
);
verify
(
mockSection
).
accept
(
c
);
verify
(
mockIntersection
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
Road
road
=
new
Road
();
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
road
);
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testContainsAnyError
()
{
Road
road
=
new
Road
();
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
road
);
assertFalse
(
top
.
containsAnyError
());
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
top
.
containsAnyError
());
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
top
.
containsAnyError
());
}
@Test
public
void
testClearAllContainedCheckResults
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
top
.
clearAllContainedCheckResults
();
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testCollectContainedErrors
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
top
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGmlGeometries
()
{
Road
r
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
r
);
top
.
setGmlObject
(
r
);
DeprecatedPropertiesOfAbstractTransportationSpace
dSpace
=
mock
(
DeprecatedPropertiesOfAbstractTransportationSpace
.
class
);
when
(
r
.
getDeprecatedProperties
()).
thenReturn
(
dSpace
);
dSpace
.
setLod1MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod2MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod3MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
dSpace
.
setLod4MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
top
.
unsetGmlGeometries
();
assertNull
(
dSpace
.
getLod1MultiSurface
());
assertNull
(
r
.
getLod2MultiSurface
());
assertNull
(
r
.
getLod3MultiSurface
());
assertNull
(
dSpace
.
getLod4MultiSurface
());
}
@Test
public
void
testReCreateGeometriesSolid
()
{
Road
gmlRoad
=
new
Road
();
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
gmlRoad
);
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
top
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlRoad
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlRoad
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlRoad
.
getLod3Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
Road
gmlRoad
=
new
Road
();
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
gmlRoad
);
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
top
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlRoad
.
getLod0MultiSurface
());
assertNotNull
(
gmlRoad
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlRoad
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNotNull
(
gmlRoad
.
getDeprecatedProperties
().
getLod1MultiSurface
().
getObject
());
assertNotNull
(
gmlRoad
.
getLod2MultiSurface
());
assertNotNull
(
gmlRoad
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlRoad
.
getLod3MultiSurface
());
assertNotNull
(
gmlRoad
.
getLod3MultiSurface
().
getObject
());
assertNotNull
(
gmlRoad
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNotNull
(
gmlRoad
.
getDeprecatedProperties
().
getLod4MultiSurface
().
getObject
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/TrafficAreaTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.model.deprecated.core.DeprecatedPropertiesOfAbstractThematicSurface
;
import
org.citygml4j.core.model.transportation.TrafficArea
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
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
static
org
.
mockito
.
Mockito
.
when
;
public
class
TrafficAreaTest
{
@Test
public
void
testContainsError
()
{
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
tao
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tao
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
tao
.
containsError
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
}
@Test
public
void
testContainsAnyError
()
{
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
assertFalse
(
tao
.
containsAnyError
());
tao
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
tao
.
containsAnyError
());
tao
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tao
.
containsAnyError
());
}
@Test
public
void
testClearAllContainedCheckResults
()
{
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
taMock
=
mock
(
TrafficArea
.
class
);
tao
.
setGmlObject
(
taMock
);
assertFalse
(
tao
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
tao
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tao
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
tao
.
clearAllContainedCheckResults
();
assertFalse
(
tao
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testCollectContainedErrors
()
{
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
taMock
=
mock
(
TrafficArea
.
class
);
tao
.
setGmlObject
(
taMock
);
tao
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
tao
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGmlGeometries
()
{
TrafficAreaObject
ta
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
r
=
mock
(
TrafficArea
.
class
);
ta
.
setGmlObject
(
r
);
DeprecatedPropertiesOfAbstractThematicSurface
dSpace
=
mock
(
DeprecatedPropertiesOfAbstractThematicSurface
.
class
);
when
(
r
.
getDeprecatedProperties
()).
thenReturn
(
dSpace
);
r
.
setLod0MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod1MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod2MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod3MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
dSpace
.
setLod4MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
ta
.
unsetGmlGeometries
();
assertNull
(
r
.
getLod0MultiSurface
());
assertNull
(
r
.
getLod1MultiSurface
());
assertNull
(
r
.
getLod2MultiSurface
());
assertNull
(
r
.
getLod3MultiSurface
());
assertNull
(
dSpace
.
getLod4MultiSurface
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
TrafficArea
gmlAus
=
new
TrafficArea
()
{
};
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
tao
.
setGmlObject
(
gmlAus
);
tao
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
tao
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
tao
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
tao
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
tao
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
tao
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlAus
.
getLod0MultiSurface
());
assertNotNull
(
gmlAus
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlAus
.
getLod2MultiSurface
());
assertNotNull
(
gmlAus
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlAus
.
getLod3MultiSurface
());
assertNotNull
(
gmlAus
.
getLod3MultiSurface
().
getObject
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/TrafficSpaceTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
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.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.ClearVisitorResultsVisitor
;
import
org.citygml4j.core.model.core.AbstractSpaceBoundary
;
import
org.citygml4j.core.model.core.AbstractUnoccupiedSpace
;
import
org.citygml4j.core.model.deprecated.core.DeprecatedPropertiesOfAbstractCityObject
;
import
org.citygml4j.core.model.transportation.TrafficSpace
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.citygml4j.core.visitor.ObjectVisitor
;
import
org.junit.Test
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
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
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
public
class
TrafficSpaceTest
{
@Test
public
void
testVisitorPropagation
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficAreaObject
areaMock
=
mock
(
TrafficAreaObject
.
class
);
tso
.
addTrafficArea
(
areaMock
);
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
};
tso
.
accept
(
c
);
verify
(
areaMock
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
tso
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tso
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
tso
.
containsError
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
}
@Test
public
void
testContainsAnyError
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
assertFalse
(
tso
.
containsAnyError
());
tso
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
tso
.
containsAnyError
());
tso
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tso
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
tso
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
tso
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testClearAllContainedCheckResults
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
tsMock
=
mock
(
TrafficSpace
.
class
);
tso
.
setGmlObject
(
tsMock
);
TrafficAreaObject
taMock
=
mock
(
TrafficAreaObject
.
class
);
tso
.
addTrafficArea
(
taMock
);
assertFalse
(
tso
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
tso
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tso
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
tso
.
clearAllContainedCheckResults
();
assertFalse
(
tso
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
verify
(
taMock
).
accept
(
any
(
ClearVisitorResultsVisitor
.
class
));
}
@Test
public
void
testUnsetGmlGeometries
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
t
=
mock
(
TrafficSpace
.
class
);
tso
.
setGmlObject
(
t
);
DeprecatedPropertiesOfAbstractCityObject
dSpace
=
mock
(
DeprecatedPropertiesOfAbstractCityObject
.
class
);
when
(
t
.
getDeprecatedProperties
()).
thenReturn
(
dSpace
);
t
.
setLod0MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
t
.
setLod2MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
t
.
setLod3MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
tso
.
unsetGmlGeometries
();
assertNull
(
t
.
getLod0MultiSurface
());
assertNull
(
t
.
getLod2MultiSurface
());
assertNull
(
t
.
getLod3MultiSurface
());
}
@Test
public
void
testReCreateGeometriesSolid
()
{
AbstractUnoccupiedSpace
gmlAus
=
new
AbstractUnoccupiedSpace
()
{
@Override
public
boolean
isValidBoundary
(
Class
<?
extends
AbstractSpaceBoundary
>
type
)
{
return
false
;
}
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
)
{
};
tso
.
setGmlObject
(
gmlAus
);
tso
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
tso
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
tso
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
tso
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAus
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAus
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAus
.
getLod3Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
AbstractUnoccupiedSpace
gmlAus
=
new
AbstractUnoccupiedSpace
()
{
@Override
public
boolean
isValidBoundary
(
Class
<?
extends
AbstractSpaceBoundary
>
type
)
{
return
false
;
}
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
tso
.
setGmlObject
(
gmlAus
);
tso
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
tso
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
tso
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
tso
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlAus
.
getLod0MultiSurface
());
assertNotNull
(
gmlAus
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlAus
.
getLod2MultiSurface
());
assertNotNull
(
gmlAus
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlAus
.
getLod3MultiSurface
());
assertNotNull
(
gmlAus
.
getLod3MultiSurface
().
getObject
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/TransportationObjectTest.java
View file @
d1ff5020
...
...
@@ -19,41 +19,10 @@
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
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.List
;
import
org.citygml4j.core.model.deprecated.core.DeprecatedPropertiesOfAbstractCityObject
;
import
org.citygml4j.core.model.deprecated.core.DeprecatedPropertiesOfAbstractThematicSurface
;
import
org.citygml4j.core.model.deprecated.transportation.DeprecatedPropertiesOfAbstractTransportationSpace
;
import
org.citygml4j.core.model.transportation.Intersection
;
import
org.citygml4j.core.model.transportation.Railway
;
import
org.citygml4j.core.model.transportation.Road
;
import
org.citygml4j.core.model.transportation.Section
;
import
org.citygml4j.core.model.transportation.Square
;
import
org.citygml4j.core.model.transportation.Track
;
import
org.citygml4j.core.model.transportation.TrafficArea
;
import
org.citygml4j.core.model.transportation.TrafficSpace
;
import
org.citygml4j.core.model.transportation.Waterway
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
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.TransportationObject.TransportationType
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
public
class
TransportationObjectTest
{
...
...
@@ -63,476 +32,5 @@ public class TransportationObjectTest {
assertEquals
(
FeatureType
.
TRANSPORTATION
,
to
.
getFeatureType
());
}
@Test
public
void
testObjectConstruction
()
{
TopLevelTransportFeature
road
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Road
.
class
));
assertEquals
(
TransportationType
.
ROAD
,
road
.
getTransportationType
());
TopLevelTransportFeature
track
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Track
.
class
));
assertEquals
(
TransportationType
.
TRACK
,
track
.
getTransportationType
());
TopLevelTransportFeature
waterway
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Waterway
.
class
));
assertEquals
(
TransportationType
.
WATERWAY
,
waterway
.
getTransportationType
());
TopLevelTransportFeature
railway
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Railway
.
class
));
assertEquals
(
TransportationType
.
RAILWAY
,
railway
.
getTransportationType
());
TopLevelTransportFeature
square
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Square
.
class
));
assertEquals
(
TransportationType
.
SQUARE
,
square
.
getTransportationType
());
}
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReCreateGeometriesSolid
()
{
TopLevelTransportFeature
to
=
TopLevelTransportFeature
.
from
(
Mockito
.
mock
(
Road
.
class
));
to
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
to
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
}
@Test
public
void
testReCreateGeometriesTransportationSpace
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TransportSection
sectionMock
=
Mockito
.
mock
(
TransportSection
.
class
);
TransportSection
intersectionMock
=
Mockito
.
mock
(
TransportSection
.
class
);
TrafficSpaceObject
tsMock
=
Mockito
.
mock
(
TrafficSpaceObject
.
class
);
TrafficSpaceObject
auxTsMock
=
Mockito
.
mock
(
TrafficSpaceObject
.
class
);
top
.
addSection
(
sectionMock
);
top
.
addIntersection
(
intersectionMock
);
top
.
addTrafficSpace
(
tsMock
);
top
.
addAuxTrafficSpace
(
auxTsMock
);
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
top
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
verify
(
roadMock
).
setLod2MultiSurface
(
any
());
verify
(
sectionMock
).
reCreateGeometries
(
any
(),
any
());
verify
(
intersectionMock
).
reCreateGeometries
(
any
(),
any
());
verify
(
tsMock
).
reCreateGeometries
(
any
(),
any
());
verify
(
auxTsMock
).
reCreateGeometries
(
any
(),
any
());
}
@Test
public
void
testReCreateGeometriesTrafficSpace
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
tsMock
=
mock
(
TrafficSpace
.
class
);
tso
.
setGmlObject
(
tsMock
);
TrafficAreaObject
taoMock
=
Mockito
.
mock
(
TrafficAreaObject
.
class
);
tso
.
addTrafficArea
(
taoMock
);
tso
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
tso
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
verify
(
tsMock
).
setLod2MultiSurface
(
any
());
verify
(
taoMock
).
reCreateGeometries
(
any
(),
any
());
}
@Test
public
void
testReCreateGeometriesTrafficArea
()
{
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
taMock
=
mock
(
TrafficArea
.
class
);
tao
.
setGmlObject
(
taMock
);
tao
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
tao
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
verify
(
taMock
).
setLod2MultiSurface
(
any
());
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod0
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TrafficSpaceObject
ts
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
trafficSpaceMock
=
mock
(
TrafficSpace
.
class
);
ts
.
setGmlObject
(
trafficSpaceMock
);
TrafficAreaObject
ta
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
trafficAreaMock
=
mock
(
TrafficArea
.
class
);
ta
.
setGmlObject
(
trafficAreaMock
);
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
ts
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
ta
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
top
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
ts
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
ta
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
verify
(
roadMock
).
setLod0MultiSurface
(
any
());
verify
(
trafficSpaceMock
).
setLod0MultiSurface
(
any
());
verify
(
trafficAreaMock
).
setLod0MultiSurface
(
any
());
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod1
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TrafficAreaObject
ta
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
trafficAreaMock
=
mock
(
TrafficArea
.
class
);
ta
.
setGmlObject
(
trafficAreaMock
);
DeprecatedPropertiesOfAbstractTransportationSpace
dSpace
=
mock
(
DeprecatedPropertiesOfAbstractTransportationSpace
.
class
);
when
(
roadMock
.
getDeprecatedProperties
()).
thenReturn
(
dSpace
);
try
{
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
}
catch
(
IllegalArgumentException
e
)
{
fail
(
"Casting of original GML object to AbstractTransportationSpace should work"
);
}
ta
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
top
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
ta
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
verify
(
dSpace
).
setLod1MultiSurface
(
any
());
verify
(
trafficAreaMock
).
setLod1MultiSurface
(
any
());
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod2
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TrafficSpaceObject
ts
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
trafficSpaceMock
=
mock
(
TrafficSpace
.
class
);
ts
.
setGmlObject
(
trafficSpaceMock
);
TrafficAreaObject
ta
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
trafficAreaMock
=
mock
(
TrafficArea
.
class
);
ta
.
setGmlObject
(
trafficAreaMock
);
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
ts
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
ta
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
top
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
ts
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
ta
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
verify
(
roadMock
).
setLod2MultiSurface
(
any
());
verify
(
trafficSpaceMock
).
setLod2MultiSurface
(
any
());
verify
(
trafficAreaMock
).
setLod2MultiSurface
(
any
());
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod3
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TrafficSpaceObject
ts
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
trafficSpaceMock
=
mock
(
TrafficSpace
.
class
);
ts
.
setGmlObject
(
trafficSpaceMock
);
TrafficAreaObject
ta
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
trafficAreaMock
=
mock
(
TrafficArea
.
class
);
ta
.
setGmlObject
(
trafficAreaMock
);
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
ts
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
ta
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
top
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
ts
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
ta
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
verify
(
roadMock
).
setLod3MultiSurface
(
any
());
verify
(
trafficSpaceMock
).
setLod3MultiSurface
(
any
());
verify
(
trafficAreaMock
).
setLod3MultiSurface
(
any
());
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod4
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TrafficAreaObject
ta
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
trafficAreaMock
=
mock
(
TrafficArea
.
class
);
ta
.
setGmlObject
(
trafficAreaMock
);
DeprecatedPropertiesOfAbstractTransportationSpace
dSpace
=
mock
(
DeprecatedPropertiesOfAbstractTransportationSpace
.
class
);
when
(
roadMock
.
getDeprecatedProperties
()).
thenReturn
(
dSpace
);
DeprecatedPropertiesOfAbstractThematicSurface
dArea
=
mock
(
DeprecatedPropertiesOfAbstractThematicSurface
.
class
);
when
(
trafficAreaMock
.
getDeprecatedProperties
()).
thenReturn
(
dArea
);
ta
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
try
{
top
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
}
catch
(
IllegalArgumentException
e
)
{
fail
(
"Casting of original GML object to AbstractTransportationSpace should work"
);
}
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
top
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
ta
.
reCreateGeometries
(
factory
,
mock
(
ParserConfiguration
.
class
));
verify
(
dSpace
).
setLod4MultiSurface
(
any
());
verify
(
dArea
).
setLod4MultiSurface
(
any
());
}
@Test
public
void
testContainsErrorTransportationSpace
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TransportSection
sectionMock
=
Mockito
.
mock
(
TransportSection
.
class
);
TransportSection
intersectionMock
=
Mockito
.
mock
(
TransportSection
.
class
);
TrafficSpaceObject
tsMock
=
Mockito
.
mock
(
TrafficSpaceObject
.
class
);
TrafficSpaceObject
auxTsMock
=
Mockito
.
mock
(
TrafficSpaceObject
.
class
);
top
.
addSection
(
sectionMock
);
top
.
addIntersection
(
intersectionMock
);
top
.
addTrafficSpace
(
tsMock
);
top
.
addAuxTrafficSpace
(
auxTsMock
);
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
verify
(
sectionMock
).
containsError
(
any
());
verify
(
intersectionMock
).
containsError
(
any
());
verify
(
tsMock
).
containsError
(
any
());
verify
(
auxTsMock
).
containsError
(
any
());
}
@Test
public
void
testContainsErrorTrafficSpace
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
tsMock
=
mock
(
TrafficSpace
.
class
);
tso
.
setGmlObject
(
tsMock
);
TrafficAreaObject
taMock
=
mock
(
TrafficAreaObject
.
class
);
tso
.
addTrafficArea
(
taMock
);
tso
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tso
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
tso
.
containsError
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
verify
(
taMock
).
containsError
(
any
());
}
@Test
public
void
testContainsErrorTrafficArea
()
{
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
taMock
=
mock
(
TrafficArea
.
class
);
tao
.
setGmlObject
(
taMock
);
tao
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tao
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
tao
.
containsError
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
}
@Test
public
void
testClearAllContainedCheckResultsTransportationSpace
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TransportSection
sectionMock
=
Mockito
.
mock
(
TransportSection
.
class
);
TransportSection
intersectionMock
=
Mockito
.
mock
(
TransportSection
.
class
);
TrafficSpaceObject
tsMock
=
Mockito
.
mock
(
TrafficSpaceObject
.
class
);
TrafficSpaceObject
auxTsMock
=
Mockito
.
mock
(
TrafficSpaceObject
.
class
);
top
.
addSection
(
sectionMock
);
top
.
addIntersection
(
intersectionMock
);
top
.
addTrafficSpace
(
tsMock
);
top
.
addAuxTrafficSpace
(
auxTsMock
);
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
top
.
clearAllContainedCheckResults
();
assertFalse
(
top
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
verify
(
sectionMock
).
clearAllContainedCheckResults
();
verify
(
intersectionMock
).
clearAllContainedCheckResults
();
verify
(
tsMock
).
clearAllContainedCheckResults
();
verify
(
auxTsMock
).
clearAllContainedCheckResults
();
}
@Test
public
void
testClearAllContainedCheckResultsTrafficSpace
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
tsMock
=
mock
(
TrafficSpace
.
class
);
tso
.
setGmlObject
(
tsMock
);
TrafficAreaObject
taMock
=
mock
(
TrafficAreaObject
.
class
);
tso
.
addTrafficArea
(
taMock
);
assertFalse
(
tso
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
tso
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tso
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
tso
.
clearAllContainedCheckResults
();
assertFalse
(
tso
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
verify
(
taMock
).
clearAllContainedCheckResults
();
}
@Test
public
void
testClearAllContainedCheckResultsTrafficArea
()
{
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
taMock
=
mock
(
TrafficArea
.
class
);
tao
.
setGmlObject
(
taMock
);
assertFalse
(
tao
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
tao
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
tao
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
tao
.
clearAllContainedCheckResults
();
assertFalse
(
tao
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testCollectContainedErrorsTransportationSpace
()
{
Road
roadMock
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
roadMock
);
top
.
setGmlObject
(
roadMock
);
TransportSection
sectionMock
=
Mockito
.
mock
(
TransportSection
.
class
);
TransportSection
intersectionMock
=
Mockito
.
mock
(
TransportSection
.
class
);
TrafficSpaceObject
tsMock
=
Mockito
.
mock
(
TrafficSpaceObject
.
class
);
TrafficSpaceObject
auxTsMock
=
Mockito
.
mock
(
TrafficSpaceObject
.
class
);
top
.
addSection
(
sectionMock
);
top
.
addIntersection
(
intersectionMock
);
top
.
addTrafficSpace
(
tsMock
);
top
.
addAuxTrafficSpace
(
auxTsMock
);
top
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
top
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
verify
(
sectionMock
).
collectContainedErrors
(
errors
);
verify
(
intersectionMock
).
collectContainedErrors
(
errors
);
verify
(
tsMock
).
collectContainedErrors
(
errors
);
verify
(
auxTsMock
).
collectContainedErrors
(
errors
);
}
@Test
public
void
testCollectContainedErrorsTrafficSpace
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
tsMock
=
mock
(
TrafficSpace
.
class
);
tso
.
setGmlObject
(
tsMock
);
TrafficAreaObject
taMock
=
mock
(
TrafficAreaObject
.
class
);
tso
.
addTrafficArea
(
taMock
);
tso
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
tso
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
verify
(
taMock
).
collectContainedErrors
(
errors
);
}
@Test
public
void
testCollectContainedErrorsTrafficArea
()
{
TrafficAreaObject
tao
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
taMock
=
mock
(
TrafficArea
.
class
);
tao
.
setGmlObject
(
taMock
);
tao
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
tao
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGmlGeometriesTransportationSpace
()
{
Road
r
=
mock
(
Road
.
class
);
TopLevelTransportFeature
top
=
TopLevelTransportFeature
.
from
(
r
);
top
.
setGmlObject
(
r
);
TransportSection
mockSection
=
mock
(
TransportSection
.
class
);
TransportSection
mockInterestSection
=
mock
(
TransportSection
.
class
);
TrafficSpaceObject
mockSpace
=
mock
(
TrafficSpaceObject
.
class
);
TrafficSpaceObject
auxMockSpace
=
mock
(
TrafficSpaceObject
.
class
);
top
.
addSection
(
mockSection
);
top
.
addIntersection
(
mockInterestSection
);
top
.
addTrafficSpace
(
mockSpace
);
top
.
addAuxTrafficSpace
(
auxMockSpace
);
DeprecatedPropertiesOfAbstractTransportationSpace
dSpace
=
mock
(
DeprecatedPropertiesOfAbstractTransportationSpace
.
class
);
when
(
r
.
getDeprecatedProperties
()).
thenReturn
(
dSpace
);
dSpace
.
setLod1MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod2MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod3MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
dSpace
.
setLod4MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
top
.
unsetGmlGeometries
();
assertNull
(
dSpace
.
getLod1MultiSurface
());
assertNull
(
r
.
getLod2MultiSurface
());
assertNull
(
r
.
getLod3MultiSurface
());
assertNull
(
dSpace
.
getLod4MultiSurface
());
verify
(
mockSection
).
unsetGmlGeometries
();
verify
(
mockInterestSection
).
unsetGmlGeometries
();
verify
(
mockSpace
).
unsetGmlGeometries
();
verify
(
auxMockSpace
).
unsetGmlGeometries
();
}
@Test
public
void
testUnsetGmlGeometriesTrafficSpace
()
{
TrafficSpaceObject
tso
=
new
TrafficSpaceObject
(
TrafficSpaceObject
.
TrafficSpaceType
.
TRAFFIC_SPACE
);
TrafficSpace
t
=
mock
(
TrafficSpace
.
class
);
tso
.
setGmlObject
(
t
);
TrafficAreaObject
mockArea
=
mock
(
TrafficAreaObject
.
class
);
tso
.
addTrafficArea
(
mockArea
);
DeprecatedPropertiesOfAbstractCityObject
dSpace
=
mock
(
DeprecatedPropertiesOfAbstractCityObject
.
class
);
when
(
t
.
getDeprecatedProperties
()).
thenReturn
(
dSpace
);
t
.
setLod0MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
t
.
setLod2MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
t
.
setLod3MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
tso
.
unsetGmlGeometries
();
assertNull
(
t
.
getLod0MultiSurface
());
assertNull
(
t
.
getLod2MultiSurface
());
assertNull
(
t
.
getLod3MultiSurface
());
verify
(
mockArea
).
unsetGmlGeometries
();
}
@Test
public
void
testUnsetGmlGeometriesTrafficArea
()
{
TrafficAreaObject
ta
=
new
TrafficAreaObject
(
TrafficAreaObject
.
TrafficAreaType
.
TRAFFIC_AREA
);
TrafficArea
r
=
mock
(
TrafficArea
.
class
);
ta
.
setGmlObject
(
r
);
DeprecatedPropertiesOfAbstractThematicSurface
dSpace
=
mock
(
DeprecatedPropertiesOfAbstractThematicSurface
.
class
);
when
(
r
.
getDeprecatedProperties
()).
thenReturn
(
dSpace
);
r
.
setLod0MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod1MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod2MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
r
.
setLod3MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
dSpace
.
setLod4MultiSurface
(
mock
(
MultiSurfaceProperty
.
class
));
ta
.
unsetGmlGeometries
();
assertNull
(
r
.
getLod0MultiSurface
());
assertNull
(
r
.
getLod1MultiSurface
());
assertNull
(
r
.
getLod2MultiSurface
());
assertNull
(
r
.
getLod3MultiSurface
());
assertNull
(
dSpace
.
getLod4MultiSurface
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/TransportationSpaceTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.model.transportation.AbstractTransportationSpace
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.citygml4j.core.visitor.ObjectVisitor
;
import
org.junit.Test
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
public
class
TransportationSpaceTest
{
@Test
public
void
testVisitorPropagation
()
{
TransportationSpace
space
=
new
TransportationSpace
(
TransportationObject
.
TransportationType
.
TRANSPORTATION_COMPLEX
)
{
};
TrafficSpaceObject
mockSpace
=
mock
(
TrafficSpaceObject
.
class
);
TrafficSpaceObject
auxMockSpace
=
mock
(
TrafficSpaceObject
.
class
);
space
.
addTrafficSpace
(
mockSpace
);
space
.
addAuxTrafficSpace
(
auxMockSpace
);
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
};
space
.
accept
(
c
);
verify
(
mockSpace
).
accept
(
c
);
verify
(
auxMockSpace
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
TransportationSpace
space
=
new
TransportationSpace
(
TransportationObject
.
TransportationType
.
TRANSPORTATION_COMPLEX
)
{
};
space
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
space
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
space
.
containsError
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
}
@Test
public
void
testContainsAnyError
()
{
TransportationSpace
space
=
new
TransportationSpace
(
TransportationObject
.
TransportationType
.
TRANSPORTATION_COMPLEX
)
{
};
assertFalse
(
space
.
containsAnyError
());
space
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
space
.
containsAnyError
());
space
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
space
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
TransportationSpace
space
=
new
TransportationSpace
(
TransportationObject
.
TransportationType
.
TRANSPORTATION_COMPLEX
)
{
};
space
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
space
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testClearAllContainedCheckResults
()
{
TransportationSpace
space
=
new
TransportationSpace
(
TransportationObject
.
TransportationType
.
TRANSPORTATION_COMPLEX
)
{
};
assertFalse
(
space
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
space
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
space
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
space
.
clearAllContainedCheckResults
();
assertFalse
(
space
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testReCreateGeometriesSolid
()
{
AbstractTransportationSpace
gmlAts
=
new
AbstractTransportationSpace
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
TransportationSpace
space
=
new
TransportationSpace
(
TransportationObject
.
TransportationType
.
TRANSPORTATION_COMPLEX
)
{
};
space
.
setGmlObject
(
gmlAts
);
space
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
space
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
space
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
space
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAts
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAts
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAts
.
getLod3Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
AbstractTransportationSpace
gmlAts
=
new
AbstractTransportationSpace
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
TransportationSpace
space
=
new
TransportationSpace
(
TransportationObject
.
TransportationType
.
TRANSPORTATION_COMPLEX
)
{
};
space
.
setGmlObject
(
gmlAts
);
space
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
space
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
space
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
space
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
space
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
space
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlAts
.
getLod0MultiSurface
());
assertNotNull
(
gmlAts
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlAts
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNotNull
(
gmlAts
.
getDeprecatedProperties
().
getLod1MultiSurface
().
getObject
());
assertNotNull
(
gmlAts
.
getLod2MultiSurface
());
assertNotNull
(
gmlAts
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlAts
.
getLod3MultiSurface
());
assertNotNull
(
gmlAts
.
getLod3MultiSurface
().
getObject
());
assertNotNull
(
gmlAts
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNotNull
(
gmlAts
.
getDeprecatedProperties
().
getLod4MultiSurface
().
getObject
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/VegetationTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.model.vegetation.PlantCover
;
import
org.citygml4j.core.model.vegetation.SolitaryVegetationObject
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
org.xmlobjects.gml.model.geometry.GeometryProperty
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSolidProperty
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.SolidProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
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
;
public
class
VegetationTest
{
//TODO: Recreate geometries tests
@Test
public
void
testContainsError
()
{
Vegetation
veg
=
new
Vegetation
(
Vegetation
.
VegetationType
.
PLANT_COVER
);
veg
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
veg
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
veg
.
containsError
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
}
@Test
public
void
testContainsAnyError
()
{
Vegetation
veg
=
new
Vegetation
(
Vegetation
.
VegetationType
.
PLANT_COVER
);
assertFalse
(
veg
.
containsAnyError
());
veg
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
veg
.
containsAnyError
());
veg
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
veg
.
containsAnyError
());
}
@Test
public
void
testClearAllContainedCheckResults
()
{
Vegetation
veg
=
new
Vegetation
(
Vegetation
.
VegetationType
.
PLANT_COVER
);
assertFalse
(
veg
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
veg
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
veg
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
veg
.
clearAllContainedCheckResults
();
assertFalse
(
veg
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testCollectContainedErrors
()
{
Vegetation
veg
=
new
Vegetation
(
Vegetation
.
VegetationType
.
PLANT_COVER
);
veg
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
veg
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGmlGeometriesPlantCover
()
{
Vegetation
plantCover
=
new
Vegetation
(
Vegetation
.
VegetationType
.
PLANT_COVER
);
PlantCover
gmlCover
=
new
PlantCover
();
plantCover
.
setGmlObject
(
gmlCover
);
gmlCover
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
());
gmlCover
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
());
gmlCover
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
gmlCover
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
gmlCover
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
());
gmlCover
.
setLod1Solid
(
new
SolidProperty
());
gmlCover
.
setLod2Solid
(
new
SolidProperty
());
gmlCover
.
setLod3Solid
(
new
SolidProperty
());
gmlCover
.
getDeprecatedProperties
().
setLod1MultiSolid
(
new
MultiSolidProperty
());
gmlCover
.
getDeprecatedProperties
().
setLod2MultiSolid
(
new
MultiSolidProperty
());
gmlCover
.
getDeprecatedProperties
().
setLod3MultiSolid
(
new
MultiSolidProperty
());
gmlCover
.
getDeprecatedProperties
().
setLod4MultiSolid
(
new
MultiSolidProperty
());
plantCover
.
clearGmlGeometries
();
assertNull
(
gmlCover
.
getLod0MultiSurface
());
assertNull
(
gmlCover
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNull
(
gmlCover
.
getLod2MultiSurface
());
assertNull
(
gmlCover
.
getLod3MultiSurface
());
assertNull
(
gmlCover
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNull
(
gmlCover
.
getLod1Solid
());
assertNull
(
gmlCover
.
getLod2Solid
());
assertNull
(
gmlCover
.
getLod3Solid
());
assertNull
(
gmlCover
.
getDeprecatedProperties
().
getLod1MultiSolid
());
assertNull
(
gmlCover
.
getDeprecatedProperties
().
getLod2MultiSolid
());
assertNull
(
gmlCover
.
getDeprecatedProperties
().
getLod3MultiSolid
());
assertNull
(
gmlCover
.
getDeprecatedProperties
().
getLod4MultiSolid
());
}
@Test
public
void
testUnsetGmlGeometriesSolitaryVegetationObject
()
{
Vegetation
solitary
=
new
Vegetation
(
Vegetation
.
VegetationType
.
SOLITARY_VEGETATION_OBJECT
);
SolitaryVegetationObject
gmlSolitary
=
new
SolitaryVegetationObject
();
solitary
.
setGmlObject
(
gmlSolitary
);
gmlSolitary
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
());
gmlSolitary
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
gmlSolitary
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
gmlSolitary
.
setLod1Solid
(
new
SolidProperty
());
gmlSolitary
.
setLod2Solid
(
new
SolidProperty
());
gmlSolitary
.
setLod3Solid
(
new
SolidProperty
());
gmlSolitary
.
getDeprecatedProperties
().
setLod1Geometry
(
new
GeometryProperty
<>());
gmlSolitary
.
getDeprecatedProperties
().
setLod2Geometry
(
new
GeometryProperty
<>());
gmlSolitary
.
getDeprecatedProperties
().
setLod3Geometry
(
new
GeometryProperty
<>());
gmlSolitary
.
getDeprecatedProperties
().
setLod4Geometry
(
new
GeometryProperty
<>());
solitary
.
clearGmlGeometries
();
assertNull
(
gmlSolitary
.
getLod0MultiSurface
());
assertNull
(
gmlSolitary
.
getLod2MultiSurface
());
assertNull
(
gmlSolitary
.
getLod3MultiSurface
());
assertNull
(
gmlSolitary
.
getLod1Solid
());
assertNull
(
gmlSolitary
.
getLod2Solid
());
assertNull
(
gmlSolitary
.
getLod3Solid
());
assertNull
(
gmlSolitary
.
getDeprecatedProperties
().
getLod1Geometry
());
assertNull
(
gmlSolitary
.
getDeprecatedProperties
().
getLod2Geometry
());
assertNull
(
gmlSolitary
.
getDeprecatedProperties
().
getLod3Geometry
());
assertNull
(
gmlSolitary
.
getDeprecatedProperties
().
getLod4Geometry
());
}
@Test
public
void
testReCreateGeometriesSolidPlantCover
()
{
PlantCover
gmlPC
=
new
PlantCover
();
Vegetation
veg
=
new
Vegetation
(
Vegetation
.
VegetationType
.
PLANT_COVER
);
veg
.
setGmlObject
(
gmlPC
);
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
veg
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlPC
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlPC
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlPC
.
getLod3Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurfacePlantCover
()
{
PlantCover
gmlPC
=
new
PlantCover
();
Vegetation
veg
=
new
Vegetation
(
Vegetation
.
VegetationType
.
PLANT_COVER
);
veg
.
setGmlObject
(
gmlPC
);
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
veg
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlPC
.
getLod0MultiSurface
());
assertNotNull
(
gmlPC
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlPC
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNotNull
(
gmlPC
.
getDeprecatedProperties
().
getLod1MultiSurface
().
getObject
());
assertNotNull
(
gmlPC
.
getLod2MultiSurface
());
assertNotNull
(
gmlPC
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlPC
.
getLod3MultiSurface
());
assertNotNull
(
gmlPC
.
getLod3MultiSurface
().
getObject
());
assertNotNull
(
gmlPC
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNotNull
(
gmlPC
.
getDeprecatedProperties
().
getLod4MultiSurface
().
getObject
());
}
@Test
public
void
testReCreateGeometriesSolidSolitaryVegetationObject
()
{
SolitaryVegetationObject
gmlPC
=
new
SolitaryVegetationObject
();
Vegetation
veg
=
new
Vegetation
(
Vegetation
.
VegetationType
.
SOLITARY_VEGETATION_OBJECT
);
veg
.
setGmlObject
(
gmlPC
);
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
veg
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlPC
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlPC
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlPC
.
getLod3Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurfaceSolitaryVegetationObject
()
{
SolitaryVegetationObject
gmlPC
=
new
SolitaryVegetationObject
();
Vegetation
veg
=
new
Vegetation
(
Vegetation
.
VegetationType
.
SOLITARY_VEGETATION_OBJECT
);
veg
.
setGmlObject
(
gmlPC
);
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
veg
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
veg
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlPC
.
getLod0MultiSurface
());
assertNotNull
(
gmlPC
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlPC
.
getDeprecatedProperties
().
getLod1Geometry
());
assertNotNull
(
gmlPC
.
getDeprecatedProperties
().
getLod1Geometry
().
getObject
());
assertNotNull
(
gmlPC
.
getLod2MultiSurface
());
assertNotNull
(
gmlPC
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlPC
.
getLod3MultiSurface
());
assertNotNull
(
gmlPC
.
getLod3MultiSurface
().
getObject
());
assertNotNull
(
gmlPC
.
getDeprecatedProperties
().
getLod4Geometry
());
assertNotNull
(
gmlPC
.
getDeprecatedProperties
().
getLod4Geometry
().
getObject
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/WaterTest.java
0 → 100644
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
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.parser.ParserConfiguration
;
import
org.citygml4j.core.model.waterbody.WaterBody
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.SolidProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
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
static
org
.
mockito
.
Mockito
.
verify
;
public
class
WaterTest
{
@Test
public
void
testVisitorPropagation
()
{
WaterObject
water
=
new
WaterObject
();
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
BoundarySurface
bsMock2
=
mock
(
BoundarySurface
.
class
);
water
.
addBoundarySurface
(
bsMock
);
water
.
addBoundarySurface
(
bsMock2
);
CheckableUtilsVisitor
c
=
new
CheckableUtilsVisitor
()
{
};
water
.
accept
(
c
);
verify
(
bsMock
).
accept
(
c
);
verify
(
bsMock2
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
WaterObject
water
=
new
WaterObject
();
water
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
water
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
water
.
containsError
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
}
@Test
public
void
testContainsAnyError
()
{
WaterObject
water
=
new
WaterObject
();
assertFalse
(
water
.
containsAnyError
());
water
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
water
.
containsAnyError
());
water
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
water
.
containsAnyError
());
}
@Test
public
void
testClearAllContainedCheckResults
()
{
WaterObject
water
=
new
WaterObject
();
assertFalse
(
water
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
water
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
water
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
water
.
clearAllContainedCheckResults
();
assertFalse
(
water
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testCollectContainedErrors
()
{
WaterObject
water
=
new
WaterObject
();
water
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
water
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGmlGeometries
()
{
WaterObject
water
=
new
WaterObject
();
WaterBody
gmlWater
=
new
WaterBody
();
water
.
setGmlObject
(
gmlWater
);
gmlWater
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
());
gmlWater
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
());
gmlWater
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
gmlWater
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
gmlWater
.
setLod1Solid
(
new
SolidProperty
());
gmlWater
.
setLod2Solid
(
new
SolidProperty
());
gmlWater
.
setLod3Solid
(
new
SolidProperty
());
gmlWater
.
getDeprecatedProperties
().
setLod4Solid
(
new
SolidProperty
());
water
.
clearGmlGeometries
();
assertNull
(
gmlWater
.
getLod0MultiSurface
());
assertNull
(
gmlWater
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNull
(
gmlWater
.
getLod2MultiSurface
());
assertNull
(
gmlWater
.
getLod3MultiSurface
());
assertNull
(
gmlWater
.
getLod1Solid
());
assertNull
(
gmlWater
.
getLod2Solid
());
assertNull
(
gmlWater
.
getLod3Solid
());
assertNull
(
gmlWater
.
getDeprecatedProperties
().
getLod4Solid
());
}
@Test
public
void
testReCreateGeometriesSolid
()
{
WaterBody
gmlWater
=
new
WaterBody
();
WaterObject
water
=
new
WaterObject
();
water
.
setGmlObject
(
gmlWater
);
water
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
water
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
water
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
water
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
water
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlWater
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlWater
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlWater
.
getLod3Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlWater
.
getDeprecatedProperties
().
getLod4Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
WaterBody
gmlWater
=
new
WaterBody
();
WaterObject
water
=
new
WaterObject
();
water
.
setGmlObject
(
gmlWater
);
water
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
water
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
water
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
water
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
water
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlWater
.
getLod0MultiSurface
());
assertNotNull
(
gmlWater
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlWater
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNotNull
(
gmlWater
.
getDeprecatedProperties
().
getLod1MultiSurface
().
getObject
());
assertNotNull
(
gmlWater
.
getLod2MultiSurface
());
assertNotNull
(
gmlWater
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlWater
.
getLod3MultiSurface
());
assertNotNull
(
gmlWater
.
getLod3MultiSurface
().
getObject
());
}
}
CityDoctorParent/CityDoctorValidation/pom.xml
View file @
d1ff5020
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
de.hft.stuttgart
</groupId>
<artifactId>
CityDoctorParent
</artifactId>
<version>
3.17.
0
</version>
<version>
3.17.
2
</version>
</parent>
<artifactId>
CityDoctorValidation
</artifactId>
<name>
CityDoctorValidation
</name>
...
...
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/CityDoctorValidation.java
View file @
d1ff5020
...
...
@@ -160,10 +160,13 @@ public class CityDoctorValidation {
logger
.
error
(
"Input file '{}' does not exist."
,
input
);
System
.
exit
(
1
);
}
if
(
inputFile
.
getName
().
endsWith
(
".gml"
))
{
if
(
inputFile
.
getName
().
endsWith
(
".gml"
)
||
inputFile
.
getName
().
endsWith
(
".xml"
)
)
{
startFileValidation
(
inputFile
,
xmlOutput
,
pdfOutput
,
config
,
outputFile
);
}
else
if
(
inputFile
.
getName
().
endsWith
(
".zip"
))
{
startZipValidation
(
input
,
xmlOutput
,
pdfOutput
,
config
,
outputFile
);
}
else
{
logger
.
error
(
"Input file '{}' does not end with .gml or .xml and is not a zip archive."
,
input
);
System
.
exit
(
1
);
}
}
...
...
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/CityDoctorValidationCLI.java
View file @
d1ff5020
package
de.hft.stuttgart.citydoctor2
;
import
picocli.CommandLine
;
import
java.util.concurrent.Callable
;
import
picocli.CommandLine.Command
;
import
picocli.CommandLine.Option
;
import
picocli.CommandLine.Parameters
;
import
java.util.concurrent.Callable
;
@Command
(
name
=
"citydoctor2"
,
mixinStandardHelpOptions
=
true
,
description
=
"Validates CityGML files according to a provided validation-plan."
)
public
class
CityDoctorValidationCLI
implements
Callable
<
Integer
>
{
...
...
Prev
1
2
3
4
5
6
7
8
9
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment