Sample project using Spring Boot and MongoDB(Fongo) and test repository with NoSqlUnit

Hi, this is the initial post of a series where i’ll be publishing some samples showing how to work with MongoDB documents with Java.
This post sample consists on a project that uses spring-boot with spring-data-mongo repository, Fongo(an in-memory mongodb representation) and NoSqlUnit – a helper library for tests.
For a cleaner document object, we use Lombok.

You can read more about Fongo in here.
You can read more about NoSqlUnit in here.
You can read more about Spring-data-mongo in here.
You can read more about Lombok in here.

User document.

User repository.

Sample data to load using NoSqlUnit.

Sample test.

Configuration

fongo-hello-world‘ – is a maven project, so it should be fairly simple to import and build it. Run the test on class ‘UserRepositoryTest’.
Hope it’s helpful for someone!

Advertisements

One thought on “Sample project using Spring Boot and MongoDB(Fongo) and test repository with NoSqlUnit

  1. I’ve been working in a personal project using spring-data-mongo-db and I’m pretty satisfied with it. Regarding your post, I got surprised with NoSqlUnit (didn’t know about it) and it looks interesting, however, in most cases I think it’s not the best solution – If you need to apply changes in the domain model for example, these changes are not automatically reflected in the json files and I can’t event think how tough would be to refactor them. Nice job 😉

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s