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
eda1bed4
Commit
eda1bed4
authored
May 06, 2025
by
Riegel
Browse files
Merge remote-tracking branch 'origin/dev' into dev
parents
8bd667ce
ffe66fd4
Pipeline
#11080
passed with stage
in 1 minute and 19 seconds
Changes
162
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/visitors/ClearMetaInformationVisitor.java
0 → 100644
View file @
eda1bed4
package
de.hft.stuttgart.citydoctor2.utils.visitors
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry
;
/**
* This Visitor removes the metadata created by the {@link PrepareForCheckingVisitor} for the low-memory consumption mode.
*/
public
class
ClearMetaInformationVisitor
extends
AbstractCheck
{
@Override
public
void
check
(
Geometry
geometry
)
{
geometry
.
clearMetaData
();
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/visitors/ContainsAnyErrorVisitor.java
0 → 100644
View file @
eda1bed4
package
de.hft.stuttgart.citydoctor2.utils.visitors
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.check.Checkable
;
import
de.hft.stuttgart.citydoctor2.utils.CheckErrorFound
;
import
de.hft.stuttgart.citydoctor2.utils.ThrowUtils
;
/**
* This visitor checks if a checkable contains any error in its datastructure.
* <p><p/>
* This visitor's check method terminates early by throwing an unchecked {@link CheckErrorFound},
* use {@link #checkObject(Checkable) ContainsAnyErrorVisitor.checkObject(Checkable)} to handle the Throwable.
*/
public
class
ContainsAnyErrorVisitor
extends
AbstractCheck
{
/**
* Checks if a Checkable, or any Object in its datastructure, contains any error.
* <p>
* Terminates early upon finding an error by throwing {@link CheckErrorFound}
*
* @param checkable The object to check
* @throws CheckErrorFound when any Error is found
*/
public
static
void
checkObject
(
Checkable
checkable
)
throws
CheckErrorFound
{
checkable
.
accept
(
new
ContainsAnyErrorVisitor
());
}
@Override
public
void
check
(
Checkable
checkable
)
{
if
(
checkable
.
hasAnyError
())
{
ThrowUtils
.
sneakyThrow
(
new
CheckErrorFound
());
}
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/visitors/ContainsErrorVisitor.java
0 → 100644
View file @
eda1bed4
package
de.hft.stuttgart.citydoctor2.utils.visitors
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.check.CheckId
;
import
de.hft.stuttgart.citydoctor2.check.Checkable
;
import
de.hft.stuttgart.citydoctor2.utils.CheckErrorFound
;
import
de.hft.stuttgart.citydoctor2.utils.ThrowUtils
;
/**
* This visitor checks if a checkable contains a specific error in its datastructure.
* <p><p/>
* This visitor's check method terminates early by throwing an unchecked {@link CheckErrorFound},
* use {@link #checkObject(Checkable, CheckId) ContainsAnyErrorVisitor.checkObject(Checkable, CheckId)} to handle the Throwable.
*/
public
class
ContainsErrorVisitor
extends
AbstractCheck
{
private
CheckId
checkId
;
/**
* Checks if a Checkable, or any Object in its datastructure, contains a specific error.
* <p>
* Terminates early upon finding the error by throwing {@link CheckErrorFound}
*
* @param checkable The object to check
* @param checkIdentifier The specific error's associated ID
* @throws CheckErrorFound when the error is found
*/
public
static
void
checkObject
(
Checkable
checkable
,
CheckId
checkIdentifier
)
throws
CheckErrorFound
{
checkable
.
accept
(
new
ContainsErrorVisitor
(
checkIdentifier
));
}
@Override
public
void
check
(
Checkable
checkable
)
{
if
(
checkable
.
hasError
(
checkId
))
{
ThrowUtils
.
sneakyThrow
(
new
CheckErrorFound
());
}
}
public
ContainsErrorVisitor
(
CheckId
checkIdentifier
)
{
super
();
checkId
=
checkIdentifier
;
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/visitors/GmlGeometryRebuilder.java
0 → 100644
View file @
eda1bed4
package
de.hft.stuttgart.citydoctor2.utils.visitors
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
java.util.Objects
;
/**
* This Visitor recreates the Geometries of the original CityGml object from the associated Geometries in CityDoctor's
* internal model.
*/
public
class
GmlGeometryRebuilder
extends
AbstractCheck
{
private
final
GeometryFactory
factory
;
private
final
ParserConfiguration
config
;
/**
* Creates a new Rebuilder for reconstruction of CityGml geometries.
*
* @param factory the GeometryFactory used for creation of CityGml geometry objects.
* @param configuration the configuration settings of the parser
*/
public
GmlGeometryRebuilder
(
GeometryFactory
factory
,
ParserConfiguration
configuration
)
{
Objects
.
requireNonNull
(
factory
);
Objects
.
requireNonNull
(
configuration
);
this
.
factory
=
factory
;
this
.
config
=
configuration
;
}
@Override
public
void
check
(
CityObject
cityObject
)
{
cityObject
.
rebuildGeometries
(
factory
,
config
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/visitors/PrepareForCheckingVisitor.java
0 → 100644
View file @
eda1bed4
package
de.hft.stuttgart.citydoctor2.utils.visitors
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry
;
/**
* This Visitor prepares the {@link Geometry Geometries} in a Checkable for low-memory consumption mode.
*/
public
class
PrepareForCheckingVisitor
extends
AbstractCheck
{
@Override
public
void
check
(
Geometry
geom
)
{
geom
.
updateEdgesAndVertices
();
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/visitors/UnsetGeometriesVisitor.java
0 → 100644
View file @
eda1bed4
package
de.hft.stuttgart.citydoctor2.utils.visitors
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
/**
* This Visitor removes the GmlGeometries from the linked original GmlObjects in a CityObject's datastructure to reduce
* memory bloat.
*/
public
class
UnsetGeometriesVisitor
extends
AbstractCheck
{
@Override
public
void
check
(
CityObject
cityObject
)
{
cityObject
.
unsetGmlGeometries
();
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/check/CheckableTest.java
View file @
eda1bed4
...
...
@@ -48,20 +48,6 @@ public class CheckableTest {
return
null
;
}
@Override
public
void
prepareForChecking
()
{
}
@Override
public
void
clearMetaInformation
()
{
}
@Override
public
void
clearAllContainedCheckResults
()
{
}
@Override
public
Class
<?
extends
Checkable
>
getCheckClass
()
{
return
Building
.
class
;
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/AbstractBuildingTest.java
View file @
eda1bed4
...
...
@@ -23,25 +23,25 @@ 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
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.ClearCheckResultsVisitor
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.GmlGeometryRebuilder
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor
;
import
org.citygml4j.core.model.construction.WallSurface
;
import
org.citygml4j.core.model.core.AbstractSpaceBoundaryProperty
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
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.SolidProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
...
...
@@ -49,10 +49,10 @@ 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.Copyable
;
public
class
AbstractBuildingTest
{
@Test
public
void
testAccept
()
{
AbstractBuilding
ab
=
createAbstractBuilding
();
...
...
@@ -91,73 +91,59 @@ public class AbstractBuildingTest {
}
@Test
public
void
testPrepareForChecking
()
{
Installation
biMock
=
mock
(
Installation
.
class
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
public
void
testVisitorPropagation
()
{
AbstractBuilding
ab
=
createAbstractBuilding
();
ab
.
addBoundarySurface
(
bsMock
);
ab
.
addBuildingInstallation
(
biMock
);
ab
.
prepareForChecking
();
Mockito
.
verify
(
biMock
,
Mockito
.
times
(
1
)).
prepareForChecking
();
Mockito
.
verify
(
bsMock
,
Mockito
.
times
(
1
)).
prepareForChecking
();
}
BuildingRoom
mockRoom
=
mock
(
BuildingRoom
.
class
);
Installation
mockInstallation
=
mock
(
Installation
.
class
);
BuildingRoomFurniture
mockBuildingRoomFurniture
=
mock
(
BuildingRoomFurniture
.
class
);
BuildingUnit
mockBuildingUnit
=
mock
(
BuildingUnit
.
class
);
Storey
mockStorey
=
mock
(
Storey
.
class
);
BoundarySurface
mockBSurface
=
mock
(
BoundarySurface
.
class
);
Geometry
mockGeometry
=
mock
(
Geometry
.
class
);
ab
.
addBuildingRoom
(
mockRoom
);
ab
.
addBuildingInstallation
(
mockInstallation
);
ab
.
addBuildingRoomFurniture
(
mockBuildingRoomFurniture
);
ab
.
addBuildingUnit
(
mockBuildingUnit
);
ab
.
addStorey
(
mockStorey
);
ab
.
addBoundarySurface
(
mockBSurface
);
ab
.
addGeometry
(
mockGeometry
);
@Test
public
void
testClearMetaInformation
()
{
Installation
biMock
=
mock
(
Installation
.
class
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
ab
.
accept
(
c
);
AbstractBuilding
ab
=
createAbstractBuilding
();
ab
.
addBoundarySurface
(
bsMock
);
ab
.
addBuildingInstallation
(
biMock
);
ab
.
clearMetaInformation
();
Mockito
.
verify
(
biMock
,
Mockito
.
times
(
1
)).
clearMetaInformation
();
Mockito
.
verify
(
bsMock
,
Mockito
.
times
(
1
)).
clearMetaInformation
();
verify
(
mockRoom
).
accept
(
c
);
verify
(
mockInstallation
).
accept
(
c
);
verify
(
mockBuildingRoomFurniture
).
accept
(
c
);
verify
(
mockBuildingUnit
).
accept
(
c
);
verify
(
mockStorey
).
accept
(
c
);
verify
(
mockBSurface
).
accept
(
c
);
verify
(
mockGeometry
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
AbstractBuilding
ab
=
createAbstractBuilding
();
assertFalse
(
ab
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
ab
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
ab
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
ab
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testContainsErrorInBs
()
{
AbstractBuilding
ab
=
createAbstractBuilding
();
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
ab
.
addBoundarySurface
(
bsMock
);
assertFalse
(
ab
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
Mockito
.
when
(
bsMock
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
)).
thenReturn
(
true
);
assertFalse
(
ab
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
ab
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
ab
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
ab
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testContainsErrorInBi
()
{
AbstractBuilding
ab
=
createAbstractBuilding
();
Installation
biMock
=
mock
(
Installation
.
class
);
ab
.
addBuildingInstallation
(
biMock
);
assertFalse
(
ab
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
Mockito
.
when
(
biMock
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
)).
thenReturn
(
true
);
assertTrue
(
ab
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
Installation
biMock
=
mock
(
Installation
.
class
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
AbstractBuilding
ab
=
createAbstractBuilding
();
assertTrue
(
ab
.
getAllCheckResults
().
isEmpty
());
ab
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
ab
.
addBoundarySurface
(
bsMock
);
ab
.
addBuildingInstallation
(
biMock
);
assertEquals
(
1
,
ab
.
getAllCheckResults
().
size
());
ab
.
clearAllContainedCheckResults
();
Mockito
.
verify
(
biMock
,
Mockito
.
times
(
1
)).
clearAllContainedCheckResults
();
Mockito
.
verify
(
bsMock
,
Mockito
.
times
(
1
)).
clearAllContainedCheckResults
();
assertTrue
(
ab
.
getAllCheckResults
().
isEmpty
());
}
...
...
@@ -172,85 +158,59 @@ public class AbstractBuildingTest {
assertTrue
(
ab
.
containsAnyError
());
}
@Test
public
void
testContainsAnyErrorInBs
()
{
AbstractBuilding
ab
=
createAbstractBuilding
();
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
ab
.
addBoundarySurface
(
bsMock
);
assertFalse
(
ab
.
containsAnyError
());
Mockito
.
when
(
bsMock
.
containsAnyError
()).
thenReturn
(
true
);
assertTrue
(
ab
.
containsAnyError
());
}
@Test
public
void
testContainsAnyErrorInBi
()
{
AbstractBuilding
ab
=
createAbstractBuilding
();
Installation
biMock
=
mock
(
Installation
.
class
);
ab
.
addBuildingInstallation
(
biMock
);
assertFalse
(
ab
.
containsAnyError
());
Mockito
.
when
(
biMock
.
containsAnyError
()).
thenReturn
(
true
);
assertTrue
(
ab
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
Installation
biMock
=
mock
(
Installation
.
class
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
AbstractBuilding
ab
=
createAbstractBuilding
();
ab
.
addBoundarySurface
(
bsMock
);
ab
.
addBuildingInstallation
(
biMock
);
ab
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
ab
.
collectContainedErrors
(
errors
);
Mockito
.
verify
(
biMock
,
Mockito
.
times
(
1
)).
collectContainedErrors
(
errors
);
Mockito
.
verify
(
bsMock
,
Mockito
.
times
(
1
)).
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testReCreateGeometriesSolid
()
{
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
);
AbstractBuilding
ab
=
createAbstractBuilding
();
org
.
citygml4j
.
core
.
model
.
building
.
AbstractBuilding
gmlAb
=
new
org
.
citygml4j
.
core
.
model
.
building
.
Building
();
ab
.
setCityGmlBuilding
(
gmlAb
);
ab
.
addGeometry
(
geom
);
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ab
.
reCreateGeometries
(
factory
,
config
);
AbstractSolid
aSolid
=
gmlAb
.
getLod2Solid
().
getObject
();
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
=
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
};
for
(
int
i
=
0
;
i
<
posList
.
size
();
i
++)
{
assertEquals
(
expectedValues
[
i
],
posList
.
get
(
i
),
0.00000001
);
}
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAb
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAb
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAb
.
getLod3Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAb
.
getDeprecatedProperties
().
getLod4Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
);
AbstractBuilding
ab
=
createAbstractBuilding
();
org
.
citygml4j
.
core
.
model
.
building
.
AbstractBuilding
gmlAb
=
new
org
.
citygml4j
.
core
.
model
.
building
.
Building
();
ab
.
setCityGmlBuilding
(
gmlAb
);
ab
.
addGeometry
(
geom
);
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
ab
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ab
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlAb
.
getLod0MultiSurface
());
assertNotNull
(
gmlAb
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlAb
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNotNull
(
gmlAb
.
getDeprecatedProperties
().
getLod1MultiSurface
().
getObject
());
assertNotNull
(
gmlAb
.
getLod2MultiSurface
());
assertNotNull
(
gmlAb
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlAb
.
getLod3MultiSurface
());
assertNotNull
(
gmlAb
.
getLod3MultiSurface
().
getObject
());
assertNotNull
(
gmlAb
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNotNull
(
gmlAb
.
getDeprecatedProperties
().
getLod4MultiSurface
().
getObject
());
}
@Test
...
...
@@ -266,7 +226,7 @@ public class AbstractBuildingTest {
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ab
.
reCreateGeometries
(
factory
,
config
);
Mockito
.
verify
(
bsMock
).
reCreateGeometries
(
factory
,
config
);
Mockito
.
verify
(
bsMock
).
accept
(
any
(
GmlGeometryRebuilder
.
class
)
);
}
@Test
...
...
@@ -299,18 +259,15 @@ public class AbstractBuildingTest {
org
.
citygml4j
.
core
.
model
.
building
.
AbstractBuilding
gmlAb
=
new
org
.
citygml4j
.
core
.
model
.
building
.
Building
();
ab
.
setCityGmlBuilding
(
gmlAb
);
ab
.
reCreateGeometries
(
factory
,
config
);
Mockito
.
verify
(
biMock
).
reCreateGeometries
(
factory
,
config
);
Mockito
.
verify
(
biMock
).
accept
(
any
(
GmlGeometryRebuilder
.
class
)
);
}
@Test
public
void
testUnsetGmlGeometries
()
{
Installation
biMock
=
mock
(
Installation
.
class
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
AbstractBuilding
ab
=
createAbstractBuilding
();
ab
.
addBoundarySurface
(
bsMock
);
ab
.
addBuildingInstallation
(
biMock
);
org
.
citygml4j
.
core
.
model
.
building
.
AbstractBuilding
gmlAb
=
new
org
.
citygml4j
.
core
.
model
.
building
.
Building
();
ab
.
setCityGmlBuilding
(
gmlAb
);
gmlAb
.
setLod1Solid
(
new
SolidProperty
());
gmlAb
.
setLod2Solid
(
new
SolidProperty
());
gmlAb
.
setLod3Solid
(
new
SolidProperty
());
...
...
@@ -319,10 +276,9 @@ public class AbstractBuildingTest {
gmlAb
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
gmlAb
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
gmlAb
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
());
ab
.
setCityGmlBuilding
(
gmlAb
);
ab
.
unsetGmlGeometries
();
Mockito
.
verify
(
biMock
).
unsetGmlGeometries
();
Mockito
.
verify
(
bsMock
).
unsetGmlGeometries
();
ab
.
clearGmlGeometries
();
assertNull
(
gmlAb
.
getLod1Solid
());
assertNull
(
gmlAb
.
getLod2Solid
());
assertNull
(
gmlAb
.
getLod3Solid
());
...
...
@@ -340,21 +296,15 @@ public class AbstractBuildingTest {
}
private
AbstractBuilding
createAbstractBuilding
()
{
AbstractBuilding
ab
=
new
AbstractBuilding
()
{
return
new
AbstractBuilding
()
{
private
static
final
long
serialVersionUID
=
-
448362592456318541L
;
@Override
public
Copyable
createCopyInstance
()
{
return
null
;
}
@Override
public
CityObject
getTopLevelCityObject
(){
return
null
;
}
};
return
ab
;
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/AbstractRoomTest.java
0 → 100644
View file @
eda1bed4
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
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.core.AbstractSpaceBoundary
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.citygml4j.core.visitor.ObjectVisitor
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
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
AbstractRoomTest
{
AbstractRoom
abRoom
;
@Before
public
void
setUp
()
{
abRoom
=
new
AbstractRoom
()
{
@Override
public
CityObject
getTopLevelCityObject
()
{
return
null
;
}
};
}
@Test
public
void
testAbstractRoomVisitorPropagation
()
{
Installation
mockInstallation
=
Mockito
.
mock
(
Installation
.
class
);
BoundarySurface
mockBoundarySurface
=
Mockito
.
mock
(
BoundarySurface
.
class
);
Geometry
geometry
=
Mockito
.
mock
(
Geometry
.
class
);
abRoom
.
addRoomInstallation
(
mockInstallation
);
abRoom
.
addBoundarySurface
(
mockBoundarySurface
);
abRoom
.
addGeometry
(
geometry
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
abRoom
.
accept
(
c
);
Mockito
.
verify
(
mockInstallation
).
accept
(
c
);
Mockito
.
verify
(
mockBoundarySurface
).
accept
(
c
);
Mockito
.
verify
(
geometry
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
assertFalse
(
abRoom
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
abRoom
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
abRoom
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
abRoom
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
abRoom
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
abRoom
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
abRoom
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
abRoom
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
abRoom
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertEquals
(
1
,
abRoom
.
getAllCheckResults
().
size
());
abRoom
.
clearAllContainedCheckResults
();
assertTrue
(
abRoom
.
getAllCheckResults
().
isEmpty
());
}
@Test
public
void
testContainsAnyError
()
{
assertFalse
(
abRoom
.
containsAnyError
());
abRoom
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
abRoom
.
containsAnyError
());
abRoom
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
abRoom
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
abRoom
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
abRoom
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGmlGeometries
()
{
org
.
citygml4j
.
core
.
model
.
core
.
AbstractUnoccupiedSpace
gmlAUS
=
new
org
.
citygml4j
.
core
.
model
.
core
.
AbstractUnoccupiedSpace
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
return
;
}
@Override
public
boolean
isValidBoundary
(
Class
<?
extends
AbstractSpaceBoundary
>
type
)
{
return
false
;
}
};
gmlAUS
.
setLod1Solid
(
new
SolidProperty
());
gmlAUS
.
setLod2Solid
(
new
SolidProperty
());
gmlAUS
.
setLod3Solid
(
new
SolidProperty
());
gmlAUS
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
());
gmlAUS
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
gmlAUS
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
abRoom
.
cgmlRoom
=
gmlAUS
;
abRoom
.
clearGmlGeometries
();
assertNull
(
gmlAUS
.
getLod1Solid
());
assertNull
(
gmlAUS
.
getLod2Solid
());
assertNull
(
gmlAUS
.
getLod3Solid
());
assertNull
(
gmlAUS
.
getLod0MultiSurface
());
assertNull
(
gmlAUS
.
getLod2MultiSurface
());
assertNull
(
gmlAUS
.
getLod3MultiSurface
());
}
@Test
public
void
testReCreateGeometriesSolid
()
{
org
.
citygml4j
.
core
.
model
.
core
.
AbstractUnoccupiedSpace
gmlAUS
=
new
org
.
citygml4j
.
core
.
model
.
core
.
AbstractUnoccupiedSpace
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
return
;
}
@Override
public
boolean
isValidBoundary
(
Class
<?
extends
AbstractSpaceBoundary
>
type
)
{
return
false
;
}
};
abRoom
.
cgmlRoom
=
gmlAUS
;
abRoom
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
abRoom
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
abRoom
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
abRoom
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAUS
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAUS
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAUS
.
getLod3Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
org
.
citygml4j
.
core
.
model
.
core
.
AbstractUnoccupiedSpace
gmlAUS
=
new
org
.
citygml4j
.
core
.
model
.
core
.
AbstractUnoccupiedSpace
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
return
;
}
@Override
public
boolean
isValidBoundary
(
Class
<?
extends
AbstractSpaceBoundary
>
type
)
{
return
false
;
}
};
abRoom
.
cgmlRoom
=
gmlAUS
;
abRoom
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
abRoom
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
abRoom
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
abRoom
.
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/AbstractTunnelTest.java
0 → 100644
View file @
eda1bed4
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
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.citygml4j.core.visitor.ObjectVisitor
;
import
org.junit.Before
;
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
AbstractTunnelTest
{
AbstractTunnel
at
;
@Before
public
void
setUp
()
{
at
=
new
AbstractTunnel
()
{
@Override
public
CityObject
getTopLevelCityObject
()
{
return
null
;
}
};
}
@Test
public
void
testVisitorPropagation
()
{
Installation
mockInstallation
=
mock
(
Installation
.
class
);
TunnelHollow
mockTunnelHollow
=
mock
(
TunnelHollow
.
class
);
TunnelFurniture
mockTunnelFurniture
=
mock
(
TunnelFurniture
.
class
);
TunnelPart
mockTunnelPart
=
mock
(
TunnelPart
.
class
);
TunnelConstructiveElement
mockTunnelConstructiveElement
=
mock
(
TunnelConstructiveElement
.
class
);
BoundarySurface
mockBoundarySurface
=
mock
(
BoundarySurface
.
class
);
Geometry
mockGeometry
=
mock
(
Geometry
.
class
);
at
.
addTunnelInstallation
(
mockInstallation
);
at
.
addTunnelHollow
(
mockTunnelHollow
);
at
.
addTunnelFurniture
(
mockTunnelFurniture
);
at
.
addTunnelPart
(
mockTunnelPart
);
at
.
addTunnelConstructiveElement
(
mockTunnelConstructiveElement
);
at
.
addBoundarySurface
(
mockBoundarySurface
);
at
.
addGeometry
(
mockGeometry
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
at
.
accept
(
c
);
verify
(
mockInstallation
).
accept
(
c
);
verify
(
mockTunnelHollow
).
accept
(
c
);
verify
(
mockTunnelFurniture
).
accept
(
c
);
verify
(
mockTunnelPart
).
accept
(
c
);
verify
(
mockTunnelConstructiveElement
).
accept
(
c
);
verify
(
mockBoundarySurface
).
accept
(
c
);
verify
(
mockGeometry
).
accept
(
c
);
}
@Test
public
void
testContainsError
()
{
assertFalse
(
at
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
at
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
at
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
at
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
at
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
at
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
at
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
at
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
at
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertEquals
(
1
,
at
.
getAllCheckResults
().
size
());
at
.
clearAllContainedCheckResults
();
assertTrue
(
at
.
getAllCheckResults
().
isEmpty
());
}
@Test
public
void
testContainsAnyError
()
{
assertFalse
(
at
.
containsAnyError
());
at
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
at
.
containsAnyError
());
at
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
at
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
at
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
at
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
}
@Test
public
void
testUnsetGeometries
()
{
org
.
citygml4j
.
core
.
model
.
tunnel
.
AbstractTunnel
gmlAt
=
new
org
.
citygml4j
.
core
.
model
.
tunnel
.
AbstractTunnel
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
at
.
setGmlObject
(
gmlAt
);
gmlAt
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
());
gmlAt
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
());
gmlAt
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
());
gmlAt
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
());
gmlAt
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
());
gmlAt
.
setLod1Solid
(
new
SolidProperty
());
gmlAt
.
setLod2Solid
(
new
SolidProperty
());
gmlAt
.
setLod3Solid
(
new
SolidProperty
());
gmlAt
.
getDeprecatedProperties
().
setLod4Solid
(
new
SolidProperty
());
at
.
clearGmlGeometries
();
assertNull
(
gmlAt
.
getLod0MultiSurface
());
assertNull
(
gmlAt
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNull
(
gmlAt
.
getLod2MultiSurface
());
assertNull
(
gmlAt
.
getLod3MultiSurface
());
assertNull
(
gmlAt
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNull
(
gmlAt
.
getLod1Solid
());
assertNull
(
gmlAt
.
getLod2Solid
());
assertNull
(
gmlAt
.
getLod3Solid
());
assertNull
(
gmlAt
.
getDeprecatedProperties
().
getLod4Solid
());
}
@Test
public
void
testReCreateGeometriesSolid
()
{
org
.
citygml4j
.
core
.
model
.
tunnel
.
AbstractTunnel
gmlAt
=
new
org
.
citygml4j
.
core
.
model
.
tunnel
.
AbstractTunnel
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
at
.
setGmlObject
(
gmlAt
);
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
at
.
reCreateGeometries
(
factory
,
config
);
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAt
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAt
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAt
.
getLod3Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlAt
.
getDeprecatedProperties
().
getLod4Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurface
()
{
org
.
citygml4j
.
core
.
model
.
tunnel
.
AbstractTunnel
gmlAt
=
new
org
.
citygml4j
.
core
.
model
.
tunnel
.
AbstractTunnel
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
at
.
setGmlObject
(
gmlAt
);
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
at
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
at
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
gmlAt
.
getLod0MultiSurface
());
assertNotNull
(
gmlAt
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlAt
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNotNull
(
gmlAt
.
getDeprecatedProperties
().
getLod1MultiSurface
().
getObject
());
assertNotNull
(
gmlAt
.
getLod2MultiSurface
());
assertNotNull
(
gmlAt
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlAt
.
getLod3MultiSurface
());
assertNotNull
(
gmlAt
.
getLod3MultiSurface
().
getObject
());
assertNotNull
(
gmlAt
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNotNull
(
gmlAt
.
getDeprecatedProperties
().
getLod4MultiSurface
().
getObject
());
}
}
\ No newline at end of file
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/BoundarySurfaceTest.java
View file @
eda1bed4
...
...
@@ -23,11 +23,16 @@ 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
.
verify
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.ClearCheckResultsVisitor
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.GmlGeometryRebuilder
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor
;
import
org.citygml4j.core.model.construction.AbstractConstructionSurface
;
import
org.citygml4j.core.model.construction.WallSurface
;
import
org.citygml4j.core.model.core.AbstractThematicSurface
;
...
...
@@ -45,6 +50,21 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
public
class
BoundarySurfaceTest
{
//Todo: Check this class for rework potential with the new Visitors
@Test
public
void
testVisitorPropagation
()
{
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
null
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
bs
.
addOpening
(
oMock
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
bs
.
accept
(
c
);
verify
(
oMock
).
accept
(
c
);
}
@Test
public
void
testAccept
()
{
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
null
);
...
...
@@ -59,7 +79,7 @@ public class BoundarySurfaceTest {
}
};
bs
.
accept
(
c
);
Mockito
.
verify
(
oMock
).
accept
(
c
);
verify
(
oMock
).
accept
(
c
);
assertEquals
(
1
,
bsCounter
.
intValue
());
}
...
...
@@ -77,26 +97,18 @@ public class BoundarySurfaceTest {
}
};
bs
.
accept
(
c
);
Mockito
.
verify
(
oMock
).
accept
(
c
);
verify
(
oMock
).
accept
(
c
);
assertEquals
(
0
,
bsCounter
.
intValue
());
}
@Test
public
void
testPrepareForChecking
()
{
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
null
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
bs
.
addOpening
(
oMock
);
Geometry
geom
=
new
Geometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
);
Geometry
spyGeom
=
Mockito
.
spy
(
geom
);
bs
.
addGeometry
(
spyGeom
);
bs
.
prepareForChecking
();
Mockito
.
verify
(
oMock
).
prepareForChecking
();
}
@Test
public
void
testClearMetaInformation
()
{
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
null
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
bs
.
addOpening
(
oMock
);
bs
.
clearMetaInformation
();
Mockito
.
verify
(
oMock
).
clearMetaInformation
();
verify
(
spyGeom
).
updateEdgesAndVertices
();
}
@Test
...
...
@@ -130,43 +142,29 @@ public class BoundarySurfaceTest {
assertFalse
(
bs
.
getAllCheckResults
().
isEmpty
());
bs
.
addOpening
(
oMock
);
bs
.
clearAllContainedCheckResults
();
Mockito
.
verify
(
oMock
).
clearAllContainedCheckResults
(
);
verify
(
oMock
).
accept
(
any
(
ClearCheckResultsVisitor
.
class
)
);
assertTrue
(
bs
.
getAllCheckResults
().
isEmpty
());
}
@Test
public
void
testContainsAnyError
()
{
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
null
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
bs
.
addOpening
(
oMock
);
assertFalse
(
bs
.
containsAnyError
());
Mockito
.
verify
(
oMock
).
containsAnyError
();
bs
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
Mockito
.
mock
(
CheckError
.
class
)));
assertTrue
(
bs
.
containsAnyError
());
}
@Test
public
void
testContainsAnyErrorInOpeing
()
{
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
null
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
bs
.
addOpening
(
oMock
);
Mockito
.
when
(
oMock
.
containsAnyError
()).
thenReturn
(
true
);
assertTrue
(
bs
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
null
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
bs
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
Mockito
.
mock
(
CheckError
.
class
)));
bs
.
addOpening
(
oMock
);
List
<
CheckError
>
errors
=
new
ArrayList
<>();
bs
.
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
());
Mockito
.
verify
(
oMock
).
collectContainedErrors
(
errors
)
;
;
}
@Test
...
...
@@ -320,7 +318,7 @@ public class BoundarySurfaceTest {
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bs
.
reCreateGeometries
(
factory
,
config
);
Mockito
.
verify
(
oMock
).
reCreateGeometries
(
factory
,
config
);
verify
(
oMock
).
accept
(
any
(
GmlGeometryRebuilder
.
class
)
);
}
@Test
...
...
@@ -342,8 +340,8 @@ public class BoundarySurfaceTest {
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
ws
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
bs
.
addOpening
(
oMock
);
bs
.
u
nsetG
mlG
eometries
(
);
Mockito
.
verify
(
oMock
).
u
nsetG
mlG
eometries
(
);
bs
.
accept
(
new
U
nsetGeometries
Visitor
()
);
verify
(
oMock
).
accept
(
any
(
U
nsetGeometries
Visitor
.
class
)
);
assertNull
(
ws
.
getLod2MultiSurface
());
assertNull
(
ws
.
getLod3MultiSurface
());
assertNull
(
ws
.
getDeprecatedProperties
().
getLod4MultiSurface
());
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/BridgeObjectTest.java
View file @
eda1bed4
...
...
@@ -22,17 +22,21 @@ 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
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
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
java.util.concurrent.atomic.AtomicInteger
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor
;
import
org.citygml4j.core.model.bridge.AbstractBridge
;
import
org.citygml4j.core.model.bridge.Bridge
;
import
org.citygml4j.core.model.deprecated.bridge.DeprecatedPropertiesOfAbstractBridge
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.citygml4j.core.visitor.ObjectVisitor
;
import
org.junit.Test
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
...
...
@@ -42,9 +46,12 @@ import de.hft.stuttgart.citydoctor2.check.CheckResult;
import
de.hft.stuttgart.citydoctor2.check.ResultStatus
;
import
de.hft.stuttgart.citydoctor2.datastructure.BridgeObject.BridgeType
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
org.mockito.Mockito
;
public
class
BridgeObjectTest
{
//TODO: Rework this class with the new Visitors
@Test
public
void
testAccept
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
...
...
@@ -68,206 +75,156 @@ public class BridgeObjectTest {
assertEquals
(
1
,
bsCounter
.
intValue
());
AtomicInteger
boCounter2
=
new
AtomicInteger
(
0
);
c
=
new
AbstractCheck
();
c
=
new
AbstractCheck
()
{
};
bo
.
accept
(
c
);
assertEquals
(
0
,
boCounter2
.
intValue
());
}
@Test
public
void
testPr
e
pa
reForChecking
()
{
public
void
test
Visitor
Pr
o
pa
gation
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
BridgeObject
partMock
=
mock
(
BridgeObject
.
class
);
BridgeRoom
mockRoom
=
mock
(
BridgeRoom
.
class
);
BridgeRoomFurniture
mockFurn
=
mock
(
BridgeRoomFurniture
.
class
);
BridgeConstructiveElement
ceMock
=
mock
(
BridgeConstructiveElement
.
class
);
Installation
instMock
=
mock
(
Installation
.
class
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
Geometry
geomMock
=
mock
(
Geometry
.
class
);
bo
.
addBridgePart
(
partMock
);
bo
.
addBridgeRoom
(
mockRoom
);
bo
.
addBridgeFurniture
(
mockFurn
);
bo
.
addConstructiveElement
(
ceMock
);
bo
.
addBridgeInstallation
(
instMock
);
bo
.
addBoundarySurface
(
bsMock
);
bo
.
prepareForChecking
();
verify
(
bsMock
).
prepareForChecking
();
bo
.
addGeometry
(
geomMock
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
bo
.
accept
(
c
);
verify
(
partMock
).
accept
(
c
);
verify
(
mockRoom
).
accept
(
c
);
verify
(
mockFurn
).
accept
(
c
);
verify
(
ceMock
).
accept
(
c
);
verify
(
instMock
).
accept
(
c
);
verify
(
bsMock
).
accept
(
c
);
verify
(
geomMock
).
accept
(
c
);
}
@Test
public
void
test
ClearMetaInformation
()
{
public
void
test
PrepareForChecking
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
bo
.
addBoundarySurface
(
bsMock
);
bo
.
clearMetaInformation
();
verify
(
bsMock
).
clearMetaInformation
();
Geometry
geom
=
new
Geometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
);
Geometry
spyGeom
=
Mockito
.
spy
(
geom
);
bo
.
addGeometry
(
spyGeom
);
bo
.
prepareForChecking
();
verify
(
spyGeom
).
updateEdgesAndVertices
();
}
@Test
public
void
testContainsError
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
assertFalse
(
bo
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
bo
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
bo
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
bo
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
}
@Test
public
void
testContainsError2
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
bo
.
addBoundarySurface
(
bsMock
);
assertFalse
(
bo
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
when
(
bsMock
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
)).
thenReturn
(
true
);
assertFalse
(
bo
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
bo
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_NON_PLANAR
,
ResultStatus
.
OK
,
mock
(
CheckError
.
class
)));
assertTrue
(
bo
.
containsError
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
bo
.
containsError
(
CheckId
.
C_GE_P_NON_PLANAR
));
}
@Test
public
void
testClearAllContainedCheckResults
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
bo
.
addBoundarySurface
(
bsMock
);
bo
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertEquals
(
1
,
bo
.
getAllCheckResults
().
size
());
bo
.
clearAllContainedCheckResults
();
verify
(
bsMock
).
clearAllContained
CheckResults
();
assertTrue
(
bo
.
getAll
CheckResults
()
.
isEmpty
())
;
}
@Test
public
void
testContainsAnyError
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
bo
.
addBoundarySurface
(
bsMock
);
bo
.
containsAnyError
();
verify
(
bsMock
).
containsAnyError
();
when
(
bsMock
.
containsAnyError
()).
thenReturn
(
true
);
assertFalse
(
bo
.
containsAnyError
());
bo
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
OK
,
null
));
assertFalse
(
bo
.
containsAnyError
());
bo
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
bo
.
containsAnyError
());
BridgeObject
bo2
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
bo2
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
assertTrue
(
bo2
.
containsAnyError
());
}
@Test
public
void
testCollectContainedErrors
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
bo
.
addBoundarySurface
(
bsMock
);
ArrayList
<
CheckError
>
errors
=
new
ArrayList
<>();
bo
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
mock
(
CheckError
.
class
)));
List
<
CheckError
>
errors
=
new
ArrayList
<>();
bo
.
collectContainedErrors
(
errors
);
verify
(
bsMock
).
collectContainedErrors
(
errors
);
assertEquals
(
1
,
errors
.
size
()
);
}
@Test
public
void
testReCreateGeometries
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
bo
.
addBoundarySurface
(
bsMock
);
GeometryFactory
factoryMock
=
mock
(
GeometryFactory
.
class
);
ParserConfiguration
configMock
=
mock
(
ParserConfiguration
.
class
);
bo
.
reCreateGeometries
(
factoryMock
,
configMock
);
verify
(
bsMock
).
reCreateGeometries
(
factoryMock
,
configMock
);
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod1
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
);
AbstractBridge
ab
=
new
Bridge
();
bo
.
setGmlObject
(
ab
);
bo
.
addGeometry
(
geom
);
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bo
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
ab
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNotNull
(
ab
.
getDeprecatedProperties
().
getLod1MultiSurface
().
getObject
());
public
void
testReCreateGeometriesSolid
()
{
org
.
citygml4j
.
core
.
model
.
bridge
.
AbstractBridge
gmlBr
=
new
AbstractBridge
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
BridgeObject
bo
=
new
BridgeObject
(
gmlBr
);
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
));
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
));
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
));
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD4
));
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod2
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
);
AbstractBridge
ab
=
new
Bridge
();
bo
.
setGmlObject
(
ab
);
bo
.
addGeometry
(
geom
);
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bo
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
ab
.
getLod2MultiSurface
());
assertNotNull
(
ab
.
getLod2MultiSurface
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod3
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
);
AbstractBridge
ab
=
new
Bridge
();
bo
.
setGmlObject
(
ab
);
bo
.
addGeometry
(
geom
);
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bo
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
ab
.
getLod3MultiSurface
());
assertNotNull
(
ab
.
getLod3MultiSurface
().
getObject
());
}
@Test
public
void
testReCreateGeometriesMultiSurfaceLod4
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
);
AbstractBridge
ab
=
new
Bridge
();
bo
.
setGmlObject
(
ab
);
bo
.
addGeometry
(
geom
);
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bo
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
ab
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNotNull
(
ab
.
getDeprecatedProperties
().
getLod4MultiSurface
().
getObject
());
}
@Test
public
void
testReCreateGeometriesSolidLod1
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD1
);
AbstractBridge
ab
=
new
Bridge
();
bo
.
setGmlObject
(
ab
);
bo
.
addGeometry
(
geom
);
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bo
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
ab
.
getLod1Solid
());
assertNotNull
(
ab
.
getLod1Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesSolidLod2
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD2
);
AbstractBridge
ab
=
new
Bridge
();
bo
.
setGmlObject
(
ab
);
bo
.
addGeometry
(
geom
);
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bo
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
ab
.
getLod2Solid
());
assertNotNull
(
ab
.
getLod2Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesSolidLod3
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD3
);
AbstractBridge
ab
=
new
Bridge
();
bo
.
setGmlObject
(
ab
);
bo
.
addGeometry
(
geom
);
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bo
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
ab
.
getLod3Solid
());
assertNotNull
(
ab
.
getLod3Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlBr
.
getLod1Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlBr
.
getLod2Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlBr
.
getLod3Solid
().
getObject
());
GeometryTestUtils
.
assertSolidMatchesExpectedValues
(
gmlBr
.
getDeprecatedProperties
().
getLod4Solid
().
getObject
());
}
@Test
public
void
testReCreateGeometriesSolidLod4
()
{
BridgeObject
bo
=
new
BridgeObject
(
mock
(
AbstractBridge
.
class
));
Geometry
geom
=
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD4
);
AbstractBridge
ab
=
new
Bridge
();
bo
.
setGmlObject
(
ab
);
bo
.
addGeometry
(
geom
);
public
void
testReCreateGeometriesMultiSurface
()
{
org
.
citygml4j
.
core
.
model
.
bridge
.
AbstractBridge
gmlBr
=
new
AbstractBridge
()
{
@Override
public
void
accept
(
ObjectVisitor
visitor
)
{
}
};
BridgeObject
bo
=
new
BridgeObject
(
gmlBr
);
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD0
));
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD1
));
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
));
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD3
));
bo
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD4
));
GeometryFactory
factory
=
GeometryFactory
.
newInstance
();
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
bo
.
reCreateGeometries
(
factory
,
config
);
assertNotNull
(
ab
.
getDeprecatedProperties
().
getLod4Solid
());
assertNotNull
(
ab
.
getDeprecatedProperties
().
getLod4Solid
().
getObject
());
assertNotNull
(
gmlBr
.
getLod0MultiSurface
());
assertNotNull
(
gmlBr
.
getLod0MultiSurface
().
getObject
());
assertNotNull
(
gmlBr
.
getDeprecatedProperties
().
getLod1MultiSurface
());
assertNotNull
(
gmlBr
.
getDeprecatedProperties
().
getLod1MultiSurface
().
getObject
());
assertNotNull
(
gmlBr
.
getLod2MultiSurface
());
assertNotNull
(
gmlBr
.
getLod2MultiSurface
().
getObject
());
assertNotNull
(
gmlBr
.
getLod3MultiSurface
());
assertNotNull
(
gmlBr
.
getLod3MultiSurface
().
getObject
());
assertNotNull
(
gmlBr
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNotNull
(
gmlBr
.
getDeprecatedProperties
().
getLod4MultiSurface
().
getObject
());
}
@Test
public
void
testUnsetGmlGeometries
()
{
AbstractBridge
abMock
=
mock
(
AbstractBridge
.
class
);
...
...
@@ -276,8 +233,13 @@ public class BridgeObjectTest {
BridgeObject
bo
=
new
BridgeObject
(
abMock
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
bo
.
addBoundarySurface
(
bsMock
);
bo
.
unsetGmlGeometries
();
doAnswer
(
invocation
->
{
bsMock
.
unsetGmlGeometries
();
return
null
;
}).
when
(
bsMock
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
bo
.
accept
(
new
UnsetGeometriesVisitor
());
verify
(
bsMock
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
verify
(
bsMock
).
unsetGmlGeometries
();
verify
(
propsMock
).
setLod1MultiSurface
(
null
);
verify
(
abMock
).
setLod2MultiSurface
(
null
);
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/BuildingTest.java
View file @
eda1bed4
...
...
@@ -22,9 +22,14 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotSame
;
import
static
org
.
junit
.
Assert
.
assertSame
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
org.citygml4j.core.model.construction.RoofSurface
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.xmlobjects.gml.model.basictypes.Code
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType
;
...
...
@@ -120,4 +125,42 @@ public class BuildingTest {
return
b
;
}
@Test
public
void
testVisitorPropagation
()
{
Building
b
=
new
Building
();
BuildingPart
bp
=
new
BuildingPart
(
b
);
BuildingPart
spyBp
=
Mockito
.
spy
(
bp
);
b
.
getBuildingParts
().
remove
(
bp
);
b
.
addBuildingPart
(
spyBp
);
BuildingRoom
mockRoom
=
mock
(
BuildingRoom
.
class
);
Installation
mockInstallation
=
mock
(
Installation
.
class
);
BuildingRoomFurniture
mockBuildingRoomFurniture
=
mock
(
BuildingRoomFurniture
.
class
);
BuildingUnit
mockBuildingUnit
=
mock
(
BuildingUnit
.
class
);
Storey
mockStorey
=
mock
(
Storey
.
class
);
b
.
addBuildingRoom
(
mockRoom
);
b
.
addBuildingInstallation
(
mockInstallation
);
b
.
addBuildingRoomFurniture
(
mockBuildingRoomFurniture
);
b
.
addBuildingUnit
(
mockBuildingUnit
);
b
.
addStorey
(
mockStorey
);
bp
.
addBuildingRoom
(
mockRoom
);
bp
.
addBuildingInstallation
(
mockInstallation
);
bp
.
addBuildingRoomFurniture
(
mockBuildingRoomFurniture
);
bp
.
addBuildingUnit
(
mockBuildingUnit
);
bp
.
addStorey
(
mockStorey
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
b
.
accept
(
c
);
verify
(
spyBp
).
accept
(
c
);
verify
(
mockRoom
,
times
(
2
)).
accept
(
c
);
verify
(
mockInstallation
,
times
(
2
)).
accept
(
c
);
verify
(
mockBuildingRoomFurniture
,
times
(
2
)).
accept
(
c
);
verify
(
mockBuildingUnit
,
times
(
2
)).
accept
(
c
);
verify
(
mockStorey
,
times
(
2
)).
accept
(
c
);
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModelTest.java
View file @
eda1bed4
...
...
@@ -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 @
eda1bed4
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 @
eda1bed4
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
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
);
AbstractCheck
check
=
new
AbstractCheck
()
{
};
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 @
eda1bed4
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
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
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
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 @
eda1bed4
...
...
@@ -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.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.ClearCheckResultsVisitor
;
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
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
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
(
ClearCheckResultsVisitor
.
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 @
eda1bed4
...
...
@@ -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 @
eda1bed4
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
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,43 +62,91 @@ 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
);
...
...
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