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
92332c37
Commit
92332c37
authored
Dec 01, 2025
by
Luna Riegel
Browse files
Refactor: Decouple FeatureCache from other classes
parent
33225871
Pipeline
#12200
passed with stage
in 2 minutes and 17 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/CacheManager.java
deleted
100644 → 0
View file @
33225871
package
de.hft.stuttgart.citydoctor2.database
;
/**
* Utility class for accessing and managing the FeatureCache instance. Enables access to the cache in contexts without
* reference or pass through of the {@link de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel CityDoctorModel}.
*/
public
class
CacheManager
{
private
static
final
FeatureCache
cache
=
new
FeatureCache
();
private
CacheManager
()
{}
/**
* Returns the FeatureCache instance
*/
public
static
FeatureCache
getFeatureCache
()
{
return
cache
;
}
/**
* Returns a new UnconnectedCache Object.
* @return
*/
public
static
UnconnectedCache
getUnconnectedCache
(){
return
new
UnconnectedCache
();
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/FeatureCache.java
View file @
92332c37
...
@@ -21,7 +21,9 @@ import java.util.stream.Stream;
...
@@ -21,7 +21,9 @@ import java.util.stream.Stream;
* automatically load missing CityObjects from it. This cache is size limited and will evict entries using the
* automatically load missing CityObjects from it. This cache is size limited and will evict entries using the
* Window Tiny LFU policy.
* Window Tiny LFU policy.
* <p>
* <p>
* This cache may only have a single instance, use {@link CacheManager} for instantiation and access.
* While this class is not a singleton, it is advised to keep an Instance of this class for the whole lifecycle and
* reset and reuse it instead of creating new Objects, as the initialization is quite heavy and resets the embedded
* database.
* <p/>
* <p/>
* <p>
* <p>
* Avoid holding long-time strong references to CityObjects returned by the cache, as eviction will sever the
* Avoid holding long-time strong references to CityObjects returned by the cache, as eviction will sever the
...
@@ -39,7 +41,7 @@ public class FeatureCache implements CityObjectCache{
...
@@ -39,7 +41,7 @@ public class FeatureCache implements CityObjectCache{
private
CacheState
state
=
CacheState
.
IDLE
;
private
CacheState
state
=
CacheState
.
IDLE
;
private
final
ConcurrentHashMap
<
Thread
,
GmlId
>
evictionLocks
=
new
ConcurrentHashMap
<>();
private
final
ConcurrentHashMap
<
Thread
,
GmlId
>
evictionLocks
=
new
ConcurrentHashMap
<>();
FeatureCache
()
{
public
FeatureCache
()
{
handler
=
new
EmbeddedDatabaseHandler
();
handler
=
new
EmbeddedDatabaseHandler
();
cache
=
Caffeine
.
newBuilder
().
maximumSize
(
3000
).
removalListener
((
GmlId
key
,
CityObject
value
,
RemovalCause
cause
)
->
{
cache
=
Caffeine
.
newBuilder
().
maximumSize
(
3000
).
removalListener
((
GmlId
key
,
CityObject
value
,
RemovalCause
cause
)
->
{
if
(
value
!=
null
&&
cause
.
wasEvicted
()
&&
isFeatureMarshallable
(
value
)){
if
(
value
!=
null
&&
cause
.
wasEvicted
()
&&
isFeatureMarshallable
(
value
)){
...
@@ -132,6 +134,7 @@ public class FeatureCache implements CityObjectCache{
...
@@ -132,6 +134,7 @@ public class FeatureCache implements CityObjectCache{
logger
.
trace
(
"Resetting cache"
);
logger
.
trace
(
"Resetting cache"
);
cache
.
invalidateAll
();
cache
.
invalidateAll
();
putsCounter
.
set
(
0
);
putsCounter
.
set
(
0
);
handler
.
setupFeaturesTable
();
}
}
@Override
@Override
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModel.java
View file @
92332c37
...
@@ -21,7 +21,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
...
@@ -21,7 +21,6 @@ package de.hft.stuttgart.citydoctor2.datastructure;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.CheckableVisitor
;
import
de.hft.stuttgart.citydoctor2.check.CheckableVisitor
;
import
de.hft.stuttgart.citydoctor2.database.CacheManager
;
import
de.hft.stuttgart.citydoctor2.database.CityObjectCache
;
import
de.hft.stuttgart.citydoctor2.database.CityObjectCache
;
import
de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException
;
import
de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
...
@@ -67,10 +66,6 @@ public class CityDoctorModel {
...
@@ -67,10 +66,6 @@ public class CityDoctorModel {
private
CityGMLVersion
cityGMLVersion
;
private
CityGMLVersion
cityGMLVersion
;
private
final
CityObjectCache
cache
;
private
final
CityObjectCache
cache
;
public
CityDoctorModel
(
ParserConfiguration
config
,
File
file
)
{
this
(
config
,
file
,
CacheManager
.
getFeatureCache
());
}
public
CityDoctorModel
(
ParserConfiguration
config
,
File
file
,
CityObjectCache
cache
)
{
public
CityDoctorModel
(
ParserConfiguration
config
,
File
file
,
CityObjectCache
cache
)
{
if
(
config
==
null
)
{
if
(
config
==
null
)
{
throw
new
IllegalArgumentException
(
"Parser configuration may not be null"
);
throw
new
IllegalArgumentException
(
"Parser configuration may not be null"
);
...
@@ -92,7 +87,6 @@ public class CityDoctorModel {
...
@@ -92,7 +87,6 @@ public class CityDoctorModel {
genericObjects
=
new
ArrayList
<>();
genericObjects
=
new
ArrayList
<>();
globalErrors
=
new
ArrayList
<>();
globalErrors
=
new
ArrayList
<>();
this
.
cache
=
cache
;
this
.
cache
=
cache
;
cache
.
resetCache
();
}
}
public
boolean
isValidated
()
{
public
boolean
isValidated
()
{
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/citygml3/Citygml3FeatureMapper.java
View file @
92332c37
...
@@ -24,7 +24,7 @@ import java.util.HashMap;
...
@@ -24,7 +24,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
de.hft.stuttgart.citydoctor2.database.
CacheManager
;
import
de.hft.stuttgart.citydoctor2.database.
FeatureCache
;
import
de.hft.stuttgart.citydoctor2.database.UnconnectedCache
;
import
de.hft.stuttgart.citydoctor2.database.UnconnectedCache
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
...
@@ -164,6 +164,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
...
@@ -164,6 +164,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Citygml3FeatureMapper
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Citygml3FeatureMapper
.
class
);
private
static
FeatureCache
featureCache
=
new
FeatureCache
();
private
final
CityDoctorModel
model
;
private
final
CityDoctorModel
model
;
private
final
ParserConfiguration
config
;
private
final
ParserConfiguration
config
;
private
final
Path
directory
;
private
final
Path
directory
;
...
@@ -180,7 +181,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
...
@@ -180,7 +181,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
if
(
unconnected
){
if
(
unconnected
){
model
=
new
CityDoctorModel
(
config
,
path
.
toFile
(),
new
UnconnectedCache
());
model
=
new
CityDoctorModel
(
config
,
path
.
toFile
(),
new
UnconnectedCache
());
}
else
{
}
else
{
model
=
new
CityDoctorModel
(
config
,
path
.
toFile
());
featureCache
.
resetCache
();
model
=
new
CityDoctorModel
(
config
,
path
.
toFile
(),
featureCache
);
}
}
neighborDistance
=
1.8d
/
Math
.
pow
(
10
,
config
.
getNumberOfRoundingPlaces
());
neighborDistance
=
1.8d
/
Math
.
pow
(
10
,
config
.
getNumberOfRoundingPlaces
());
}
}
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/database/FeatureCacheTest.java
View file @
92332c37
...
@@ -6,14 +6,16 @@ import org.junit.Test;
...
@@ -6,14 +6,16 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
public
class
FeatureCacheTest
{
public
class
FeatureCacheTest
{
@Test
@Test
public
void
testPut
(){
public
void
testPut
(){
FeatureCache
cache
=
CacheManager
.
get
FeatureCache
();
FeatureCache
cache
=
new
FeatureCache
();
Building
b
=
new
Building
();
Building
b
=
new
Building
();
b
.
setGmlObject
(
mock
(
AbstractBuilding
.
class
));
b
.
setGmlObject
(
mock
(
AbstractBuilding
.
class
));
...
@@ -22,15 +24,16 @@ public class FeatureCacheTest {
...
@@ -22,15 +24,16 @@ public class FeatureCacheTest {
assertEquals
(
0
,
cache
.
getTotalFeatureCount
());
assertEquals
(
0
,
cache
.
getTotalFeatureCount
());
cache
.
put
(
b
);
cache
.
put
(
b
);
cache
.
synchronize
();
assertEquals
(
1
,
cache
.
getTotalFeatureCount
());
assertEquals
(
1
,
cache
.
getTotalFeatureCount
());
}
}
@Test
@Test
public
void
testGet
(){
public
void
testGet
(){
FeatureCache
cache
=
CacheManager
.
getFeatureCache
();
FeatureCache
cache
=
new
FeatureCache
();
assertNull
(
cache
.
get
(
new
GmlId
(
"building"
)));
assertNull
(
cache
.
get
(
new
GmlId
(
"test"
)));
Building
b
=
new
Building
();
Building
b
=
new
Building
();
b
.
setGmlObject
(
mock
(
AbstractBuilding
.
class
));
b
.
setGmlObject
(
mock
(
AbstractBuilding
.
class
));
...
@@ -38,10 +41,59 @@ public class FeatureCacheTest {
...
@@ -38,10 +41,59 @@ public class FeatureCacheTest {
b
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD0
));
b
.
addGeometry
(
GeometryTestUtils
.
createDummyGeometry
(
GeometryType
.
SOLID
,
Lod
.
LOD0
));
assertEquals
(
0
,
cache
.
getTotalFeatureCount
());
assertEquals
(
0
,
cache
.
getTotalFeatureCount
());
cache
.
put
(
b
);
cache
.
put
(
b
);
cache
.
synchronize
();
CityObject
b2
=
cache
.
get
(
new
GmlId
(
"
building
"
));
CityObject
b2
=
cache
.
get
(
new
GmlId
(
"
test
"
));
assertEquals
(
b
.
getGmlId
(),
b2
.
getGmlId
());
assertEquals
(
b
.
getGmlId
(),
b2
.
getGmlId
());
}
}
@Test
public
void
testStateHandlingFromIdle
(){
FeatureCache
cache
=
new
FeatureCache
();
assertEquals
(
FeatureCache
.
CacheState
.
IDLE
,
cache
.
getState
());
AutoCloseable
parsingContext
=
cache
.
startParsingMode
();
try
(
parsingContext
){
assertEquals
(
FeatureCache
.
CacheState
.
PARSING
,
cache
.
getState
());
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
e
);
}
assertEquals
(
FeatureCache
.
CacheState
.
IDLE
,
cache
.
getState
());
AutoCloseable
checkingContext
=
cache
.
startCheckingMode
();
try
(
checkingContext
){
assertEquals
(
FeatureCache
.
CacheState
.
CHECKING
,
cache
.
getState
());
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
e
);
}
assertEquals
(
FeatureCache
.
CacheState
.
IDLE
,
cache
.
getState
());
}
@Test
public
void
testCheckingModeStateCollision
(){
FeatureCache
cache
=
new
FeatureCache
();
assertEquals
(
FeatureCache
.
CacheState
.
IDLE
,
cache
.
getState
());
AutoCloseable
checkingContext
=
cache
.
startCheckingMode
();
try
(
checkingContext
){
assertEquals
(
FeatureCache
.
CacheState
.
CHECKING
,
cache
.
getState
());
assertThrows
(
IllegalStateException
.
class
,
cache:
:
startParsingMode
);
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
e
);
}
}
@Test
public
void
testParsingModeStateCollision
(){
FeatureCache
cache
=
new
FeatureCache
();
assertEquals
(
FeatureCache
.
CacheState
.
IDLE
,
cache
.
getState
());
AutoCloseable
parsingContext
=
cache
.
startParsingMode
();
try
(
parsingContext
){
assertEquals
(
FeatureCache
.
CacheState
.
PARSING
,
cache
.
getState
());
assertThrows
(
IllegalStateException
.
class
,
cache:
:
startCheckingMode
);
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
e
);
}
}
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/CityDoctorModelTest.java
View file @
92332c37
...
@@ -27,6 +27,8 @@ import java.util.ArrayList;
...
@@ -27,6 +27,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
import
de.hft.stuttgart.citydoctor2.database.FeatureCache
;
import
de.hft.stuttgart.citydoctor2.database.UnconnectedCache
;
import
org.citygml4j.core.ade.ADEException
;
import
org.citygml4j.core.ade.ADEException
;
import
org.citygml4j.core.model.CityGMLVersion
;
import
org.citygml4j.core.model.CityGMLVersion
;
import
org.citygml4j.core.model.core.AbstractFeatureProperty
;
import
org.citygml4j.core.model.core.AbstractFeatureProperty
;
...
@@ -66,12 +68,15 @@ public class CityDoctorModelTest {
...
@@ -66,12 +68,15 @@ public class CityDoctorModelTest {
private
File
mockFile
;
private
File
mockFile
;
private
ParserConfiguration
config
;
private
ParserConfiguration
config
;
private
CityDoctorModel
model
;
private
final
FeatureCache
featureCache
=
new
FeatureCache
();
@Before
@Before
public
void
setUp
(){
public
void
setUp
(){
mockFile
=
Mockito
.
mock
(
File
.
class
);
mockFile
=
Mockito
.
mock
(
File
.
class
);
Mockito
.
when
(
mockFile
.
getName
()).
thenReturn
(
"test"
);
Mockito
.
when
(
mockFile
.
getName
()).
thenReturn
(
"test"
);
config
=
new
ParserConfiguration
(
8
,
false
);
config
=
new
ParserConfiguration
(
8
,
false
);
featureCache
.
resetCache
();
model
=
new
CityDoctorModel
(
config
,
mockFile
,
featureCache
);
}
}
@Rule
@Rule
...
@@ -79,24 +84,22 @@ public class CityDoctorModelTest {
...
@@ -79,24 +84,22 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testCityDoctorModelNoConfig
()
{
public
void
testCityDoctorModelNoConfig
()
{
new
CityDoctorModel
(
null
,
mockFile
);
new
CityDoctorModel
(
null
,
mockFile
,
new
UnconnectedCache
()
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testCityDoctorModelNoFile
()
{
public
void
testCityDoctorModelNoFile
()
{
new
CityDoctorModel
(
config
,
null
);
new
CityDoctorModel
(
config
,
null
,
new
UnconnectedCache
()
);
}
}
@Test
@Test
public
void
testSetValidated
()
{
public
void
testSetValidated
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
model
.
setValidated
(
Mockito
.
mock
(
ValidationPlan
.
class
));
model
.
setValidated
(
Mockito
.
mock
(
ValidationPlan
.
class
));
assertTrue
(
model
.
isValidated
());
assertTrue
(
model
.
isValidated
());
}
}
@Test
@Test
public
void
testAddGlobalError
()
{
public
void
testAddGlobalError
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
CheckError
err
=
Mockito
.
mock
(
CheckError
.
class
);
CheckError
err
=
Mockito
.
mock
(
CheckError
.
class
);
model
.
addGlobalError
(
err
);
model
.
addGlobalError
(
err
);
assertEquals
(
err
,
model
.
getGlobalErrors
().
get
(
0
));
assertEquals
(
err
,
model
.
getGlobalErrors
().
get
(
0
));
...
@@ -104,7 +107,6 @@ public class CityDoctorModelTest {
...
@@ -104,7 +107,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddGlobalErrors
()
{
public
void
testAddGlobalErrors
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
CheckError
err1
=
Mockito
.
mock
(
CheckError
.
class
);
CheckError
err1
=
Mockito
.
mock
(
CheckError
.
class
);
CheckError
err2
=
Mockito
.
mock
(
CheckError
.
class
);
CheckError
err2
=
Mockito
.
mock
(
CheckError
.
class
);
List
<
CheckError
>
errors
=
new
ArrayList
<>();
List
<
CheckError
>
errors
=
new
ArrayList
<>();
...
@@ -117,13 +119,11 @@ public class CityDoctorModelTest {
...
@@ -117,13 +119,11 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testGetFile
()
{
public
void
testGetFile
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
assertEquals
(
mockFile
,
model
.
getFile
());
assertEquals
(
mockFile
,
model
.
getFile
());
}
}
@Test
@Test
public
void
testCreateFeatureStream
()
{
public
void
testCreateFeatureStream
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Building
b
=
Mockito
.
mock
(
Building
.
class
);
Building
b
=
Mockito
.
mock
(
Building
.
class
);
Mockito
.
when
(
b
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b"
));
Mockito
.
when
(
b
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b"
));
Vegetation
v
=
Mockito
.
mock
(
Vegetation
.
class
);
Vegetation
v
=
Mockito
.
mock
(
Vegetation
.
class
);
...
@@ -137,7 +137,6 @@ public class CityDoctorModelTest {
...
@@ -137,7 +137,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testSaveAsWithoutValidation
()
throws
CityGMLWriteException
,
ADEException
,
public
void
testSaveAsWithoutValidation
()
throws
CityGMLWriteException
,
ADEException
,
IOException
,
CityGmlParseException
,
InvalidGmlFileException
,
CityDoctorWriteException
{
IOException
,
CityGmlParseException
,
InvalidGmlFileException
,
CityDoctorWriteException
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
model
.
setParsedCityGMLVersion
(
CityGMLVersion
.
v2_0
);
model
.
setParsedCityGMLVersion
(
CityGMLVersion
.
v2_0
);
CityModel
cModel
=
new
CityModel
();
CityModel
cModel
=
new
CityModel
();
model
.
setCityModel
(
cModel
);
model
.
setCityModel
(
cModel
);
...
@@ -161,7 +160,7 @@ public class CityDoctorModelTest {
...
@@ -161,7 +160,7 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testSaveAsWithValidation
()
throws
CityGMLWriteException
,
ADEException
,
public
void
testSaveAsWithValidation
()
throws
CityGMLWriteException
,
ADEException
,
IOException
,
CityGmlParseException
,
InvalidGmlFileException
,
CityDoctorWriteException
{
IOException
,
CityGmlParseException
,
InvalidGmlFileException
,
CityDoctorWriteException
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
model
.
setParsedCityGMLVersion
(
CityGMLVersion
.
v2_0
);
model
.
setParsedCityGMLVersion
(
CityGMLVersion
.
v2_0
);
CityModel
cModel
=
new
CityModel
();
CityModel
cModel
=
new
CityModel
();
ValidationPlan
plan
=
new
ValidationPlan
();
ValidationPlan
plan
=
new
ValidationPlan
();
...
@@ -238,7 +237,6 @@ public class CityDoctorModelTest {
...
@@ -238,7 +237,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testCollectErrors
()
{
public
void
testCollectErrors
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Building
b
=
new
Building
();
Building
b
=
new
Building
();
model
.
addBuilding
(
b
);
model
.
addBuilding
(
b
);
CheckError
error
=
Mockito
.
mock
(
CheckError
.
class
);
CheckError
error
=
Mockito
.
mock
(
CheckError
.
class
);
...
@@ -249,14 +247,12 @@ public class CityDoctorModelTest {
...
@@ -249,14 +247,12 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testGetFileName
()
{
public
void
testGetFileName
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
assertEquals
(
"test"
,
model
.
getFileName
());
assertEquals
(
"test"
,
model
.
getFileName
());
assertEquals
(
mockFile
,
model
.
getFile
());
assertEquals
(
mockFile
,
model
.
getFile
());
}
}
@Test
@Test
public
void
testSetCityModel
()
{
public
void
testSetCityModel
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
CityModel
cModel
=
Mockito
.
mock
(
CityModel
.
class
);
CityModel
cModel
=
Mockito
.
mock
(
CityModel
.
class
);
model
.
setCityModel
(
cModel
);
model
.
setCityModel
(
cModel
);
assertEquals
(
cModel
,
model
.
getCityModel
());
assertEquals
(
cModel
,
model
.
getCityModel
());
...
@@ -264,7 +260,6 @@ public class CityDoctorModelTest {
...
@@ -264,7 +260,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddBuilding
()
{
public
void
testAddBuilding
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Building
b
=
Mockito
.
mock
(
Building
.
class
);
Building
b
=
Mockito
.
mock
(
Building
.
class
);
Mockito
.
when
(
b
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b"
));
Mockito
.
when
(
b
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b"
));
model
.
addBuilding
(
b
);
model
.
addBuilding
(
b
);
...
@@ -273,7 +268,6 @@ public class CityDoctorModelTest {
...
@@ -273,7 +268,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddBridge
()
{
public
void
testAddBridge
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
BridgeObject
b
=
Mockito
.
mock
(
BridgeObject
.
class
);
BridgeObject
b
=
Mockito
.
mock
(
BridgeObject
.
class
);
Mockito
.
when
(
b
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b"
));
Mockito
.
when
(
b
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b"
));
model
.
addBridge
(
b
);
model
.
addBridge
(
b
);
...
@@ -282,7 +276,6 @@ public class CityDoctorModelTest {
...
@@ -282,7 +276,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddVegetation
()
{
public
void
testAddVegetation
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Vegetation
veg
=
Mockito
.
mock
(
Vegetation
.
class
);
Vegetation
veg
=
Mockito
.
mock
(
Vegetation
.
class
);
Mockito
.
when
(
veg
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"v"
));
Mockito
.
when
(
veg
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"v"
));
model
.
addVegetation
(
veg
);
model
.
addVegetation
(
veg
);
...
@@ -291,7 +284,6 @@ public class CityDoctorModelTest {
...
@@ -291,7 +284,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddTunnel
()
{
public
void
testAddTunnel
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Tunnel
tunnel
=
Mockito
.
mock
(
Tunnel
.
class
);
Tunnel
tunnel
=
Mockito
.
mock
(
Tunnel
.
class
);
Mockito
.
when
(
tunnel
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t"
));
Mockito
.
when
(
tunnel
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t"
));
model
.
addTunnel
(
tunnel
);
model
.
addTunnel
(
tunnel
);
...
@@ -301,7 +293,6 @@ public class CityDoctorModelTest {
...
@@ -301,7 +293,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddTransportation
()
{
public
void
testAddTransportation
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
TransportationObject
trans
=
Mockito
.
mock
(
TransportationObject
.
class
);
TransportationObject
trans
=
Mockito
.
mock
(
TransportationObject
.
class
);
Mockito
.
when
(
trans
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t"
));
Mockito
.
when
(
trans
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t"
));
model
.
addTransportation
(
trans
);
model
.
addTransportation
(
trans
);
...
@@ -311,7 +302,6 @@ public class CityDoctorModelTest {
...
@@ -311,7 +302,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddLand
()
{
public
void
testAddLand
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
LandObject
land
=
Mockito
.
mock
(
LandObject
.
class
);
LandObject
land
=
Mockito
.
mock
(
LandObject
.
class
);
Mockito
.
when
(
land
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"l"
));
Mockito
.
when
(
land
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"l"
));
model
.
addLand
(
land
);
model
.
addLand
(
land
);
...
@@ -320,7 +310,6 @@ public class CityDoctorModelTest {
...
@@ -320,7 +310,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddWater
()
{
public
void
testAddWater
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
WaterObject
water
=
Mockito
.
mock
(
WaterObject
.
class
);
WaterObject
water
=
Mockito
.
mock
(
WaterObject
.
class
);
Mockito
.
when
(
water
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"w"
));
Mockito
.
when
(
water
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"w"
));
model
.
addWater
(
water
);
model
.
addWater
(
water
);
...
@@ -329,7 +318,6 @@ public class CityDoctorModelTest {
...
@@ -329,7 +318,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddCityFurniture
()
{
public
void
testAddCityFurniture
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
CityFurniture
cf
=
Mockito
.
mock
(
CityFurniture
.
class
);
CityFurniture
cf
=
Mockito
.
mock
(
CityFurniture
.
class
);
Mockito
.
when
(
cf
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"cf"
));
Mockito
.
when
(
cf
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"cf"
));
model
.
addCityFurniture
(
cf
);
model
.
addCityFurniture
(
cf
);
...
@@ -338,7 +326,6 @@ public class CityDoctorModelTest {
...
@@ -338,7 +326,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testAddGenericCityObject
()
{
public
void
testAddGenericCityObject
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
GenericCityObject
gen
=
Mockito
.
mock
(
GenericCityObject
.
class
);
GenericCityObject
gen
=
Mockito
.
mock
(
GenericCityObject
.
class
);
Mockito
.
when
(
gen
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"g"
));
Mockito
.
when
(
gen
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"g"
));
model
.
addGenericCityObject
(
gen
);
model
.
addGenericCityObject
(
gen
);
...
@@ -347,7 +334,6 @@ public class CityDoctorModelTest {
...
@@ -347,7 +334,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testGetNumberOfFeatures
()
{
public
void
testGetNumberOfFeatures
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Building
b
=
Mockito
.
mock
(
Building
.
class
);
Building
b
=
Mockito
.
mock
(
Building
.
class
);
Mockito
.
when
(
b
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b"
));
Mockito
.
when
(
b
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b"
));
...
@@ -384,13 +370,11 @@ public class CityDoctorModelTest {
...
@@ -384,13 +370,11 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testGetParserConfig
()
{
public
void
testGetParserConfig
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
assertEquals
(
config
,
model
.
getParserConfig
());
assertEquals
(
config
,
model
.
getParserConfig
());
}
}
@Test
@Test
public
void
testReplaceBuilding
()
{
public
void
testReplaceBuilding
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Building
b1
=
Mockito
.
mock
(
Building
.
class
);
Building
b1
=
Mockito
.
mock
(
Building
.
class
);
Mockito
.
when
(
b1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b1"
));
Mockito
.
when
(
b1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b1"
));
Building
b2
=
Mockito
.
mock
(
Building
.
class
);
Building
b2
=
Mockito
.
mock
(
Building
.
class
);
...
@@ -405,7 +389,6 @@ public class CityDoctorModelTest {
...
@@ -405,7 +389,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceBuildingMissing
()
{
public
void
testReplaceBuildingMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Building
b1
=
Mockito
.
mock
(
Building
.
class
);
Building
b1
=
Mockito
.
mock
(
Building
.
class
);
Building
b2
=
Mockito
.
mock
(
Building
.
class
);
Building
b2
=
Mockito
.
mock
(
Building
.
class
);
model
.
replaceFeature
(
b1
,
b2
);
model
.
replaceFeature
(
b1
,
b2
);
...
@@ -413,7 +396,6 @@ public class CityDoctorModelTest {
...
@@ -413,7 +396,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testReplaceBridge
()
{
public
void
testReplaceBridge
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
BridgeObject
b1
=
Mockito
.
mock
(
BridgeObject
.
class
);
BridgeObject
b1
=
Mockito
.
mock
(
BridgeObject
.
class
);
Mockito
.
when
(
b1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b1"
));
Mockito
.
when
(
b1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"b1"
));
BridgeObject
b2
=
Mockito
.
mock
(
BridgeObject
.
class
);
BridgeObject
b2
=
Mockito
.
mock
(
BridgeObject
.
class
);
...
@@ -427,7 +409,6 @@ public class CityDoctorModelTest {
...
@@ -427,7 +409,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceBridgeMissing
()
{
public
void
testReplaceBridgeMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
BridgeObject
b1
=
Mockito
.
mock
(
BridgeObject
.
class
);
BridgeObject
b1
=
Mockito
.
mock
(
BridgeObject
.
class
);
BridgeObject
b2
=
Mockito
.
mock
(
BridgeObject
.
class
);
BridgeObject
b2
=
Mockito
.
mock
(
BridgeObject
.
class
);
model
.
replaceFeature
(
b1
,
b2
);
model
.
replaceFeature
(
b1
,
b2
);
...
@@ -435,7 +416,6 @@ public class CityDoctorModelTest {
...
@@ -435,7 +416,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testReplaceVegetation
()
{
public
void
testReplaceVegetation
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Vegetation
v1
=
Mockito
.
mock
(
Vegetation
.
class
);
Vegetation
v1
=
Mockito
.
mock
(
Vegetation
.
class
);
Mockito
.
when
(
v1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"v1"
));
Mockito
.
when
(
v1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"v1"
));
Vegetation
v2
=
Mockito
.
mock
(
Vegetation
.
class
);
Vegetation
v2
=
Mockito
.
mock
(
Vegetation
.
class
);
...
@@ -450,7 +430,6 @@ public class CityDoctorModelTest {
...
@@ -450,7 +430,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceVegetationMissing
()
{
public
void
testReplaceVegetationMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Vegetation
v1
=
Mockito
.
mock
(
Vegetation
.
class
);
Vegetation
v1
=
Mockito
.
mock
(
Vegetation
.
class
);
Vegetation
v2
=
Mockito
.
mock
(
Vegetation
.
class
);
Vegetation
v2
=
Mockito
.
mock
(
Vegetation
.
class
);
model
.
replaceFeature
(
v1
,
v2
);
model
.
replaceFeature
(
v1
,
v2
);
...
@@ -458,7 +437,6 @@ public class CityDoctorModelTest {
...
@@ -458,7 +437,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testReplaceTunnel
()
{
public
void
testReplaceTunnel
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Tunnel
t1
=
Mockito
.
mock
(
Tunnel
.
class
);
Tunnel
t1
=
Mockito
.
mock
(
Tunnel
.
class
);
Mockito
.
when
(
t1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t1"
));
Mockito
.
when
(
t1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t1"
));
Tunnel
t2
=
Mockito
.
mock
(
Tunnel
.
class
);
Tunnel
t2
=
Mockito
.
mock
(
Tunnel
.
class
);
...
@@ -473,7 +451,6 @@ public class CityDoctorModelTest {
...
@@ -473,7 +451,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceTunnelMissing
()
{
public
void
testReplaceTunnelMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
Tunnel
t1
=
Mockito
.
mock
(
Tunnel
.
class
);
Tunnel
t1
=
Mockito
.
mock
(
Tunnel
.
class
);
Tunnel
t2
=
Mockito
.
mock
(
Tunnel
.
class
);
Tunnel
t2
=
Mockito
.
mock
(
Tunnel
.
class
);
model
.
replaceFeature
(
t1
,
t2
);
model
.
replaceFeature
(
t1
,
t2
);
...
@@ -481,7 +458,6 @@ public class CityDoctorModelTest {
...
@@ -481,7 +458,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testReplaceTransportation
()
{
public
void
testReplaceTransportation
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
TransportationObject
t1
=
Mockito
.
mock
(
TransportationObject
.
class
);
TransportationObject
t1
=
Mockito
.
mock
(
TransportationObject
.
class
);
Mockito
.
when
(
t1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t1"
));
Mockito
.
when
(
t1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t1"
));
TransportationObject
t2
=
Mockito
.
mock
(
TransportationObject
.
class
);
TransportationObject
t2
=
Mockito
.
mock
(
TransportationObject
.
class
);
...
@@ -496,7 +472,6 @@ public class CityDoctorModelTest {
...
@@ -496,7 +472,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceTransportationMissing
()
{
public
void
testReplaceTransportationMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
TransportationObject
t1
=
Mockito
.
mock
(
TransportationObject
.
class
);
TransportationObject
t1
=
Mockito
.
mock
(
TransportationObject
.
class
);
TransportationObject
t2
=
Mockito
.
mock
(
TransportationObject
.
class
);
TransportationObject
t2
=
Mockito
.
mock
(
TransportationObject
.
class
);
model
.
replaceFeature
(
t1
,
t2
);
model
.
replaceFeature
(
t1
,
t2
);
...
@@ -504,7 +479,6 @@ public class CityDoctorModelTest {
...
@@ -504,7 +479,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testReplaceLand
()
{
public
void
testReplaceLand
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
LandObject
lo1
=
Mockito
.
mock
(
LandObject
.
class
);
LandObject
lo1
=
Mockito
.
mock
(
LandObject
.
class
);
Mockito
.
when
(
lo1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"lo1"
));
Mockito
.
when
(
lo1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"lo1"
));
LandObject
lo2
=
Mockito
.
mock
(
LandObject
.
class
);
LandObject
lo2
=
Mockito
.
mock
(
LandObject
.
class
);
...
@@ -519,7 +493,6 @@ public class CityDoctorModelTest {
...
@@ -519,7 +493,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceLandMissing
()
{
public
void
testReplaceLandMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
LandObject
lo1
=
Mockito
.
mock
(
LandObject
.
class
);
LandObject
lo1
=
Mockito
.
mock
(
LandObject
.
class
);
LandObject
lo2
=
Mockito
.
mock
(
LandObject
.
class
);
LandObject
lo2
=
Mockito
.
mock
(
LandObject
.
class
);
model
.
replaceFeature
(
lo1
,
lo2
);
model
.
replaceFeature
(
lo1
,
lo2
);
...
@@ -527,7 +500,6 @@ public class CityDoctorModelTest {
...
@@ -527,7 +500,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testReplaceWater
()
{
public
void
testReplaceWater
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
WaterObject
t1
=
Mockito
.
mock
(
WaterObject
.
class
);
WaterObject
t1
=
Mockito
.
mock
(
WaterObject
.
class
);
Mockito
.
when
(
t1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t1"
));
Mockito
.
when
(
t1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"t1"
));
WaterObject
t2
=
Mockito
.
mock
(
WaterObject
.
class
);
WaterObject
t2
=
Mockito
.
mock
(
WaterObject
.
class
);
...
@@ -542,7 +514,6 @@ public class CityDoctorModelTest {
...
@@ -542,7 +514,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceWaterMissing
()
{
public
void
testReplaceWaterMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
WaterObject
t1
=
Mockito
.
mock
(
WaterObject
.
class
);
WaterObject
t1
=
Mockito
.
mock
(
WaterObject
.
class
);
WaterObject
t2
=
Mockito
.
mock
(
WaterObject
.
class
);
WaterObject
t2
=
Mockito
.
mock
(
WaterObject
.
class
);
model
.
replaceFeature
(
t1
,
t2
);
model
.
replaceFeature
(
t1
,
t2
);
...
@@ -550,7 +521,6 @@ public class CityDoctorModelTest {
...
@@ -550,7 +521,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testReplaceCityFurniture
()
{
public
void
testReplaceCityFurniture
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
CityFurniture
cf1
=
Mockito
.
mock
(
CityFurniture
.
class
);
CityFurniture
cf1
=
Mockito
.
mock
(
CityFurniture
.
class
);
Mockito
.
when
(
cf1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"cf1"
));
Mockito
.
when
(
cf1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"cf1"
));
CityFurniture
cf2
=
Mockito
.
mock
(
CityFurniture
.
class
);
CityFurniture
cf2
=
Mockito
.
mock
(
CityFurniture
.
class
);
...
@@ -565,7 +535,6 @@ public class CityDoctorModelTest {
...
@@ -565,7 +535,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceCityFurnitureMissing
()
{
public
void
testReplaceCityFurnitureMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
CityFurniture
cf1
=
Mockito
.
mock
(
CityFurniture
.
class
);
CityFurniture
cf1
=
Mockito
.
mock
(
CityFurniture
.
class
);
CityFurniture
cf2
=
Mockito
.
mock
(
CityFurniture
.
class
);
CityFurniture
cf2
=
Mockito
.
mock
(
CityFurniture
.
class
);
model
.
replaceFeature
(
cf1
,
cf2
);
model
.
replaceFeature
(
cf1
,
cf2
);
...
@@ -573,7 +542,6 @@ public class CityDoctorModelTest {
...
@@ -573,7 +542,6 @@ public class CityDoctorModelTest {
@Test
@Test
public
void
testReplaceGenericCityObject
()
{
public
void
testReplaceGenericCityObject
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
GenericCityObject
gco1
=
Mockito
.
mock
(
GenericCityObject
.
class
);
GenericCityObject
gco1
=
Mockito
.
mock
(
GenericCityObject
.
class
);
Mockito
.
when
(
gco1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"gco1"
));
Mockito
.
when
(
gco1
.
getGmlId
()).
thenReturn
(
new
GmlId
(
"gco1"
));
GenericCityObject
gco2
=
Mockito
.
mock
(
GenericCityObject
.
class
);
GenericCityObject
gco2
=
Mockito
.
mock
(
GenericCityObject
.
class
);
...
@@ -588,7 +556,6 @@ public class CityDoctorModelTest {
...
@@ -588,7 +556,6 @@ public class CityDoctorModelTest {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testReplaceGenericCityObjectMissing
()
{
public
void
testReplaceGenericCityObjectMissing
()
{
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
mockFile
);
GenericCityObject
gco1
=
Mockito
.
mock
(
GenericCityObject
.
class
);
GenericCityObject
gco1
=
Mockito
.
mock
(
GenericCityObject
.
class
);
GenericCityObject
gco2
=
Mockito
.
mock
(
GenericCityObject
.
class
);
GenericCityObject
gco2
=
Mockito
.
mock
(
GenericCityObject
.
class
);
model
.
replaceFeature
(
gco1
,
gco2
);
model
.
replaceFeature
(
gco1
,
gco2
);
...
...
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java
View file @
92332c37
...
@@ -28,9 +28,7 @@ import de.hft.stuttgart.citydoctor2.checks.CheckPrototype;
...
@@ -28,9 +28,7 @@ import de.hft.stuttgart.citydoctor2.checks.CheckPrototype;
import
de.hft.stuttgart.citydoctor2.checks.Checks
;
import
de.hft.stuttgart.citydoctor2.checks.Checks
;
import
de.hft.stuttgart.citydoctor2.checks.SvrlContentHandler
;
import
de.hft.stuttgart.citydoctor2.checks.SvrlContentHandler
;
import
de.hft.stuttgart.citydoctor2.checks.util.FeatureCheckedListener
;
import
de.hft.stuttgart.citydoctor2.checks.util.FeatureCheckedListener
;
import
de.hft.stuttgart.citydoctor2.database.CacheManager
;
import
de.hft.stuttgart.citydoctor2.database.CityObjectCache
;
import
de.hft.stuttgart.citydoctor2.database.CityObjectCache
;
import
de.hft.stuttgart.citydoctor2.database.FeatureCache
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.FeatureType
;
import
de.hft.stuttgart.citydoctor2.datastructure.FeatureType
;
...
@@ -233,7 +231,7 @@ public class Checker {
...
@@ -233,7 +231,7 @@ public class Checker {
private
void
handleSchematronResults
(
SvrlContentHandler
handler
)
{
private
void
handleSchematronResults
(
SvrlContentHandler
handler
)
{
model
.
addGlobalErrors
(
handler
.
getGeneralErrors
());
model
.
addGlobalErrors
(
handler
.
getGeneralErrors
());
Feature
Cache
cache
=
CacheManager
.
getFeature
Cache
();
CityObject
Cache
cache
=
model
.
get
Cache
();
handler
.
getFeatureErrors
().
forEach
((
k
,
v
)
->
{
handler
.
getFeatureErrors
().
forEach
((
k
,
v
)
->
{
if
(
k
.
trim
().
isEmpty
())
{
if
(
k
.
trim
().
isEmpty
())
{
// missing gml id, ignore?
// missing gml id, ignore?
...
...
CityDoctorParent/CityDoctorValidation/src/test/java/de/hft/stuttgart/citydoctor2/checks/geometry/DegeneratedPolygonCheckTest.java
View file @
92332c37
...
@@ -26,6 +26,7 @@ import java.util.HashMap;
...
@@ -26,6 +26,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
de.hft.stuttgart.citydoctor2.database.UnconnectedCache
;
import
org.junit.Test
;
import
org.junit.Test
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
...
@@ -72,7 +73,7 @@ public class DegeneratedPolygonCheckTest {
...
@@ -72,7 +73,7 @@ public class DegeneratedPolygonCheckTest {
File
file
=
Mockito
.
mock
(
File
.
class
);
File
file
=
Mockito
.
mock
(
File
.
class
);
Mockito
.
when
(
file
.
getName
()).
thenReturn
(
"building"
);
Mockito
.
when
(
file
.
getName
()).
thenReturn
(
"building"
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
file
);
CityDoctorModel
model
=
new
CityDoctorModel
(
config
,
file
,
new
UnconnectedCache
()
);
model
.
addBuilding
(
b
);
model
.
addBuilding
(
b
);
ValidationConfiguration
valConfig
=
ValidationConfiguration
.
loadStandardValidationConfig
();
ValidationConfiguration
valConfig
=
ValidationConfiguration
.
loadStandardValidationConfig
();
...
...
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java
View file @
92332c37
package
de.hft.stuttgart.citydoctor2.gui
;
package
de.hft.stuttgart.citydoctor2.gui
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.Checkable
;
import
de.hft.stuttgart.citydoctor2.check.Checker
;
import
de.hft.stuttgart.citydoctor2.check.Checker
;
import
de.hft.stuttgart.citydoctor2.check.ErrorId
;
import
de.hft.stuttgart.citydoctor2.check.ErrorId
;
import
de.hft.stuttgart.citydoctor2.check.ValidationConfiguration
;
import
de.hft.stuttgart.citydoctor2.check.ValidationConfiguration
;
import
de.hft.stuttgart.citydoctor2.check.error.SchematronError
;
import
de.hft.stuttgart.citydoctor2.check.error.SchematronError
;
import
de.hft.stuttgart.citydoctor2.database.
CacheManager
;
import
de.hft.stuttgart.citydoctor2.database.
UnconnectedCache
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException
;
import
de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException
;
import
de.hft.stuttgart.citydoctor2.gui.table.ErrorStat
;
import
de.hft.stuttgart.citydoctor2.gui.table.ErrorStat
;
...
@@ -1174,7 +1173,7 @@ public class CityDoctorController {
...
@@ -1174,7 +1173,7 @@ public class CityDoctorController {
if
(
model
==
null
)
{
if
(
model
==
null
)
{
return
;
return
;
}
}
CityDoctorModel
newModel
=
new
CityDoctorModel
(
model
.
getParserConfig
(),
model
.
getFile
());
CityDoctorModel
newModel
=
new
CityDoctorModel
(
model
.
getParserConfig
(),
model
.
getFile
()
,
new
UnconnectedCache
()
);
newModel
.
setCityModel
(
new
CityModel
());
newModel
.
setCityModel
(
new
CityModel
());
newModel
.
addCityObject
(
co
);
newModel
.
addCityObject
(
co
);
newModel
.
setParsedCityGMLVersion
(
model
.
getCityGMLVersion
());
newModel
.
setParsedCityGMLVersion
(
model
.
getCityGMLVersion
());
...
...
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