-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: set actualSubmissionDate to null for all draft recommendations #432
base: main
Are you sure you want to change the base?
Conversation
TIS21-3530:TIS Status not changing to draft when recommendation process is started e.g GMC 7072683
Could have used a more efficient JPA query (ifNotNull) but wasn't sure it was worth cluttering the repository class for a one-off change |
…angeLog TIS21-3530:TIS Status not changing to draft when recommendation process is started e.g GMC 7072683
TIS21-3530:TIS Status not changing to draft when recommendation process is started e.g GMC 7072683
Kudos, SonarCloud Quality Gate passed! |
List.of(draftWithDate) | ||
); | ||
changeLog.setActualSubmissionDatesToNull(recommendationRepository); | ||
verify(recommendationRepository).save(draftWithoutDate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is draftWithoutDate
rather than draftWithDate
some #copy:spaghetti:? If so, worth looking at why the test passes!
It might be that you want to use a fakers/random for the recommendation id field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I think we need to verify the post parameter doesn't have the actualSubmissionDate, so draftWithoutDate
is the expected one. But, either draftWithoutDate
or draftWithDate
can pass the tests!!
Because Mockito uses Recommendation.equals
to check if the object matches. And the equals()
method is generated by Lombok @Data
, here is the doc: https://projectlombok.org/features/Data (Scrolling down to equals()
, we can see it checks the reference first, if references don't match, then check eatch fields).
I think a better way to check the post parameters is to use ArgumentCaptor.
private Recommendation buildDraftWithActualSubmissionDate() { | ||
return Recommendation.builder() | ||
.id(RECOMMENDATION_ID) | ||
.actualSubmissionDate(LocalDate.now()) | ||
.build(); | ||
} | ||
|
||
private Recommendation buildDraftWithoutActualSubmissionDate() { | ||
return Recommendation.builder() | ||
.id(RECOMMENDATION_ID) | ||
.build(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done inline to reduce LOC. Methods are good where we think we'll reuse them. You could also replace the 2 methods with a parameterised version that takes a date, or many fields, inc. id
.
private static final String RECOMMENDATION_ID = "123"; | ||
|
||
private Recommendation draftWithDate = buildDraftWithActualSubmissionDate(); | ||
private Recommendation draftWithoutDate = buildDraftWithoutActualSubmissionDate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these 2 objects are used in different tests, it would be better to set them as final.
Querying with the filter I don't know how drafts got actualSubmissionDate and think it's better to know if this will happen again after we apply this changelog. |
TIS21-3530:TIS Status not changing to draft when recommendation process is started e.g GMC 7072683