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
c73cfb26
Commit
c73cfb26
authored
9 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
Additional test.
parent
602c0438
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
P/Sda1/Javastreams/src/test/java/de/hdm_stuttgart/mi/javastreams/FunctionalTests.java
+34
-1
34 additions, 1 deletion
...java/de/hdm_stuttgart/mi/javastreams/FunctionalTests.java
with
34 additions
and
1 deletion
P/Sda1/Javastreams/src/test/java/de/hdm_stuttgart/mi/javastreams/FunctionalTests.java
+
34
−
1
View file @
c73cfb26
...
...
@@ -13,12 +13,46 @@ import org.junit.Test;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableMap
;
import
de.hdm_stuttgart.mi.javastreams.Student.Sex
;
/**
* Testing functional queries.
*/
public
class
FunctionalTests
{
final
List
<
Student
>
roster
=
Student
.
createRoster
();
/**
* Order all male students by email and create a list of their respective names
* in that order eliminating possible duplicates:
*
* "Bob", 2, Student.Sex.MALE, "bob@uk.edu"
* "Fred", 2, Student.Sex.MALE, "fred@example.com"
* "George", 4, Student.Sex.MALE, "george@math.edu"
* "Jane", 1, Student.Sex.FEMALE, "jane@kiv.de"
* "Kim", 2, Student.Sex.FEMALE, "wilde@serious.de"
*
* ==> {"Bob", "Fred", "George"}
*
*/
@Test
public
void
allMaleDistinctNameOrderedByEmail
()
{
List
<
String
>
emails
=
roster
.
stream
().
filter
(
s
->
s
.
gender
==
Sex
.
MALE
).
sorted
((
s1
,
s2
)
->
s1
.
getEmailAddress
().
compareTo
(
s2
.
getEmailAddress
())).
map
(
Student:
:
getName
).
distinct
().
collect
(
Collectors
.
toList
());
assertThat
(
emails
,
Matchers
.<
List
<
String
>>
equalTo
(
ImmutableList
.
of
(
"Bob"
,
"Fred"
,
"George"
)
)
);
}
/**
* Summing students' marks having a German email address:
...
...
@@ -38,7 +72,6 @@ public class FunctionalTests {
);
}
/**
* Group students by sex and collect their respective names:
*
...
...
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