clean constants
This commit is contained in:
parent
ac807bd5e5
commit
b4c8a5c851
|
@ -5,6 +5,9 @@ export const SERVICE_NAME = 'ad';
|
|||
export const GRPC_PACKAGE_NAME = 'ad';
|
||||
export const GRPC_SERVICE_NAME = 'AdService';
|
||||
|
||||
// messaging
|
||||
export const AD_CREATED_ROUTING_KEY = 'ad.created';
|
||||
|
||||
// configuration
|
||||
export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set';
|
||||
export const SERVICE_CONFIGURATION_DELETE_QUEUE = 'ad-configuration-delete';
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export const MESSAGER_AD_CREATED_ROUTING_KEY = 'ad.created';
|
|
@ -3,7 +3,7 @@ import { OnEvent } from '@nestjs/event-emitter';
|
|||
import { AdCreatedDomainEvent } from '../../domain/events/ad-created.domain-events';
|
||||
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
||||
import { AD_MESSAGE_PUBLISHER } from '@modules/ad/ad.di-tokens';
|
||||
import { MESSAGER_AD_CREATED_ROUTING_KEY } from '@modules/ad/ad.constants';
|
||||
import { AD_CREATED_ROUTING_KEY } from '@src/app.constants';
|
||||
|
||||
@Injectable()
|
||||
export class PublishMessageWhenAdIsCreatedDomainEventHandler {
|
||||
|
@ -15,7 +15,7 @@ export class PublishMessageWhenAdIsCreatedDomainEventHandler {
|
|||
@OnEvent(AdCreatedDomainEvent.name, { async: true, promisify: true })
|
||||
async handle(event: AdCreatedDomainEvent): Promise<any> {
|
||||
this.messagePublisher.publish(
|
||||
MESSAGER_AD_CREATED_ROUTING_KEY,
|
||||
AD_CREATED_ROUTING_KEY,
|
||||
JSON.stringify(event),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { PublishMessageWhenAdIsCreatedDomainEventHandler } from '@modules/ad/cor
|
|||
import { AdCreatedDomainEvent } from '@modules/ad/core/domain/events/ad-created.domain-events';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AD_MESSAGE_PUBLISHER } from '@modules/ad/ad.di-tokens';
|
||||
import { MESSAGER_AD_CREATED_ROUTING_KEY } from '@modules/ad/ad.constants';
|
||||
import { AD_CREATED_ROUTING_KEY } from '@src/app.constants';
|
||||
|
||||
const mockMessagePublisher = {
|
||||
publish: jest.fn().mockImplementation(),
|
||||
|
@ -81,7 +81,7 @@ describe('Publish message when ad is created domain event handler', () => {
|
|||
expect(publishMessageWhenAdIsCreatedDomainEventHandler).toBeDefined();
|
||||
expect(mockMessagePublisher.publish).toHaveBeenCalledTimes(1);
|
||||
expect(mockMessagePublisher.publish).toHaveBeenCalledWith(
|
||||
MESSAGER_AD_CREATED_ROUTING_KEY,
|
||||
AD_CREATED_ROUTING_KEY,
|
||||
'{"id":"some-domain-event-id","aggregateId":"some-aggregate-id","userId":"some-user-id","driver":false,"passenger":true,"frequency":"PUNCTUAL","fromDate":"2023-06-28","toDate":"2023-06-28","schedule":[{"day":3,"time":"07:15","margin":900}],"seatsProposed":3,"seatsRequested":1,"strict":false,"waypoints":[{"position":0,"houseNumber":"5","street":"Avenue Foch","locality":"Nancy","postalCode":"54000","country":"France","lat":48.689445,"lon":6.1765102},{"position":1,"locality":"Paris","postalCode":"75000","country":"France","lat":48.8566,"lon":2.3522}],"metadata":{"timestamp":1687928400000,"correlationId":"some-correlation-id"}}',
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue