LogoAwesome Skills
  • Search
  • Category
  • Tag
  • Blog
LogoAwesome Skills
LogoAwesome Skills

Discover Open-Source Agent Skills for AI Coding Assistants

Product

  • Search
  • Category
  • Tag
  • Blog

Resources

  • Claude Skill Docs
  • Antigravity Skills Docs

Tools

  • Claude Code
  • OpenCode
  • Cursor
  • Codex
  • Antigravity

Company

  • Privacy Policy
  • Terms of Service
  • Sitemap

©2026 Awesome Skills. All rights reserved.

Privacy PolicyTerms
Back to Skills

unit-test-mapper-converter

Provides patterns for unit testing mappers, converters, and bean mappings. Validates entity-to-DTO and model transformation logic in isolation. Generates executable mapping tests with MapStruct and custom converter test coverage. Use when writing mapping tests, converter tests, entity mapping tests, or ensuring correct data transformation between DTOs and domain objects.

315stars37forksUpdated 8/1/2026
Testing & QA#mapstruct#spring-boot#unit-testing#dto#testing#java

Security Assessment

Safe(95/100)
Security Score95/100

About unit-test-mapper-converter

This skill provides patterns for unit testing MapStruct mappers and custom converter classes in Java. It solves the problem of verifying data transformation correctness — entity-to-DTO mapping, null handling, type conversion, nested objects, bidirectional round trips, and enum mapping — in isolated, executable tests.

The guidance begins by verifying that MapStruct's compile-time generated mapper classes exist before testing, with fallback steps to run compilation and check the annotation processor. It then covers testing null handling and configuring nullValueMappingStrategy, bidirectional round-trip mapping using usingRecursiveComparison, nested object and collection mapping via referenced mappers, custom @Mapping expressions that are not compile-time validated, and exhaustive enum-to-enum @ValueMapping tests. A best-practices section recommends Mappers.getMapper for standalone tests and Spring injection for integration tests, plus focusing tests on transformation correctness. Constraints call out compile-time generation, circular dependency limits, collection immutability, and date/time timezone handling. Reference examples include basic mappers, nested and list mapping, custom field-name and expression mapping, enum mapping, a custom date formatter/converter, and partial update mapping.

It targets Java developers using MapStruct for DTO and domain-object mapping who want reliable regression coverage of their transformation layer. It fits teams standardizing mapping tests across a codebase.

FAQ

What mapping framework does it target?

MapStruct (version 1.5.5.Final in the examples), plus custom hand-written converter classes.

Why check for generated classes before testing?

MapStruct generates mapper implementations at compile time; the skill has you verify the generated sources exist and, if missing, run compilation and check the annotation processor configuration.

How does it test round-trip mapping?

By mapping an entity to a DTO and back, then comparing with usingRecursiveComparison to catch asymmetries between the two directions.

Are custom mapping expressions covered?

Yes, and the skill warns that expressions in @Mapping are not validated at compile time, so they must be tested explicitly.

What are the noted limitations?

MapStruct cannot handle circular dependencies between mappers, mapping immutable collections may need special configuration, and date/time mapping should be verified across timezones.

All Files

2 files
references/examples.md7.5 KB
View
SKILL.md4.8 KB
View

Install unit-test-mapper-converter

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

giuseppe-trisciuoglio/developer-kit

Related Skills

short-form-video

14

multi-asset-morning-briefing

7,907

content-strategy

2,901

doherty-threshold

2,901