example code for BAEL-1961 (#5781)
* added example code for BAEL-2366 * moved example code for BAEL-2366 * example code for BAEL-1961 * moved example code into integration test * updated the test assertions
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.baeldung.mongodb;
|
||||
|
||||
import com.baeldung.mongodb.daos.UserRepository;
|
||||
import com.baeldung.mongodb.models.User;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class MongoDbAutoGeneratedFieldIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {}
|
||||
|
||||
@Test
|
||||
public void givenUserObject_whenSave_thenCreateNewUser() {
|
||||
|
||||
User user = new User();
|
||||
user.setFirstName("John");
|
||||
user.setLastName("Doe");
|
||||
user.setEmail("john.doe@example.com");
|
||||
userRepository.save(user);
|
||||
|
||||
assertThat(userRepository.findAll().size()).isGreaterThan(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user