Minor cleanup with tests
Added converter on saving in db user
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user