plugins/developer-kit-java/skills/unit-test-mapper-converter/SKILL.md
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.
npx skillsauth add giuseppe-trisciuoglio/developer-kit unit-test-mapper-converterInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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
development
Provides security review capability for TypeScript/Node.js applications, validates code against XSS, injection, CSRF, JWT/OAuth2 flaws, dependency CVEs, and secrets exposure. Use when performing security audits, before deployment, reviewing authentication/authorization implementations, or ensuring OWASP compliance for Express, NestJS, and Next.js. Triggers on "security review", "check for security issues", "TypeScript security audit".
development
Provides final code cleanup after task review approval. Removes debug logs, temporary comments, dead code, optimizes imports, and improves readability. Use when asked to clean up code, polish, finalize, tidy up, remove technical debt, or prepare code for completion after review. Not for refactoring logic or fixing bugs—focused solely on cosmetic and hygiene cleanup.
tools
Ralph Wiggum-inspired automation loop for specification-driven development. Orchestrates task implementation, review, cleanup, and synchronization using a Python script. Use when: user runs /loop command, user asks to automate task implementation, user wants to iterate through spec tasks step-by-step, or user wants to run development workflow automation with context window management. One step per invocation. State machine: init → choose_task → implementation → review → fix → cleanup → sync → update_done. Supports --from-task and --to-task for task range filtering. State persisted in fix_plan.json.
testing
Creates, updates, validates, and displays the architectural DNA of a project through two shared documents: docs/specs/architecture.md (technology stack, architectural rules, security constraints, AI guardrails) and docs/specs/ontology.md (domain glossary / Ubiquitous Language). Use BEFORE brainstorm as a project setup step, or at any point in the SDD lifecycle to validate specs/tasks against architecture principles. Triggers on 'create constitution', 'update constitution', 'constitution check', 'validate against constitution', 'project principles', 'architectural guardrails', 'setup project architecture', 'define ontology'.