-
Notifications
You must be signed in to change notification settings - Fork 23
Marcorensch #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcorensch
wants to merge
5
commits into
ibwgr:master
Choose a base branch
from
marcorensch:marcorensch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Marcorensch #29
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
99ec09d
Added Tests:
marcorensch 4b0c423
Diverse Tests
marcorensch 2b3d8b6
Included meine UserControllerTest Lösungen
marcorensch e8d402c
Included meine UserControllerTest Lösungen
marcorensch 6611200
withValidInexitingUsername_addUserToDB__MOCKITO
marcorensch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,59 @@ | ||
| package assertions; | ||
|
|
||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.Period; | ||
|
|
||
| class PersonTest { | ||
|
|
||
| // --- getFullName | ||
|
|
||
| @Test | ||
| void getFullNameReturnsFirstnameSpaceLastname(){ | ||
| // TODO implement | ||
| throw new IllegalArgumentException("you should implement code here"); | ||
| Person p = new Person("Hans", "Müller", LocalDate.of(1986, 7, 18)); | ||
| String fullname = "Hans Müller"; | ||
| Assertions.assertEquals(fullname, p.getFullName()); | ||
| } | ||
|
|
||
| // TODO some more useful tests | ||
|
|
||
|
|
||
| // --- getAge | ||
|
|
||
| @Test | ||
| void getAgeReturns10YearsIfBornIn2009() throws Exception { | ||
| // TODO verbessern. Hinweis: Repeatable (wiederholbar) zu jeder Zeit. | ||
| Person p = new Person("", "", LocalDate.of(2009, 1, 1)); | ||
| void getAgeReturns10YearsIf10ago() { | ||
| Person p = new Person("", "", LocalDate.now().minusYears(10)); | ||
| Period age = p.getAge(); | ||
| Assertions.assertEquals(10, age.getYears()); | ||
| } | ||
|
|
||
| throw new IllegalArgumentException("you should implement code here"); | ||
| @Test | ||
| void getAgeHasToBePositive() { | ||
| LocalDate birthday = LocalDate.now().minusYears(10).minusMonths(7).minusDays(9); | ||
| Person p = new Person("Foo", "Bar", birthday); | ||
| Period age = p.getAge(); | ||
| Assertions.assertTrue(age.getYears() > 0 || age.getMonths() > 0 || age.getDays() > 0); | ||
| } | ||
|
|
||
| @Test | ||
| void getAgeReturns1DayIfYesterday() throws Exception { | ||
| void getAgeReturns1DayIfYesterday() { | ||
| Person p = new Person("", "", LocalDate.now().minusDays(1)); | ||
| Period age = p.getAge(); | ||
| Assertions.assertEquals(1, age.getDays()); | ||
| } | ||
|
|
||
| // TODO implement | ||
| throw new IllegalArgumentException("you should implement code here"); | ||
| @Test | ||
| void getAgeReturns5MonthsIf5MonthsAgo() { | ||
| Person p = new Person("", "", LocalDate.now().minusMonths(5)); | ||
| Period age = p.getAge(); | ||
| Assertions.assertEquals(5, age.getMonths()); | ||
| } | ||
|
|
||
| // TODO some more useful tests | ||
| @Test | ||
| void checkIfAgeIsLargerThen11(){ | ||
| Person p = new Person("", "", LocalDate.of(2009, 10, 10)); | ||
| Period age = p.getAge(); | ||
| System.out.println(age.getYears()); | ||
| Assertions.assertTrue(age.getYears() > 11); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package fakes; | ||
|
|
||
| public class FakeUserValidator extends UserValidator { | ||
| private boolean doesUsernameExists; | ||
|
|
||
| public FakeUserValidator(boolean doesUsernameExists){ | ||
| this.doesUsernameExists = doesUsernameExists; | ||
| } | ||
| public FakeUserValidator(){ | ||
| // doesUsernameExists == false so | ||
| } | ||
|
|
||
| @Override | ||
| public boolean doesUsernameExist(String username) { | ||
| return doesUsernameExists; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package fakes; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class MockDatabase extends Database{ | ||
| List<User> users = new ArrayList<>(); | ||
|
|
||
| @Override | ||
| public void addUser(User user) { | ||
| users.add(user); | ||
| } | ||
|
|
||
| @Override | ||
| public List<User> getUsers() { | ||
| return users; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InexistingUsername steht im Testnamen :)
Zudem ist die SUT ja der UserController nicht der UserValidator.