Minor cleanup with tests

Added converter on saving in db user
This commit is contained in:
coach88
2015-08-15 00:11:19 +03:00
parent 3e4f69fb74
commit 236b808d05
10 changed files with 167 additions and 7 deletions

View File

@@ -34,7 +34,9 @@ public class MongoTemplateQueryIntegrationTest {
@Before
public void testSetup() {
mongoTemplate.createCollection(User.class);
if (!mongoTemplate.collectionExists(User.class)) {
mongoTemplate.createCollection(User.class);
}
}
@After
@@ -148,7 +150,7 @@ public class MongoTemplateQueryIntegrationTest {
}
@Test
public void givenExisted() {
public void whenSavingUserWithEmailAddress_thenUserandEmailAddressSaved() {
User user = new User();
user.setName("Brendan");
EmailAddress emailAddress = new EmailAddress();

View File

@@ -17,7 +17,9 @@ public class BaseQueryIntegrationTest {
@Before
public void testSetup() {
mongoOps.createCollection(User.class);
if (!mongoOps.collectionExists(User.class)) {
mongoOps.createCollection(User.class);
}
}
@After

View File

@@ -34,7 +34,9 @@ public class UserRepositoryIntegrationTest {
@Before
public void testSetup() {
mongoOps.createCollection(User.class);
if (!mongoOps.collectionExists(User.class)) {
mongoOps.createCollection(User.class);
}
}
@After
@@ -67,12 +69,11 @@ public class UserRepositoryIntegrationTest {
mongoOps.insert(user);
user = mongoOps.findOne(Query.query(Criteria.where("name").is("Jack")), User.class);
final String id = user.getId();
user.setName("Jim");
userRepository.save(user);
assertThat(mongoOps.findOne(Query.query(Criteria.where("id").is(id)), User.class).getName(), is("Jim"));
assertThat(mongoOps.findAll(User.class).size(), is(2));
}
@Test