Goodbye Grails, Hello Micronaut #4: Datasets

This is the fourth post in a series that will guide you through the migration from Grails to Micronaut. This guide requires your application to be based on Grails 4.x or later.

We should cover the crucial parts of the application with tests as things can go wrong very easily during the migration. For the meaningful tests, we will need the meaningful data. In this post, we are going to use Dru framework for this purpose because it already supports Grails and GORM, and Micronaut Data out of the box.

Dru excels in creating the relationships between different entities but we won't get into too many details. You should rather use the documentation for the full reference.

Let's say we have a simple domain class in our codebase:


If you want to define the dataset for an entity then we usually choose from either a JSON or SQL file. You can use responses from your production or test environment using the JSON source or you can use simplified database dumps with the SQL source. To add Dru on your classpath update the application's Gradle file with the following dependencies:

The following snippet shows using the JSON fixture to load test data:


Given the class HelloDataSet being declared in hello package then the JSON file containing the test data for vehicles is located in src/test/resources/hello/HelloDataSet/vehicles.json file.


The data set deserves its own specification as a lot of other tests will depend on the data being loaded properly:


Creating data sets will later help us to create tests for the controllers as well as migrating from GORM to Micronaut Data.

In the next step, we will move towards decoupling the web layer from the domain layer by introducing Data Transfer Objects (DTOs) into the controllers.

Table of Contents

  1. Multiproject
  2. Configuration
  3. Static Compilation
  4. Datasets
  5. Marshalling
  6. Domain Classes
  7. Services
  8. Controllers
  9. Micronaut Application
  10. Micronaut Data

Sources & Discussion




Agorapulse is a leading Social Media Management platform. This is our story and feedback from the ground.

Recommended from Medium

Credit Checker: Instant real-time credit report inside Salesforce

B2B Lead Generation in Dungannon #Dungannon

Reap The Benefits Of Include Junior Team Members In Your Code Review Process

Go Lean or Go Agile: A Brief Analysis

Getting started with lyft/cartography

Troubleshoot maven test goal from your IDE

Dual-track Agile: How to optimize product development?

Poor Acceptance Criteria Can Ruin Any Great User Story

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vladimír Oraný

Vladimír Oraný

Full Stack Developer and Test Facilitator at @agorapulse

More from Medium

Distributed Systems Part-3: Managing Anti-Entropy using Merkle Trees

Solace Selector

88th Monthly Technical Session

Pendle x Ante: Pendle Ante Tests Explained