Unit testing patterns for MapStruct mappers and custom converters with comprehensive transformation validation.
Works with
Covers field mapping accuracy, null handling, type conversions, nested objects, bidirectional mapping, enum mapping, and partial updates
Includes Maven and Gradle setup with MapStruct, JUnit 5, and AssertJ dependencies
Provides patterns for testing simple mappings, nested hierarchies, custom @Mapping annotations, enum @ValueMapping , and @MappingTarget partial updates
De
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionunit-test-mapper-converterExecute the skills CLI command in your project's root directory to begin installation:
Fetches unit-test-mapper-converter from giuseppe-trisciuoglio/developer-kit and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate unit-test-mapper-converter. Access via /unit-test-mapper-converter in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
193
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
193
stars
Provides patterns for unit testing MapStruct mappers and custom converter classes. Covers field mapping accuracy, null handling, type conversions, nested object transformations, bidirectional mapping, enum mapping, and partial updates.
Before testing, verify generated mapper classes exist:
# Maven
ls target/generated-sources/
# Gradle
ls build/generated/sources/
If generated classes are missing:
mvn compile (Maven) or ./gradlew compileJava (Gradle)@Mapper interfaces are in a compiled source setassertThat(mapper.toDto(null)).isNull();
Configure nullValueMappingStrategy in mapper if null should return empty/default.
If null tests fail:
nullValueMappingStrategy = NullValueMappingStrategy.RETURN_NULL to @MappernullValuePropertyMappingStrategy for nested property handlingUser restored = mapper.toEntity(mapper.toDto(original));
assertThat(restored).usingRecursiveComparison().isEqualTo(original);
If bidirectional tests fail:
@Mapping annotations for field name mismatchesunmappedTargetPolicy = ReportingPolicy.ERROR to catch missing mappingsassertThat(dto.getNested()).usingRecursiveComparison().isEqualTo(expected);
If nested tests fail:
uses = NestedMapper.classelementMappingStrategyCustom expressions in @Mapping(target = "field", expression = "java(...)") are not compile-time validated.
If expression tests fail:
Use @ValueMapping for enum-to-enum translations. Test all enum values exhaustively.
Mappers.getMapper() for standalone tests, Spring injection for integration testsusingRecursiveComparison() for complex nested structuresnullValueMappingStrategy and nullValuePropertyMappingStrategy appropriately@Mapping are not validated at compile time—test them explicitlyComplete executable test with imports:
package com.example.mapper;
import org.junit.jupiter.api.Test;
import org.mapstruct.factory.Mappers;
import static org.assertj.core.api.Assertions.*;
class UserMapperCompleteTest {
private final UserMapper mapper = Mappers.getMapper(UserMapper.class);
@Test
void shouldMapUserToDto() {
User user = new User(1L, "Alice", "[email protected]", 25);
UserDto dto = mapper.toDto(user);
assertThat(dto)
.isNotNull()
.extracting(UserDto::getName, UserDto::getEmail)
.containsExactly("Alice", "[email protected]");
}
@Test
void shouldMaintainRoundTrip() {
User original = new User(1L, "Alice", "[email protected]", 25);
assertThat(mapper.toEntity(mapper.toDto(original)))
.usingRecursiveComparison()
.isEqualTo(original);
}
@Test
void shouldHandleNullInput() {
assertThat(mapper.toDto(null)).isNull();
}
}
Additional examples in: references/examples.md
Prerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
cexll/myclaude
unit-test-mapper-converter reduced setup friction for our internal harness; good balance of opinion and flexibility.
unit-test-mapper-converter fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
We added unit-test-mapper-converter from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
Keeps context tight: unit-test-mapper-converter is the kind of skill you can hand to a new teammate without a long onboarding doc.
I recommend unit-test-mapper-converter for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
Solid pick for teams standardizing on skills: unit-test-mapper-converter is focused, and the summary matches what you get after install.
unit-test-mapper-converter is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
Keeps context tight: unit-test-mapper-converter is the kind of skill you can hand to a new teammate without a long onboarding doc.
unit-test-mapper-converter is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
Useful defaults in unit-test-mapper-converter — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
showing 1-10 of 26