I wrote a Test for a MongoRepository in Spring Boot, and the test works fine. The only problem is that when the test is over, I want a rollback, so that there will be no change in the database caused by the test.
@RunWith(SpringRunner.class)
@DataMongoTest
@Transactional
public class AccountTypeRepositoryTest {
@Autowired
AccountTypeRepository accountTypeRepository;
@Test
@Rollback(true)
public void test_save(@Autowired MongoTemplate mongoTemplate){
AccountType accountType=new AccountType();
accountType.setName("test");
AccountType expected=accountTypeRepository.save(accountType);
assertNotNull(expected);
assertNotNull(expected.getId());
}
}
It is amazing to visit your site. Thanks for sharing this information, this is useful to me...
RépondreSupprimerWorkday Integration Online Training
Workday Integration Course India