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
3539192a
Commit
3539192a
authored
Apr 30, 2025
by
Riegel
Browse files
Test: Add coverage of all Featuretypes
parent
72b53470
Changes
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModelTest.java
View file @
3539192a
...
@@ -255,13 +255,13 @@ public class CityDoctorModelTest {
...
@@ -255,13 +255,13 @@ public class CityDoctorModelTest {
}
}
@Test
@Test
public
void
test
AddBridge
()
{
public
void
test
SetCityModel
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
BridgeObject
b
=
Mockito
.
mock
(
BridgeObject
.
class
);
CityModel
cModel
=
Mockito
.
mock
(
CityModel
.
class
);
model
.
addBridge
(
b
);
model
.
setCityModel
(
cModel
);
assertEquals
(
b
,
model
.
get
Bridges
().
get
(
0
));
assertEquals
(
cModel
,
model
.
get
CityModel
(
));
}
}
@Test
@Test
...
@@ -275,25 +275,47 @@ public class CityDoctorModelTest {
...
@@ -275,25 +275,47 @@ public class CityDoctorModelTest {
}
}
@Test
@Test
public
void
test
SetCityModel
()
{
public
void
test
AddBridge
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityModel
cModel
=
Mockito
.
mock
(
CityModel
.
class
);
BridgeObject
b
=
Mockito
.
mock
(
BridgeObject
.
class
);
model
.
setCityModel
(
cModel
);
model
.
addBridge
(
b
);
assertEquals
(
cModel
,
model
.
get
CityModel
(
));
assertEquals
(
b
,
model
.
get
Bridges
().
get
(
0
));
}
}
@Test
@Test
public
void
testAdd
Water
()
{
public
void
testAdd
Vegetation
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
WaterObject
water
=
Mockito
.
mock
(
WaterObject
.
class
);
Vegetation
veg
=
Mockito
.
mock
(
Vegetation
.
class
);
model
.
add
Water
(
water
);
model
.
add
Vegetation
(
veg
);
assertEquals
(
water
,
model
.
get
Water
().
get
(
0
));
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
@Test
public
void
testAddLand
()
{
public
void
testAddLand
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
File
f
=
Mockito
.
mock
(
File
.
class
);
...
@@ -305,23 +327,33 @@ public class CityDoctorModelTest {
...
@@ -305,23 +327,33 @@ public class CityDoctorModelTest {
}
}
@Test
@Test
public
void
testAdd
Vegetation
()
{
public
void
testAdd
Water
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
Vegetation
veg
=
Mockito
.
mock
(
Vegetation
.
class
);
WaterObject
water
=
Mockito
.
mock
(
WaterObject
.
class
);
model
.
add
Vegetation
(
veg
);
model
.
add
Water
(
water
);
assertEquals
(
veg
,
model
.
get
Vegetation
().
get
(
0
));
assertEquals
(
water
,
model
.
get
Water
().
get
(
0
));
}
}
@Test
@Test
public
void
testAdd
Transportation
()
{
public
void
testAdd
CityFurniture
()
{
File
f
=
Mockito
.
mock
(
File
.
class
);
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
TransportationObject
trans
=
Mockito
.
mock
(
TransportationObject
.
class
);
CityFurniture
cf
=
Mockito
.
mock
(
CityFurniture
.
class
);
model
.
addTransportation
(
trans
);
model
.
addCityFurniture
(
cf
);
assertEquals
(
trans
,
model
.
getTransportation
().
get
(
0
));
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
@Test
...
@@ -329,11 +361,29 @@ public class CityDoctorModelTest {
...
@@ -329,11 +361,29 @@ public class CityDoctorModelTest {
File
f
=
Mockito
.
mock
(
File
.
class
);
File
f
=
Mockito
.
mock
(
File
.
class
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
f
);
Building
b
=
Mockito
.
mock
(
Building
.
class
);
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
);
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
.
addBuilding
(
b
);
model
.
addBridge
(
bo
);
model
.
addVegetation
(
veg
);
model
.
addTransportation
(
trans
);
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
@Test
...
@@ -355,6 +405,7 @@ public class CityDoctorModelTest {
...
@@ -355,6 +405,7 @@ public class CityDoctorModelTest {
assertEquals
(
b1
,
model
.
getBuildings
().
get
(
0
));
assertEquals
(
b1
,
model
.
getBuildings
().
get
(
0
));
model
.
replaceFeature
(
b1
,
b2
);
model
.
replaceFeature
(
b1
,
b2
);
assertEquals
(
b2
,
model
.
getBuildings
().
get
(
0
));
assertEquals
(
b2
,
model
.
getBuildings
().
get
(
0
));
assertEquals
(
1
,
model
.
getBuildings
().
size
());
}
}
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
...
@@ -366,6 +417,30 @@ public class CityDoctorModelTest {
...
@@ -366,6 +417,30 @@ public class CityDoctorModelTest {
Building
b2
=
Mockito
.
mock
(
Building
.
class
);
Building
b2
=
Mockito
.
mock
(
Building
.
class
);
model
.
replaceFeature
(
b1
,
b2
);
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
@Test
public
void
testReplaceVegetation
()
{
public
void
testReplaceVegetation
()
{
...
@@ -378,6 +453,7 @@ public class CityDoctorModelTest {
...
@@ -378,6 +453,7 @@ public class CityDoctorModelTest {
assertEquals
(
v1
,
model
.
getVegetation
().
get
(
0
));
assertEquals
(
v1
,
model
.
getVegetation
().
get
(
0
));
model
.
replaceFeature
(
v1
,
v2
);
model
.
replaceFeature
(
v1
,
v2
);
assertEquals
(
v2
,
model
.
getVegetation
().
get
(
0
));
assertEquals
(
v2
,
model
.
getVegetation
().
get
(
0
));
assertEquals
(
1
,
model
.
getVegetation
().
size
());
}
}
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
...
@@ -389,6 +465,30 @@ public class CityDoctorModelTest {
...
@@ -389,6 +465,30 @@ public class CityDoctorModelTest {
Vegetation
v2
=
Mockito
.
mock
(
Vegetation
.
class
);
Vegetation
v2
=
Mockito
.
mock
(
Vegetation
.
class
);
model
.
replaceFeature
(
v1
,
v2
);
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
@Test
public
void
testReplaceTransportation
()
{
public
void
testReplaceTransportation
()
{
...
@@ -401,6 +501,7 @@ public class CityDoctorModelTest {
...
@@ -401,6 +501,7 @@ public class CityDoctorModelTest {
assertEquals
(
t1
,
model
.
getTransportation
().
get
(
0
));
assertEquals
(
t1
,
model
.
getTransportation
().
get
(
0
));
model
.
replaceFeature
(
t1
,
t2
);
model
.
replaceFeature
(
t1
,
t2
);
assertEquals
(
t2
,
model
.
getTransportation
().
get
(
0
));
assertEquals
(
t2
,
model
.
getTransportation
().
get
(
0
));
assertEquals
(
1
,
model
.
getTransportation
().
size
());
}
}
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
...
@@ -412,6 +513,30 @@ public class CityDoctorModelTest {
...
@@ -412,6 +513,30 @@ public class CityDoctorModelTest {
TransportationObject
t2
=
Mockito
.
mock
(
TransportationObject
.
class
);
TransportationObject
t2
=
Mockito
.
mock
(
TransportationObject
.
class
);
model
.
replaceFeature
(
t1
,
t2
);
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
@Test
public
void
testReplaceWater
()
{
public
void
testReplaceWater
()
{
...
@@ -424,6 +549,7 @@ public class CityDoctorModelTest {
...
@@ -424,6 +549,7 @@ public class CityDoctorModelTest {
assertEquals
(
t1
,
model
.
getWater
().
get
(
0
));
assertEquals
(
t1
,
model
.
getWater
().
get
(
0
));
model
.
replaceFeature
(
t1
,
t2
);
model
.
replaceFeature
(
t1
,
t2
);
assertEquals
(
t2
,
model
.
getWater
().
get
(
0
));
assertEquals
(
t2
,
model
.
getWater
().
get
(
0
));
assertEquals
(
1
,
model
.
getWater
().
size
());
}
}
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
...
@@ -436,4 +562,52 @@ public class CityDoctorModelTest {
...
@@ -436,4 +562,52 @@ public class CityDoctorModelTest {
model
.
replaceFeature
(
t1
,
t2
);
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
);
}
}
}
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