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
ae344b1a
Commit
ae344b1a
authored
Apr 11, 2025
by
Riegel
Browse files
Test: adjust testcases
parent
eebe787b
Changes
5
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/AbstractBuildingTest.java
View file @
ae344b1a
...
@@ -94,6 +94,35 @@ public class AbstractBuildingTest {
...
@@ -94,6 +94,35 @@ public class AbstractBuildingTest {
assertEquals
(
2
,
biCounter
.
intValue
());
assertEquals
(
2
,
biCounter
.
intValue
());
}
}
@Test
public
void
testVisitorPropagation
()
{
AbstractBuilding
ab
=
createAbstractBuilding
();
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
);
ab
.
addBuildingRoom
(
mockRoom
);
ab
.
addBuildingInstallation
(
mockInstallation
);
ab
.
addBuildingRoomFurniture
(
mockBuildingRoomFurniture
);
ab
.
addBuildingUnit
(
mockBuildingUnit
);
ab
.
addStorey
(
mockStorey
);
ab
.
addBoundarySurface
(
mockBSurface
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
ab
.
accept
(
c
);
verify
(
mockRoom
).
accept
(
c
);
verify
(
mockInstallation
).
accept
(
c
);
verify
(
mockBuildingRoomFurniture
).
accept
(
c
);
verify
(
mockBuildingUnit
).
accept
(
c
);
verify
(
mockStorey
).
accept
(
c
);
verify
(
mockBSurface
).
accept
(
c
);
}
@Test
@Test
public
void
testPrepareForChecking
()
{
public
void
testPrepareForChecking
()
{
Installation
biMock
=
mock
(
Installation
.
class
);
Installation
biMock
=
mock
(
Installation
.
class
);
...
@@ -335,7 +364,7 @@ public class AbstractBuildingTest {
...
@@ -335,7 +364,7 @@ public class AbstractBuildingTest {
gmlAb
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
());
gmlAb
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
());
ab
.
setCityGmlBuilding
(
gmlAb
);
ab
.
setCityGmlBuilding
(
gmlAb
);
ab
.
accept
(
new
Unset
Geometries
Visitor
()
);
ab
.
clearGml
Geometries
(
);
verify
(
biMock
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
verify
(
biMock
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
verify
(
bsMock
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
verify
(
bsMock
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/AbstractRoomTest.java
0 → 100644
View file @
ae344b1a
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.check.AbstractCheck
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
org.citygml4j.core.model.core.AbstractSpaceBoundary
;
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
static
org
.
junit
.
Assert
.
assertNull
;
public
class
AbstractRoomTest
{
AbstractRoom
ab
;
@Before
public
void
setUp
()
{
ab
=
new
AbstractRoom
()
{
@Override
public
CityObject
getTopLevelCityObject
()
{
return
null
;
}
@Override
public
Copyable
createCopyInstance
()
{
return
null
;
}
};
}
@Test
public
void
testAbstractRoomVisitorPropagation
()
{
Installation
mockInstallation
=
Mockito
.
mock
(
Installation
.
class
);
BoundarySurface
mockBoundarySurface
=
Mockito
.
mock
(
BoundarySurface
.
class
);
ab
.
addRoomInstallation
(
mockInstallation
);
ab
.
addBoundarySurface
(
mockBoundarySurface
);
AbstractCheck
c
=
new
AbstractCheck
()
{
};
ab
.
accept
(
c
);
Mockito
.
verify
(
mockInstallation
).
accept
(
c
);
Mockito
.
verify
(
mockBoundarySurface
).
accept
(
c
);
}
@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
());
ab
.
cgmlRoom
=
gmlAUS
;
ab
.
clearGmlGeometries
();
assertNull
(
gmlAUS
.
getLod1Solid
());
assertNull
(
gmlAUS
.
getLod2Solid
());
assertNull
(
gmlAUS
.
getLod3Solid
());
assertNull
(
gmlAUS
.
getLod0MultiSurface
());
assertNull
(
gmlAUS
.
getLod2MultiSurface
());
assertNull
(
gmlAUS
.
getLod3MultiSurface
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/BoundarySurfaceTest.java
View file @
ae344b1a
...
@@ -23,11 +23,13 @@ import static org.junit.Assert.assertFalse;
...
@@ -23,11 +23,13 @@ import static org.junit.Assert.assertFalse;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
de.hft.stuttgart.citydoctor2.utils.UnsetGeometriesVisitor
;
import
org.citygml4j.core.model.construction.AbstractConstructionSurface
;
import
org.citygml4j.core.model.construction.AbstractConstructionSurface
;
import
org.citygml4j.core.model.construction.WallSurface
;
import
org.citygml4j.core.model.construction.WallSurface
;
import
org.citygml4j.core.model.core.AbstractThematicSurface
;
import
org.citygml4j.core.model.core.AbstractThematicSurface
;
...
@@ -342,8 +344,8 @@ public class BoundarySurfaceTest {
...
@@ -342,8 +344,8 @@ public class BoundarySurfaceTest {
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
ws
);
BoundarySurface
bs
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
ws
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
Opening
oMock
=
Mockito
.
mock
(
Opening
.
class
);
bs
.
addOpening
(
oMock
);
bs
.
addOpening
(
oMock
);
bs
.
u
nsetG
mlG
eometries
(
);
bs
.
accept
(
new
U
nsetGeometries
Visitor
()
);
Mockito
.
verify
(
oMock
).
u
nsetG
mlG
eometries
(
);
Mockito
.
verify
(
oMock
).
accept
(
any
(
U
nsetGeometries
Visitor
.
class
)
);
assertNull
(
ws
.
getLod2MultiSurface
());
assertNull
(
ws
.
getLod2MultiSurface
());
assertNull
(
ws
.
getLod3MultiSurface
());
assertNull
(
ws
.
getLod3MultiSurface
());
assertNull
(
ws
.
getDeprecatedProperties
().
getLod4MultiSurface
());
assertNull
(
ws
.
getDeprecatedProperties
().
getLod4MultiSurface
());
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/BridgeObjectTest.java
View file @
ae344b1a
...
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
...
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
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
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
@@ -29,6 +31,7 @@ import static org.mockito.Mockito.when;
...
@@ -29,6 +31,7 @@ import static org.mockito.Mockito.when;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
de.hft.stuttgart.citydoctor2.utils.UnsetGeometriesVisitor
;
import
org.citygml4j.core.model.bridge.AbstractBridge
;
import
org.citygml4j.core.model.bridge.AbstractBridge
;
import
org.citygml4j.core.model.bridge.Bridge
;
import
org.citygml4j.core.model.bridge.Bridge
;
import
org.citygml4j.core.model.deprecated.bridge.DeprecatedPropertiesOfAbstractBridge
;
import
org.citygml4j.core.model.deprecated.bridge.DeprecatedPropertiesOfAbstractBridge
;
...
@@ -277,8 +280,13 @@ public class BridgeObjectTest {
...
@@ -277,8 +280,13 @@ public class BridgeObjectTest {
BridgeObject
bo
=
new
BridgeObject
(
abMock
);
BridgeObject
bo
=
new
BridgeObject
(
abMock
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
BoundarySurface
bsMock
=
mock
(
BoundarySurface
.
class
);
bo
.
addBoundarySurface
(
bsMock
);
bo
.
addBoundarySurface
(
bsMock
);
doAnswer
(
invocation
->
{
bo
.
unsetGmlGeometries
();
bsMock
.
unsetGmlGeometries
();
return
null
;
}).
when
(
bsMock
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
bo
.
accept
(
new
UnsetGeometriesVisitor
());
verify
(
bsMock
).
accept
(
any
(
UnsetGeometriesVisitor
.
class
));
verify
(
bsMock
).
unsetGmlGeometries
();
verify
(
bsMock
).
unsetGmlGeometries
();
verify
(
propsMock
).
setLod1MultiSurface
(
null
);
verify
(
propsMock
).
setLod1MultiSurface
(
null
);
verify
(
abMock
).
setLod2MultiSurface
(
null
);
verify
(
abMock
).
setLod2MultiSurface
(
null
);
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/BuildingTest.java
View file @
ae344b1a
...
@@ -22,9 +22,14 @@ import static org.junit.Assert.assertEquals;
...
@@ -22,9 +22,14 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotSame
;
import
static
org
.
junit
.
Assert
.
assertNotSame
;
import
static
org
.
junit
.
Assert
.
assertSame
;
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.citygml4j.core.model.construction.RoofSurface
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.xmlobjects.gml.model.basictypes.Code
;
import
org.xmlobjects.gml.model.basictypes.Code
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType
;
...
@@ -120,4 +125,44 @@ public class BuildingTest {
...
@@ -120,4 +125,44 @@ public class BuildingTest {
return
b
;
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
);
}
}
}
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