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

DMP-3534: Retention Confidence #2382

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

chrisbellingham-hmcts
Copy link
Contributor

@chrisbellingham-hmcts chrisbellingham-hmcts commented Dec 13, 2024

DMP-3534

Two fundamental changes in this PR:

  1. The numerical values associated with retn_conf_score have been altered per the ticket requirement. See src/main/java/uk/gov/hmcts/darts/retention/enums/RetentionConfidenceScoreEnum.java
  2. The retention confidence reason and score that are set on a case are now driven by the provided confidence category. A DB lookup is performed on retention_confidence_category_mapper to obtain these values. See src/main/java/uk/gov/hmcts/darts/retention/service/impl/RetentionServiceImpl.java

Some additional work has been done to facilitate these changes:

  • RetentionConfidenceCategoryMapperEntity has been updated to utilise enums rather than ints, improving code readability and aligning with the approach taken for CaseRetentionEntity and CourtCaseEntity.
  • The logic that performs the category lookup and that sets the confidence attributes on a court case has been centralised in RetentionServiceImpl, and calling code has been adjusted to share this common code.
  • Test data classes have been created to allow for easy creation of RetentionConfidenceCategoryMapperEntity objects for both unit and integration tests going forward.
  • A flyway script is included to migrate ret_conf_score values of 1 -> 0, and 2 -> 1, such that the meaning of those numerical values is consistent between DB and application.

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[x] No

@chrisbellingham-hmcts chrisbellingham-hmcts force-pushed the dmp-3534-retention-confidence-category-mapper branch from 0b674db to a78340f Compare December 18, 2024 12:13
@chrisbellingham-hmcts chrisbellingham-hmcts force-pushed the dmp-3534-retention-confidence-category-mapper branch from a78340f to 7eaab33 Compare December 18, 2024 12:15

// when
closeOldCasesProcessor.closeCases(2);

// then
assertTrue(courtCase.getClosed());
assertEquals(CURRENT_DATE_TIME, courtCase.getRetConfUpdatedTs());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Author note: The class under test no longer has responsibility for setting this attribute, therefore the assertion is removed here. Dedicated unit tests exist in RetentionServiceImplTest to verify this attribute is set correctly.

Comment on lines -308 to -312
verify(caseRepository).save(courtCaseEntityArgumentCaptor.capture());
CourtCaseEntity savedCourtCase = courtCaseEntityArgumentCaptor.getValue();
assertEquals(RetentionConfidenceReasonEnum.MANUAL_OVERRIDE, savedCourtCase.getRetConfReason());
assertEquals(RetentionConfidenceScoreEnum.CASE_PERFECTLY_CLOSED, savedCourtCase.getRetConfScore());
assertEquals(CURRENT_DATE_TIME, savedCourtCase.getRetConfUpdatedTs());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Author note: The class under test no longer has responsibility for setting these attributes, therefore the assertions are removed here. Dedicated unit tests exist in RetentionServiceImplTest to verify these attributes are set correctly.

Similar comment applies to the other tests in this test class.

@chrisbellingham-hmcts chrisbellingham-hmcts marked this pull request as ready for review December 18, 2024 13:54
@chrisbellingham-hmcts chrisbellingham-hmcts requested review from davet1985, jackmaloney, cakeben, c4seyla, cpareek and mananpatel26 and removed request for a team December 18, 2024 13:54
@chrisbellingham-hmcts chrisbellingham-hmcts changed the title DMP-3534 (WIP) DMP-3534: Retention Confidence Dec 18, 2024
…g value for confidenceReason; add associated test

OffsetDateTime closeDate = OffsetDateTime.now().minusYears(7);

EventEntity eventEntity1 = dartsDatabase.getEventStub().createEvent(hearing, 8);//Re-examination
Copy link
Contributor

@jackmaloney jackmaloney Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does comment on this line mean? Is it the event name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will review the comments in this test method, I have copy/pasted an existing test setup to test a slightly different scenario here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing comments were relating to the name of the event handler, but since the primary keys were hard-coded they have since went out of sync. Regardless, the choice of event handler doesn't matter, we just need some event.

I've reworked this test to remove the hard-coded primary keys and have simplified it somewhat.

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

Successfully merging this pull request may close these issues.

3 participants