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
ad9ffe7b
Commit
ad9ffe7b
authored
Mar 15, 2021
by
Matthias Betz
Browse files
added Check tests
parent
aaee62de
Pipeline
#2294
passed with stage
in 3 minutes and 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/check/CheckTest.java
0 → 100644
View file @
ad9ffe7b
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package
de.hft.stuttgart.citydoctor2.check
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
import
org.junit.Test
;
import
de.hft.stuttgart.citydoctor2.check.error.AttributeMissingError
;
import
de.hft.stuttgart.citydoctor2.datastructure.AbstractBuilding
;
import
de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface
;
import
de.hft.stuttgart.citydoctor2.datastructure.Building
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vegetation
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vegetation.VegetationType
;
public
class
CheckTest
{
@Test
public
void
testCheckOneMethod
()
{
Check
c
=
new
Check
()
{
@Override
public
Set
<
Requirement
>
appliesToRequirements
()
{
return
null
;
}
@Override
public
CheckId
getCheckId
()
{
return
null
;
}
@Override
public
RequirementType
getType
()
{
return
null
;
}
@Override
public
Check
createNewInstance
()
{
return
null
;
}
public
void
check
(
AbstractBuilding
ab
)
{
};
};
List
<
Class
<
Checkable
>>
applicableToClasses
=
c
.
getApplicableToClasses
();
assertEquals
(
1
,
applicableToClasses
.
size
());
Class
<
Checkable
>
class1
=
applicableToClasses
.
get
(
0
);
assertEquals
(
class1
,
AbstractBuilding
.
class
);
}
@Test
public
void
testCheckTwoMethod
()
{
Check
c
=
new
Check
()
{
@Override
public
Set
<
Requirement
>
appliesToRequirements
()
{
return
null
;
}
@Override
public
CheckId
getCheckId
()
{
return
null
;
}
@Override
public
RequirementType
getType
()
{
return
null
;
}
@Override
public
Check
createNewInstance
()
{
return
null
;
}
public
void
check
(
AbstractBuilding
ab
)
{
};
@Override
public
void
check
(
BoundarySurface
bs
)
{
check
(
bs
,
1
);
check
(
2
);
}
public
void
check
(
BoundarySurface
bs
,
Integer
test
)
{
}
public
void
check
(
Integer
i
)
{
}
};
List
<
Class
<
Checkable
>>
applicableToClasses
=
c
.
getApplicableToClasses
();
assertEquals
(
2
,
applicableToClasses
.
size
());
assertTrue
(
applicableToClasses
.
contains
(
AbstractBuilding
.
class
));
assertTrue
(
applicableToClasses
.
contains
(
BoundarySurface
.
class
));
assertFalse
(
applicableToClasses
.
contains
(
Integer
.
class
));
}
@Test
public
void
testGetDependencies
()
{
Check
c
=
new
Check
()
{
@Override
public
Set
<
Requirement
>
appliesToRequirements
()
{
return
null
;
}
@Override
public
CheckId
getCheckId
()
{
return
null
;
}
@Override
public
RequirementType
getType
()
{
return
null
;
}
@Override
public
Check
createNewInstance
()
{
return
null
;
}
};
assertTrue
(
c
.
getDependencies
().
isEmpty
());
}
@Test
public
void
testCanExecute
()
{
Check
c2
=
new
Check
()
{
@Override
public
Set
<
Requirement
>
appliesToRequirements
()
{
return
null
;
}
@Override
public
CheckId
getCheckId
()
{
return
CheckId
.
C_GE_P_INNER_RINGS_NESTED
;
}
@Override
public
RequirementType
getType
()
{
return
null
;
}
@Override
public
Check
createNewInstance
()
{
return
null
;
}
@Override
public
List
<
CheckId
>
getDependencies
()
{
return
Collections
.
singletonList
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
);
}
public
void
check
(
AbstractBuilding
b
)
{
};
};
Building
b
=
new
Building
();
assertTrue
(
c2
.
canExecute
(
b
));
b
.
addCheckResult
(
new
CheckResult
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
,
ResultStatus
.
ERROR
,
new
AttributeMissingError
(
b
,
null
,
null
,
false
)));
assertEquals
(
1
,
b
.
getAllCheckResults
().
size
());
assertTrue
(
b
.
getAllCheckResults
().
containsKey
(
CheckId
.
C_GE_P_HOLE_OUTSIDE
));
assertFalse
(
c2
.
canExecute
(
b
));
assertEquals
(
2
,
b
.
getAllCheckResults
().
size
());
assertTrue
(
b
.
getAllCheckResults
().
containsKey
(
CheckId
.
C_GE_P_INNER_RINGS_NESTED
));
assertFalse
(
c2
.
canExecute
(
b
));
Vegetation
veg
=
new
Vegetation
(
VegetationType
.
PLANT_COVER
);
assertFalse
(
c2
.
canExecute
(
veg
));
}
}
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