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

INC-1147: Generically typed domain event #404

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ushkarev
Copy link
Contributor

@ushkarev ushkarev commented Apr 4, 2023

HMPPS domain events have a nullable field (additionalInformation) that can contain any old object, it depends on the event type. Right now, we model this field using a highly polymorphic class with nullable fields for every possible use. This prevents us from using strong typing to ensure correct fields are used in the correct places.

This PR is an attempt to make the domain event generic over this field.

I'm not totally convinced by this! Generics + Jackson deserialisation do not always play well together… and tests aren't properly stable (see 2 CI runs on identical commit hash).

assertThat(domainEvent.eventType).isEqualTo(eventType)

return domainEvent
}

protected fun getPublishedDomainEvents(): List<HMPPSDomainEvent> {
protected fun getPublishedDomainEvents(): List<HMPPSDomainEvent<Map<String, *>>> {
Copy link
Contributor Author

@ushkarev ushkarev Apr 4, 2023

Choose a reason for hiding this comment

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

Map<String, *> is an effective super set of IncentiveLevelRef and PrisonIncentiveLevelRef or any other non-null additional information structure

@ushkarev ushkarev force-pushed the generic-domain-event branch from 23814db to 961e051 Compare April 4, 2023 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant