FINERACT-2293: update client address#6085
Conversation
| } | ||
|
|
||
| public CommandWrapperBuilder addClientAddress(final long clientId, final long addressTypeId) { | ||
| public CommandWrapperBuilder addClientAddress(final Long clientId, final Long addressTypeId) { |
There was a problem hiding this comment.
Why is this still here? CommandWrapperBuilder belongs to the legacy command processing... could you please explain why this is still relevant when we move those client commands to the new command processing?
| .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_HOOK") | ||
| .requestMatchers(API_MATCHER.matcher(HttpMethod.DELETE, "/api/*/hooks/*")) | ||
| .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "DELETE_HOOK") | ||
|
|
There was a problem hiding this comment.
Seems like a minor thing, but try to avoid inserting blocks of code like this in the middle of previous changes... like this authorization configuration list in SecurityConfig. Maybe it makes more sense for you to put the client definitions at this position in the file, but for Git this means that you are potentially creating conflict situations that are hard to resolve, especially when other devs are working in the same area (and they are).
Pro tip: just go to the last entry of those authorization definitions and insert your (client) related definitions after the last entry. This is much easier to resolve and a lot nicer to your fellow developers.
| @ConditionalOnMissingBean(value = AddressDomainService.class, ignored = AddressDomainServiceImpl.class) | ||
| public class AddressDomainServiceImpl implements AddressDomainService { | ||
|
|
||
| private final PlatformSecurityContext context; |
There was a problem hiding this comment.
Why do we still need this? The complete REST API is authentication protected... it makes pretty much no sense to double validate if a user is authenticated at this point. Please remove.
| @Override | ||
| @Transactional | ||
| public AddressCreateResponse create(final AddressCreateRequest request) { | ||
| context.authenticatedUser(); |
There was a problem hiding this comment.
See above comment about checking user authentication in business logic services. Keep in mind that removing this makes unit testing a ton easier.
| @Override | ||
| @Transactional | ||
| public AddressUpdateResponse update(final AddressUpdateRequest request) { | ||
| context.authenticatedUser(); |
There was a problem hiding this comment.
Remove all similar entries. See above comments.
| private final ClientRepositoryWrapper clientRepositoryWrapper; | ||
| private final AddressRepository addressRepository; | ||
| private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper; | ||
| private final AddressCommandFromApiJsonDeserializer fromApiJsonDeserializer; |
There was a problem hiding this comment.
We said no manual JSON de-/serialization? Why would we need this one here? Please make sure that we don't use this and find a solution that works out of the box with Jackson... and I don't mean that you use ObjectMapper or similar here... just plain Java POJOs, nothing else.
| } | ||
|
|
||
| @Override | ||
| public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) { |
There was a problem hiding this comment.
CommandProcessingResult belongs to the legacy command processing. Why is this still here when we migrate things to new command processing? In other words: a proper XXXResponse or XXXData POJO would be expected here.
| import org.mockito.junit.jupiter.MockitoExtension; | ||
|
|
||
| @ExtendWith(MockitoExtension.class) | ||
| class AddressCreateCommandHandlerTest { |
There was a problem hiding this comment.
Not sure if this adds a lot of value here (pretty much everything is a mock...), but let's leave it. I didn't define any specific unit testing strategy for the new command processing, because our main tests are the integration tests... and they cover the command handlers too.
| import org.mockito.junit.jupiter.MockitoExtension; | ||
|
|
||
| @ExtendWith(MockitoExtension.class) | ||
| class AddressUpdateCommandHandlerTest { |
There was a problem hiding this comment.
See previous comment on tests.
| @@ -265,14 +264,14 @@ public static PostClientsResponse createClient(final RequestSpecification reques | |||
| // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, | |||
| // org.apache.fineract.client.models.PostLoansLoanIdRequest) | |||
| @Deprecated(forRemoval = true) | |||
| public static PostClientClientIdAddressesResponse createClientAddress(final RequestSpecification requestSpec, | |||
| public static HashMap<String, Object> createClientAddress(final RequestSpecification requestSpec, | |||
There was a problem hiding this comment.
Why do we suddenly lose the type information here? This looks like a regression and indicates that OpenAPI doesn't have enough information available to determine the proper Java type... which then falls back on HashMap. We should fix this.
| .stateProvinceId(Long.valueOf(stateId)).isActive(addressIsActive); | ||
| PostClientClientIdAddressesResponse response = ClientHelper.createClientAddress(requestSpec, responseSpec, clientId.longValue(), | ||
| addressTypeId, request); | ||
| HashMap<String, Object> response = ClientHelper.createClientAddress(requestSpec, responseSpec, clientId.longValue(), addressTypeId, |
There was a problem hiding this comment.
See my previous comment on OpenAPI type information.
JIRA: https://issues.apache.org/jira/browse/FINERACT-2293
Migrates the update client address endpoint (PUT /v1/client/{clientId}/addresses)
from the legacy JsonCommand path to the new typed fineract-command framework.
Scope (PR 2 of 2 for FINERACT-2293)
(@BeanMapping(nullValuePropertyMappingStrategy = IGNORE) for clean null-skip)
AddressWritePlatformService
Depends on #6049 (PR 1 - create client address). This PR is currently based
on that branch. Once #6049 merge in develop, I will rebase this on develop and
force-push; that should reduce the diff to only the update-specific changes.
Pattern follows the merged template-module reference (#5851) and PR 1 (#6049).
Expected CI failure: run-api-backward-compatibility
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.