giuseppe-trisciuoglio avatar

Unit Test Json Serialization

If you're writing Spring Boot apps with Jackson, you'll eventually need to verify your DTOs serialize correctly. This gives you patterns for @JsonTest with JacksonTester, covering the essentials like field name mappings with @JsonProperty, custom serializers, nested objects, and polymorphic types. The examples are practical: testing that your API responses actually match what you expect, handling null fields properly, and validating date formats don't break between versions. It's focused on unit testing the JSON layer in isolation, not integration tests. Honestly, this is one of those things you set up once per project and then copy the pattern everywhere.

skills.sh installs
3.9K
GitHub stars
369
last updated
Aug 21, 2026

Install

$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-json-serialization --agent claude-code

Installs into .claude/skills of the current project.

Files

Unit Testing JSON Serialization with @JsonTest

Overview

Provides patterns for unit testing JSON serialization and deserialization using Spring's @JsonTest and Jackson. Covers POJO mapping, custom serializers, field name mappings, nested objects, date/time formatting, and polymorphic types.

When to Use

  • Testing JSON serialization/deserialization of DTOs
  • Verifying custom Jackson serializers/deserializers
  • Validating @JsonProperty, @JsonIgnore, and field name mappings
  • Testing date/time format handling (LocalDateTime, Date)
  • Testing null handling and missing fields
  • Testing polymorphic type deserialization

Instructions

Sponsors

Details

Repository
github.com/giuseppe-trisciuoglio/developer-kit
Categories
Testing & QA, Documentation, Java & JVM
First seen
May 16, 2026

More from giuseppe-trisciuoglio/developer-kit

All 102
1giuseppe-trisciuoglio avatarunit-test-security-authorizationgiuseppe-trisciuoglio/developer-kitProvides patterns for unit testing Spring Security with `@PreAuthorize`, `@Secured`, `@RolesAllowed`. Validates role-based access control and authorization poli3.9Kskills.sh installs
2giuseppe-trisciuoglio avatarunit-test-scheduled-asyncgiuseppe-trisciuoglio/developer-kitProvides patterns for unit testing Spring `@Scheduled` and `@Async` methods using JUnit 5, CompletableFuture, Awaitility, and Mockito. Covers mocking task execu3.9Kskills.sh installs
3giuseppe-trisciuoglio avatarunit-test-utility-methodsgiuseppe-trisciuoglio/developer-kitProvides patterns for testing utility classes, static methods, and helper functions. Validates pure functions, null handling, edge cases, and boundary condition3.9Kskills.sh installs
4giuseppe-trisciuoglio avatarunit-test-exception-handlergiuseppe-trisciuoglio/developer-kitProvides patterns for unit testing `@ExceptionHandler` and `@ControllerAdvice` in Spring Boot applications. Validates error response formatting, mocks exception3.9Kskills.sh installs
5giuseppe-trisciuoglio avatarunit-test-config-propertiesgiuseppe-trisciuoglio/developer-kitProvides patterns for unit testing `@ConfigurationProperties` classes with `@ConfigurationPropertiesTest`. Validates property binding, tests validation constrai3.8Kskills.sh installs
6hyva-themes avatarhyva-playwright-testhyva-themes/hyva-ai-toolsWrite Playwright tests for Hyvä themes with Alpine.js components. This skill should be used when writing e2e tests, creating page objects, or debugging selector1.3Kskills.sh installs