mapstruct / mapstruct/mapstruct-examples

mapstruct-mapper-repo example bug

Open
#79 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.4k
Forks
504
PR merge metrics
No merged PRs in 30d

Description

in testMapObjectToObject add:
carDto.setSetCount(7);
and
Assert.assertEquals(5, carDto.getSeatCount());
test will fail

Also, despite the annotation
@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
on CarMapper:
in testMapObjectToObject
change
Car car = new Car("Morris", 5, CarType.SPORTS);
to
Car car = new Car("Morris", 5, null);
and add
carDto.setType("anything");
and
Assert.assertEquals("anything", carDto.getType());
test will fail

For the latter, I tried to make sense of your recent change of "don't overwrite target if source is null" pull request, but there was so much discussion on what the annotation should be, I couldn't easily figure out the end result. ;o)

I also can't find a test case in this git repo that covers it. Can you point me to it, if there is one?
Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with testMapObjectToObject and the CarMapper definition mentioned in the issue. Run the test after applying the described inputs to reproduce both mapping failures, then inspect the existing nullValuePropertyMappingStrategy coverage and related discussion. Done means the intended seat-count and null-source behavior is reproduced by regression tests and the example tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.