Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CaiWillis
Copy link
Contributor

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
@CaiWillis
Copy link
Contributor Author

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

TISadminCW added 2 commits December 19, 2022 11:48
…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
@sonarcloud
Copy link

sonarcloud bot commented Dec 19, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

List.of(draftWithDate)
);
changeLog.setActualSubmissionDatesToNull(recommendationRepository);
verify(recommendationRepository).save(draftWithoutDate);
Copy link
Contributor

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.

Copy link
Contributor

@hihilary hihilary Dec 28, 2022

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.

Comment on lines +50 to +61
private Recommendation buildDraftWithActualSubmissionDate() {
return Recommendation.builder()
.id(RECOMMENDATION_ID)
.actualSubmissionDate(LocalDate.now())
.build();
}

private Recommendation buildDraftWithoutActualSubmissionDate() {
return Recommendation.builder()
.id(RECOMMENDATION_ID)
.build();
}
Copy link
Contributor

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();
Copy link
Contributor

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.

@hihilary
Copy link
Contributor

Querying with the filter {$and:[{recommendationStatus:"READY_TO_REVIEW"},{actualSubmissionDate:{$exists:true}}]}, we can find 439 draft recommendations with actualSubmissionDate, and if we sort by {actualSubmissionDate: -1}, the latest actualSubmissionDate is 2022-06-22.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants