Skip to content

Commit 9cdf7ed

Browse files
committed
Added solution for business processes
1 parent 3d476c9 commit 9cdf7ed

File tree

30 files changed

+432
-717
lines changed

30 files changed

+432
-717
lines changed

workshops/introduction_to_event_sourcing/src/17_business_processes/regular/solution1_aggregates/entityDefinitionTests.exercises.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,29 @@ import {
66
type EventStore,
77
type MessageCatcher,
88
} from '../../tools';
9-
import { GroupCheckoutFacade } from './groupCheckouts';
109
import {
11-
GuestStayFacade,
10+
GroupCheckoutFacade,
11+
type InitiateGroupCheckout,
12+
} from './groupCheckouts';
13+
import {
14+
GuestStayAccountFacade,
1215
type CheckInGuest,
1316
type CheckoutGuest,
14-
type InitiateGroupCheckout,
1517
type RecordCharge,
1618
type RecordPayment,
17-
} from './guestStayFacade';
19+
} from './guestStayAccounts';
1820

1921
describe('Entity Definition Tests', () => {
2022
let eventStore: EventStore;
2123
let publishedEvents: MessageCatcher;
22-
let guestStayFacade: GuestStayFacade;
24+
let guestStayFacade: GuestStayAccountFacade;
2325
let groupCheckoutFacade: GroupCheckoutFacade;
2426
let now: Date;
2527

2628
beforeEach(() => {
2729
eventStore = getEventStore();
2830
publishedEvents = getMessageCatcher();
29-
guestStayFacade = GuestStayFacade({ eventStore });
31+
guestStayFacade = GuestStayAccountFacade({ eventStore });
3032
groupCheckoutFacade = GroupCheckoutFacade({ eventStore });
3133
now = new Date();
3234
eventStore.use(publishedEvents.catchMessage);

workshops/introduction_to_event_sourcing/src/17_business_processes/regular/solution1_aggregates/guestStayFacade.ts

Lines changed: 0 additions & 174 deletions
This file was deleted.

workshops/introduction_to_event_sourcing/src/17_business_processes/regular/solution2_immutableEntities/entityDefinitionTests.exercises.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
import { faker } from '@faker-js/faker';
22
import { v4 as uuid } from 'uuid';
33
import {
4+
getCommandBus,
45
getEventStore,
56
getMessageCatcher,
7+
type CommandBus,
68
type EventStore,
79
type MessageCatcher,
810
} from '../../tools';
11+
import type { InitiateGroupCheckout } from './groupCheckouts';
912
import type {
1013
CheckInGuest,
1114
CheckoutGuest,
1215
RecordCharge,
1316
RecordPayment,
1417
} from './guestStayAccounts';
15-
import { GuestStayFacade, type InitiateGroupCheckout } from './guestStayFacade';
18+
import { GuestStayAccountFacade } from './guestStayAccounts';
1619

1720
describe('Entity Definition Tests', () => {
1821
let eventStore: EventStore;
22+
let commandBus: CommandBus;
1923
let publishedEvents: MessageCatcher;
20-
let guestStayFacade: ReturnType<typeof GuestStayFacade>;
24+
let guestStayFacade: GuestStayAccountFacade;
2125
let now: Date;
2226

2327
beforeEach(() => {
2428
eventStore = getEventStore();
29+
commandBus = getCommandBus();
2530
publishedEvents = getMessageCatcher();
26-
guestStayFacade = GuestStayFacade({ eventStore: eventStore });
31+
guestStayFacade = GuestStayAccountFacade({ eventStore, commandBus });
2732
now = new Date();
2833
eventStore.use(publishedEvents.catchMessage);
2934
});

workshops/introduction_to_event_sourcing/src/17_business_processes/regular/solution2_immutableEntities/guestStayFacade.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

workshops/introduction_to_event_sourcing/src/solved/16_processes_entities_definition/regular/solution1_aggregates/entityDefinitionTests.solved.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Entity Definition Tests', () => {
2424
beforeEach(() => {
2525
eventStore = getEventStore();
2626
publishedEvents = getEventCatcher();
27-
guestStayFacade = GuestStayFacade({ eventBus: eventStore });
27+
guestStayFacade = GuestStayFacade({ eventStore: eventStore });
2828
now = new Date();
2929
eventStore.use(publishedEvents.catchMessage);
3030
});

workshops/introduction_to_event_sourcing/src/solved/16_processes_entities_definition/regular/solution1_aggregates/guestStayFacade.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ export type GroupCheckoutCommand =
8282
| RecordGuestCheckoutCompletion
8383
| RecordGuestCheckoutFailure;
8484

85-
export const GuestStayFacade = (options: { eventBus: EventStore }) => {
86-
const { eventBus: eventStore } = options;
85+
export const GuestStayFacade = (options: { eventStore: EventStore }) => {
86+
const { eventStore: eventStore } = options;
8787

8888
const aggregateOptions = {
8989
evolve: (state: GuestStayAccount | null, event: GuestStayAccountEvent) => {

0 commit comments

Comments
 (0)