Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
8159818a
Commit
8159818a
authored
8 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
Simplifying Map object handling
parent
ba0482de
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ws/Unitmarking/src/main/java/de/hdm_stuttgart/mi/exam/unitmarking/MarkingListener.java
+28
-26
28 additions, 26 deletions
...de/hdm_stuttgart/mi/exam/unitmarking/MarkingListener.java
with
28 additions
and
26 deletions
ws/Unitmarking/src/main/java/de/hdm_stuttgart/mi/exam/unitmarking/MarkingListener.java
+
28
−
26
View file @
8159818a
...
...
@@ -8,15 +8,23 @@ import org.junit.runner.notification.Failure;
import
org.junit.runner.notification.RunListener
;
public
class
MarkingListener
extends
RunListener
{
static
<
T
>
T
last
(
T
[]
array
)
{
return
array
[
array
.
length
-
1
];
}
private
Map
<
String
,
Values
>
valuesByClassname
=
new
HashMap
<>();
class
Values
{
int
points
=
0
,
reachablePoints
=
0
,
currentPoints
;
reachablePoints
=
0
,
currentPoints
=
0
;
public
Values
()
{}
public
Values
(
int
currentPoints
)
{
this
.
currentPoints
=
currentPoints
;
}
public
int
getPoints
()
{
return
points
;
}
...
...
@@ -24,6 +32,10 @@ public class MarkingListener extends RunListener {
public
int
getReachablePoints
()
{
return
reachablePoints
;
}
public
Values
set
(
int
currentPoints
){
this
.
currentPoints
=
currentPoints
;
return
this
;
}
}
@Override
...
...
@@ -42,31 +54,21 @@ public class MarkingListener extends RunListener {
}
Values
addDescription
(
final
Description
description
)
{
// Split fully qualified classname string
final
String
[]
components
=
description
.
getClassName
().
split
(
"\\."
);
final
String
testClassName
=
last
(
description
.
getClassName
().
split
(
"\\."
)
)
;
final
String
testClassName
=
components
[
components
.
length
-
1
];
Values
values
=
valuesByClassname
.
get
(
testClassName
);
if
(
null
==
values
)
{
values
=
new
Values
();
valuesByClassname
.
put
(
testClassName
,
values
);
}
final
Marking
marking
=
description
.
getAnnotation
(
Marking
.
class
);
if
(
null
==
marking
)
{
values
.
currentPoints
=
1
;
}
else
{
values
.
currentPoints
=
marking
.
points
();
}
return
values
;
final
int
reacheablePoints
=
null
==
marking
?
1
:
marking
.
points
();
return
valuesByClassname
.
compute
(
testClassName
,
(
c
,
v
)
->
{
return
v
==
null
?
new
Values
(
reacheablePoints
):
v
.
set
(
reacheablePoints
);});
}
public
String
getPointSumms
()
{
final
StringBuffer
ret
=
new
StringBuffer
();
int
reachablePointSum
=
0
,
pointSum
=
0
;
for
(
Map
.
Entry
<
String
,
Values
>
entry:
valuesByClassname
.
entrySet
())
{
ret
.
append
(
entry
.
getKey
());
ret
.
append
(
": "
);
...
...
@@ -81,11 +83,11 @@ public class MarkingListener extends RunListener {
ret
.
append
(
"\nSum ("
+
pointSum
+
"/"
+
reachablePointSum
+
")"
);
return
ret
.
toString
();
}
// @Override
// public void testRunStarted(Description description) throws Exception {
// super.testRunStarted(description);
// System.out.println("testRunStarted" + description);
// }
// @Override
// public void testRunStarted(Description description) throws Exception {
// super.testRunStarted(description);
// System.out.println("testRunStarted" + description);
// }
//
// @Override
// public void testRunFinished(Result result) throws Exception {
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment