Sdk automation/configurationwebhooks balanceplatformwebhook tests#2017
Sdk automation/configurationwebhooks balanceplatformwebhook tests#2017poojah-adyen wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for recurring top-up configuration webhooks by adding several new model classes (such as TopUpConfigurationEventRequest and TopUpConfigurationUpdatedEventRequest) and updating ConfigurationWebhooksHandler with deserialization helpers. Additionally, Mandate date fields were updated to use OffsetDateTime, and discriminator mappings were registered for polymorphic deserialization. Feedback on the changes points out redundant and inefficient loops in ConfigurationWebhooksHandler that verify event types; since the type is already represented as an enum, these loops can be simplified to direct null checks to avoid unnecessary array cloning overhead.
| if (optionalTopUpConfigurationEventRequest.isPresent()) { | ||
| // verify event type | ||
| for (var value : TopUpConfigurationEventRequest.TypeEnum.values()) { | ||
| if (value.equals(optionalTopUpConfigurationEventRequest.get().getType())) { | ||
| // found matching event type | ||
| return optionalTopUpConfigurationEventRequest; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The loop verifying the event type is redundant. Since getType() returns a TopUpConfigurationEventRequest.TypeEnum, any non-null value is guaranteed to be a valid enum constant. Additionally, calling TypeEnum.values() clones the underlying array on every invocation, which introduces unnecessary memory allocation and garbage collection overhead. We can simplify this to a direct null check.
if (optionalTopUpConfigurationEventRequest.isPresent() && optionalTopUpConfigurationEventRequest.get().getType() != null) {
return optionalTopUpConfigurationEventRequest;
}| if (optionalTopUpConfigurationUpdatedEventRequest.isPresent()) { | ||
| // verify event type | ||
| for (var value : TopUpConfigurationUpdatedEventRequest.TypeEnum.values()) { | ||
| if (value.equals(optionalTopUpConfigurationUpdatedEventRequest.get().getType())) { | ||
| // found matching event type | ||
| return optionalTopUpConfigurationUpdatedEventRequest; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The loop verifying the event type is redundant. Since getType() returns a TopUpConfigurationUpdatedEventRequest.TypeEnum, any non-null value is guaranteed to be a valid enum constant. Additionally, calling TypeEnum.values() clones the underlying array on every invocation, which introduces unnecessary memory allocation and garbage collection overhead. We can simplify this to a direct null check.
if (optionalTopUpConfigurationUpdatedEventRequest.isPresent() && optionalTopUpConfigurationUpdatedEventRequest.get().getType() != null) {
return optionalTopUpConfigurationUpdatedEventRequest;
}
|



Description
Tested scenarios
Fixed issue: