Skip to content

rockotseng/mongo-data-annotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mongo Data Annotation

To annotate a test class or test method to configure testing data to be inserted into certain MongoDB during integration tests.

Idea from @Sql of Spring Framework

Made by ResourceReaderRepositoryPopulator of Spring Data Mongo

Usage

Add MongoDataTestExecutionListener to your test class

@TestExecutionListeners(listeners = MongoDataTestExecutionListener.class, mergeMode = MergeMode.MERGE_WITH_DEFAULTS)

Annotate your test class or test method

@Test
@MongoData("/test-data/foo.json")
public void test() {
    assertEquals(1, fooRepository.count());
}

Please see IntegrationTest.java for details.