Skip to content

Conversation

@EdwardBarclay
Copy link
Contributor

feat: add get endpoints for for R. these are for the admins to use to get a list of all forms or a singular formR

@ReubenRobertsHEE
Copy link
Contributor

@EdwardBarclay would you mind fixing the build/compile issues before a proper review? 😁

@EdwardBarclay
Copy link
Contributor Author

@EdwardBarclay would you mind fixing the build/compile issues before a proper review? 😁

Yep! think I mixed something up when re-doing the PR, sorting out the partB so it gets the id within the service rather then needing a param too

query.addCriteria(Criteria.where("traineeTisId").is(traineeTisId));

query.addCriteria(Criteria.where("submissionDate").ne(null));
query.addCriteria(Criteria.where("status.lifecycleState").ne(LifecycleState.DELETED));
Copy link
Contributor

@ReubenRobertsHEE ReubenRobertsHEE Jan 14, 2026

Choose a reason for hiding this comment

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

If it were me, I would rather use a parameterised query in the FormRPartARepository for this, it might fit better there (and allows you to avoid using the mongoTemplate directly from the service). e.g. something like

@Query("{ 'traineeTisId': ?0, 'submissionDate': { $ne: null }, 'status.lifecycleState': { $ne: 'DELETED' } }")
  List<FormRPartA> findNotDraftNorDeletedByTraineeTisId(String traineeTisId);

(excluding DRAFT forms by using the presence of a submissionDate is maybe a bit brittle, I'd rather use the lifecycleState for all conditions, but it's somewhat a matter of taste. Either way, you should be consistent in the criteria used for a single form and a list of forms, to avoid inconsistency. For a single form you are currently using lifecycleState only.)

Also, can you please test locally to confirm that status.lifecycleState is actually the correct term? On my side I would have assumed it was lifecycleState, there is no status subdocument in FormRs.

@EdwardBarclay EdwardBarclay force-pushed the add_formr_admin_get_endpoints branch from 7f07966 to 6f173c6 Compare January 16, 2026 09:59
@EdwardBarclay EdwardBarclay marked this pull request as ready for review January 16, 2026 10:01
@EdwardBarclay EdwardBarclay requested a review from a team as a code owner January 16, 2026 10:01
@EdwardBarclay EdwardBarclay force-pushed the add_formr_admin_get_endpoints branch from d051904 to 342a84a Compare January 16, 2026 12:48
@EdwardBarclay EdwardBarclay requested a review from Judge40 January 16, 2026 14:00
@EdwardBarclay EdwardBarclay requested a review from Judge40 January 19, 2026 15:40
Copy link
Contributor

@ReubenRobertsHEE ReubenRobertsHEE left a comment

Choose a reason for hiding this comment

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

Looking pretty good. It would be sensible to add some integration tests, in the same way that we have for other endpoints.

… get a list of all forms or a singular formR

TICKET TIS21-8076
TICKET TIS21-8077

chore: codesmells that arnt consecutive capitalisation TICKET TIS21-8076 TICKET TIS21-8077

test: fix broken tests TICKET TIS21-8076 TICKET TIS21-8077

chore: github comments

TICKET TIS21-8076
TICKET TIS21-8077

chore: codesmells

TICKET TIS21-8076
TICKET TIS21-8077

test: add service tests

TICKET TIS21-8076
TICKET TIS21-8077

feat: fix build errors refactor admins form R part B GET service

TICKET TIS21-8076
TICKET TIS21-8077

refactor: remove re-appeared mongo implimentation

TICKET TIS21-8076
TICKET TIS21-8077

refactor: change services to return optional of forms instead of nullable, and update tests

TICKET TIS21-8076
TICKET TIS21-8077

fix: I forgot to remove the GET params TICKET TIS21-8076 TICKET TIS21-8077

fix: issue with incorrect labling for trainee Id and Id in the repository test: add intergration tests

TICKET TIS21-8076
TICKET TIS21-8077

test: add forgotton intergration testing

TICKET TIS21-8076
TICKET TIS21-8077

refactor: remove filtering logic from service to be preformed by mongo in the repo. update tests to match changes

TICKET TIS21-8076
TICKET TIS21-8077
@EdwardBarclay EdwardBarclay force-pushed the add_formr_admin_get_endpoints branch from 8ef972a to e5e7867 Compare January 21, 2026 10:14
@sonarqubecloud
Copy link


Optional<FormRPartADto> formRPartADto = service.getAdminsFormRPartAById(id);

formRPartADto.ifPresent(dto ->
Copy link
Contributor

Choose a reason for hiding this comment

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

}

@Test
void shouldGetAdminsFormRPartAByIdWhenSubmitted() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Because you are mocking the repository function, there is no real value in having these two tests (shouldGetAdminsFormRPartAByIdWhenSubmitted(), shouldGetAdminsFormRPartAByIdWhenUnsubmitted()). If anything, that logic should be tested in repository unit tests, or in the e2e tests.


@ParameterizedTest(name = "Should return empty when admin form is {0}")
@EnumSource(value = LifecycleState.class, names = {"DRAFT", "DELETED"})
void shouldReturnEmptyWhenAdminsFormRPartAIsDraftOrDeleted(LifecycleState state) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Because you don't mock the repository method here, any lifecycle state will return nothing, which means its not testing what you are trying to test.
If you want to test the repository method logic directly, which would be nice, these should go in a repository test class.

GET | /api/admin/formr-parta/{formId} | HEE Admin Sensitive
GET | /api/admin/formr-parta/{formId} | HEE TIS Admin
""")
void shouldReturnOkWhenRequiredFormFound(HttpMethod method, String uriTemplate,
Copy link
Contributor

Choose a reason for hiding this comment

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

As you do for the list request tests below, it would be useful to confirm the lifecycleState filter is working correctly for a single form request. In this particular case, lifecycleState == null, which 'passes', but if anything makes me think the filter should be a bit stricter and not allow null lifecycleState forms to be returned!

Repository unit tests could be used to confirm the filters are working as intended, in which case the e2e tests do not need to cover this logic in detail.

@ReubenRobertsHEE
Copy link
Contributor

Sorry @EdwardBarclay, lots of comments - the squash commit sent me back to review everything, you see 😁 😈

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.

4 participants