forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eugenp#237 from alex-semenyuk/master
Added support common annotation
- Loading branch information
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -153,7 +153,7 @@ public void givenUserExistsWithIndexAddedFromMapping_whenCheckingIndex_thenIndex | |
public void whenSavingUserWithEmailAddress_thenUserandEmailAddressSaved() { | ||
final User user = new User(); | ||
user.setName("Brendan"); | ||
EmailAddress emailAddress = new EmailAddress(); | ||
final EmailAddress emailAddress = new EmailAddress(); | ||
emailAddress.setValue("[email protected]"); | ||
user.setEmailAddress(emailAddress); | ||
mongoTemplate.insert(user); | ||
|
@@ -172,4 +172,22 @@ public void givenUserExistsWithIndexAddedFromCode_whenCheckingIndex_thenIndexIsE | |
|
||
assertThat(indexInfos.size(), is(2)); | ||
} | ||
|
||
@Test | ||
public void whenSavingUserWithoutSettingAge_thenAgeIsSetByDefault() { | ||
final User user = new User(); | ||
user.setName("Alex"); | ||
mongoTemplate.insert(user); | ||
|
||
assertThat(mongoTemplate.findOne(Query.query(Criteria.where("name").is("Alex")), User.class).getAge(), is(0)); | ||
} | ||
|
||
@Test | ||
public void whenSavingUser_thenYearOfBirthIsCalculated() { | ||
final User user = new User(); | ||
user.setName("Alex"); | ||
mongoTemplate.insert(user); | ||
|
||
assertThat(mongoTemplate.findOne(Query.query(Criteria.where("name").is("Alex")), User.class).getYearOfBirth(), is(2015)); | ||
} | ||
} |