-
Notifications
You must be signed in to change notification settings - Fork 0
Add formr admin get endpoints #782
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
base: main
Are you sure you want to change the base?
Conversation
|
@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 |
src/main/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartBResource.java
Outdated
Show resolved
Hide resolved
| query.addCriteria(Criteria.where("traineeTisId").is(traineeTisId)); | ||
|
|
||
| query.addCriteria(Criteria.where("submissionDate").ne(null)); | ||
| query.addCriteria(Criteria.where("status.lifecycleState").ne(LifecycleState.DELETED)); |
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 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.
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBService.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAService.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBService.java
Outdated
Show resolved
Hide resolved
7f07966 to
6f173c6
Compare
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAService.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAService.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAService.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBService.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBService.java
Outdated
Show resolved
Hide resolved
d051904 to
342a84a
Compare
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAService.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBService.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartBResource.java
Outdated
Show resolved
Hide resolved
ReubenRobertsHEE
left a comment
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.
Looking pretty good. It would be sensible to add some integration tests, in the same way that we have for other endpoints.
...rationTest/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartAResourceIntegrationTest.java
Show resolved
Hide resolved
...rationTest/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartAResourceIntegrationTest.java
Show resolved
Hide resolved
… 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
8ef972a to
e5e7867
Compare
|
|
|
||
| Optional<FormRPartADto> formRPartADto = service.getAdminsFormRPartAById(id); | ||
|
|
||
| formRPartADto.ifPresent(dto -> |
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.
As per #782 (comment)
src/main/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartBResource.java
Show resolved
Hide resolved
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAServiceTest.java
Show resolved
Hide resolved
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAServiceTest.java
Show resolved
Hide resolved
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAServiceTest.java
Show resolved
Hide resolved
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartAServiceTest.java
Show resolved
Hide resolved
| } | ||
|
|
||
| @Test | ||
| void shouldGetAdminsFormRPartAByIdWhenSubmitted() { |
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.
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) { |
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.
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.
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBServiceTest.java
Show resolved
Hide resolved
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBServiceTest.java
Show resolved
Hide resolved
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBServiceTest.java
Show resolved
Hide resolved
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBServiceTest.java
Show resolved
Hide resolved
src/test/java/uk/nhs/hee/tis/trainee/forms/service/FormRPartBServiceTest.java
Show resolved
Hide resolved
...rationTest/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartAResourceIntegrationTest.java
Show resolved
Hide resolved
...rationTest/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartAResourceIntegrationTest.java
Show resolved
Hide resolved
...rationTest/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartAResourceIntegrationTest.java
Show resolved
Hide resolved
...rationTest/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartAResourceIntegrationTest.java
Show resolved
Hide resolved
| GET | /api/admin/formr-parta/{formId} | HEE Admin Sensitive | ||
| GET | /api/admin/formr-parta/{formId} | HEE TIS Admin | ||
| """) | ||
| void shouldReturnOkWhenRequiredFormFound(HttpMethod method, String uriTemplate, |
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.
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.
...rationTest/java/uk/nhs/hee/tis/trainee/forms/api/AdminFormRPartBResourceIntegrationTest.java
Show resolved
Hide resolved
|
Sorry @EdwardBarclay, lots of comments - the squash commit sent me back to review everything, you see 😁 😈 |



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