JAVA-31697: Fix failing integration test in spring-boot-persistence-mongodb (#16177)
This commit is contained in:
parent
4e08d9bd77
commit
8cd148b5b0
|
@ -10,4 +10,5 @@ spring.thymeleaf.cache=false
|
|||
|
||||
spring.servlet.multipart.max-file-size=256MB
|
||||
spring.servlet.multipart.max-request-size=256MB
|
||||
spring.servlet.multipart.enabled=true
|
||||
spring.servlet.multipart.enabled=true
|
||||
spring.data.mongodb.uri=mongodb://localhost
|
|
@ -2,30 +2,31 @@ package com.baeldung.mongodb;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import com.baeldung.mongodb.daos.UserRepository;
|
||||
import com.baeldung.mongodb.models.User;
|
||||
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@DirtiesContext
|
||||
public class MongoDbAutoGeneratedFieldIntegrationTest {
|
||||
@DataMongoTest
|
||||
class MongoDbAutoGeneratedFieldIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
UserRepository userRepository;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {}
|
||||
void contextLoads() {
|
||||
// Verifies the context is loaded correctly
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUserObject_whenSave_thenCreateNewUser() {
|
||||
void givenUserObject_whenSave_thenCreateNewUser() {
|
||||
|
||||
User user = new User();
|
||||
user.setFirstName("John");
|
||||
|
@ -33,8 +34,8 @@ public class MongoDbAutoGeneratedFieldIntegrationTest {
|
|||
user.setEmail("john.doe@example.com");
|
||||
userRepository.save(user);
|
||||
|
||||
assertThat(userRepository.findAll().size()).isGreaterThan(0);
|
||||
assertThat(userRepository.findAll()
|
||||
.size()).isPositive();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue