From 579415c3005e09e4a5acf05ed6892916156c0f4f Mon Sep 17 00:00:00 2001 From: Romain Thouvenin Date: Tue, 19 Mar 2024 08:03:50 +0100 Subject: [PATCH] Rename GeorouterProvider[Port] to Georouter[Port] --- src/modules/ad/ad.module.ts | 4 ++-- .../application/commands/create-ad/create-ad.service.ts | 4 ++-- .../ports/{georouter-provider.port.ts => georouter.port.ts} | 2 +- .../application/queries/match/completer/route.completer.ts | 2 +- .../ad/core/application/queries/match/match.query.ts | 6 +++--- .../infrastructure/{georouter-provider.ts => georouter.ts} | 6 +++--- .../ad/interface/grpc-controllers/match.grpc-controller.ts | 4 ++-- src/modules/ad/tests/unit/core/create-ad.service.spec.ts | 4 ++-- src/modules/ad/tests/unit/core/match.query.spec.ts | 4 ++-- src/modules/ad/tests/unit/core/route.completer.spec.ts | 2 +- src/modules/ad/tests/unit/georouter.mock.ts | 6 +++--- 11 files changed, 22 insertions(+), 22 deletions(-) rename src/modules/ad/core/application/ports/{georouter-provider.port.ts => georouter.port.ts} (92%) rename src/modules/ad/infrastructure/{georouter-provider.ts => georouter.ts} (84%) diff --git a/src/modules/ad/ad.module.ts b/src/modules/ad/ad.module.ts index 5de16d4..03c760b 100644 --- a/src/modules/ad/ad.module.ts +++ b/src/modules/ad/ad.module.ts @@ -40,7 +40,7 @@ import { } from '@songkeys/nestjs-redis'; import { ConfigurationRepository } from '@mobicoop/configuration-module'; import { PublishMessageWhenMatcherAdIsCreatedDomainEventHandler } from './core/application/event-handlers/publish-message-when-matcher-ad-is-created.domain-event-handler'; -import { GeorouterProvider } from './infrastructure/georouter-provider'; +import { Georouter } from './infrastructure/georouter'; import { ClientsModule, Transport } from '@nestjs/microservices'; import { GRPC_GEOGRAPHY_PACKAGE_NAME } from '@src/app.constants'; import { join } from 'path'; @@ -139,7 +139,7 @@ const adapters: Provider[] = [ }, { provide: AD_ROUTE_PROVIDER, - useClass: GeorouterProvider, + useClass: Georouter, }, { provide: TIMEZONE_FINDER, diff --git a/src/modules/ad/core/application/commands/create-ad/create-ad.service.ts b/src/modules/ad/core/application/commands/create-ad/create-ad.service.ts index ebe2031..4158100 100644 --- a/src/modules/ad/core/application/commands/create-ad/create-ad.service.ts +++ b/src/modules/ad/core/application/commands/create-ad/create-ad.service.ts @@ -26,7 +26,7 @@ import { Point as PointValueObject } from '@modules/ad/core/domain/value-objects import { Point } from '@modules/geography/core/domain/route.types'; import { MatcherAdCreationFailedIntegrationEvent } from '../../events/matcher-ad-creation-failed.integration-event'; import { MATCHER_AD_CREATION_FAILED_ROUTING_KEY } from '@src/app.constants'; -import { GeorouterProviderPort } from '../../ports/georouter-provider.port'; +import { GeorouterPort } from '../../ports/georouter.port'; @CommandHandler(CreateAdCommand) export class CreateAdService implements ICommandHandler { @@ -36,7 +36,7 @@ export class CreateAdService implements ICommandHandler { @Inject(AD_REPOSITORY) private readonly repository: AdRepositoryPort, @Inject(AD_ROUTE_PROVIDER) - private readonly routeProvider: GeorouterProviderPort, + private readonly routeProvider: GeorouterPort, ) {} async execute(command: CreateAdCommand): Promise { diff --git a/src/modules/ad/core/application/ports/georouter-provider.port.ts b/src/modules/ad/core/application/ports/georouter.port.ts similarity index 92% rename from src/modules/ad/core/application/ports/georouter-provider.port.ts rename to src/modules/ad/core/application/ports/georouter.port.ts index d43a510..752e843 100644 --- a/src/modules/ad/core/application/ports/georouter-provider.port.ts +++ b/src/modules/ad/core/application/ports/georouter.port.ts @@ -26,6 +26,6 @@ export type RouteResponse = { }; @Injectable() -export abstract class GeorouterProviderPort { +export abstract class GeorouterPort { abstract getRoute(request: RouteRequest): Promise; } diff --git a/src/modules/ad/core/application/queries/match/completer/route.completer.ts b/src/modules/ad/core/application/queries/match/completer/route.completer.ts index 8bf28b8..aca1a73 100644 --- a/src/modules/ad/core/application/queries/match/completer/route.completer.ts +++ b/src/modules/ad/core/application/queries/match/completer/route.completer.ts @@ -3,7 +3,7 @@ import { Completer } from './completer.abstract'; import { MatchQuery } from '../match.query'; import { Step } from '../../../types/step.type'; import { CarpoolPathItem } from '@modules/ad/core/domain/value-objects/carpool-path-item.value-object'; -import { RouteResponse } from '../../../ports/georouter-provider.port'; +import { RouteResponse } from '../../../ports/georouter.port'; export class RouteCompleter extends Completer { protected readonly type: RouteCompleterType; diff --git a/src/modules/ad/core/application/queries/match/match.query.ts b/src/modules/ad/core/application/queries/match/match.query.ts index 1958c45..f671550 100644 --- a/src/modules/ad/core/application/queries/match/match.query.ts +++ b/src/modules/ad/core/application/queries/match/match.query.ts @@ -12,7 +12,7 @@ import { } from '@modules/ad/core/domain/path-creator.service'; import { Point } from '@modules/ad/core/domain/value-objects/point.value-object'; import { Route } from '../../types/route.type'; -import { GeorouterProviderPort } from '../../ports/georouter-provider.port'; +import { GeorouterPort } from '../../ports/georouter.port'; export class MatchQuery extends QueryBase { id?: string; @@ -40,10 +40,10 @@ export class MatchQuery extends QueryBase { passengerRoute?: Route; backAzimuth?: number; private readonly originWaypoint: Waypoint; - routeProvider: GeorouterProviderPort; + routeProvider: GeorouterPort; // TODO: remove MatchRequestDto depency (here core domain depends on interface /!\) - constructor(props: MatchRequestDto, routeProvider: GeorouterProviderPort) { + constructor(props: MatchRequestDto, routeProvider: GeorouterPort) { super(); this.id = props.id; this.driver = props.driver; diff --git a/src/modules/ad/infrastructure/georouter-provider.ts b/src/modules/ad/infrastructure/georouter.ts similarity index 84% rename from src/modules/ad/infrastructure/georouter-provider.ts rename to src/modules/ad/infrastructure/georouter.ts index 4e68605..1280791 100644 --- a/src/modules/ad/infrastructure/georouter-provider.ts +++ b/src/modules/ad/infrastructure/georouter.ts @@ -3,10 +3,10 @@ import { Inject, Injectable, OnModuleInit } from '@nestjs/common'; import { ClientGrpc } from '@nestjs/microservices'; import { GRPC_GEOROUTER_SERVICE_NAME } from '@src/app.constants'; import { - GeorouterProviderPort, + GeorouterPort, RouteRequest, RouteResponse, -} from '../core/application/ports/georouter-provider.port'; +} from '../core/application/ports/georouter.port'; import { GEOGRAPHY_PACKAGE } from '../ad.di-tokens'; interface GeorouterService { @@ -14,7 +14,7 @@ interface GeorouterService { } @Injectable() -export class GeorouterProvider implements GeorouterProviderPort, OnModuleInit { +export class Georouter implements GeorouterPort, OnModuleInit { private georouterService: GeorouterService; constructor(@Inject(GEOGRAPHY_PACKAGE) private readonly client: ClientGrpc) {} diff --git a/src/modules/ad/interface/grpc-controllers/match.grpc-controller.ts b/src/modules/ad/interface/grpc-controllers/match.grpc-controller.ts index 2ccbab6..30acfda 100644 --- a/src/modules/ad/interface/grpc-controllers/match.grpc-controller.ts +++ b/src/modules/ad/interface/grpc-controllers/match.grpc-controller.ts @@ -11,7 +11,7 @@ import { AD_ROUTE_PROVIDER } from '@modules/ad/ad.di-tokens'; import { MatchMapper } from '@modules/ad/match.mapper'; import { MatchingResult } from '@modules/ad/core/application/queries/match/match.query-handler'; import { CacheInterceptor, CacheKey } from '@nestjs/cache-manager'; -import { GeorouterProviderPort } from '@modules/ad/core/application/ports/georouter-provider.port'; +import { GeorouterPort } from '@modules/ad/core/application/ports/georouter.port'; @UsePipes( new RpcValidationPipe({ @@ -24,7 +24,7 @@ export class MatchGrpcController { constructor( private readonly queryBus: QueryBus, @Inject(AD_ROUTE_PROVIDER) - private readonly routeProvider: GeorouterProviderPort, + private readonly routeProvider: GeorouterPort, private readonly matchMapper: MatchMapper, ) {} diff --git a/src/modules/ad/tests/unit/core/create-ad.service.spec.ts b/src/modules/ad/tests/unit/core/create-ad.service.spec.ts index 9886287..626dc71 100644 --- a/src/modules/ad/tests/unit/core/create-ad.service.spec.ts +++ b/src/modules/ad/tests/unit/core/create-ad.service.spec.ts @@ -12,7 +12,7 @@ import { CreateAdService } from '@modules/ad/core/application/commands/create-ad import { CreateAdCommand } from '@modules/ad/core/application/commands/create-ad/create-ad.command'; import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors'; import { PointProps } from '@modules/ad/core/domain/value-objects/point.value-object'; -import { GeorouterProviderPort } from '@modules/ad/core/application/ports/georouter-provider.port'; +import { GeorouterPort } from '@modules/ad/core/application/ports/georouter.port'; const originWaypoint: PointProps = { lat: 48.689445, @@ -62,7 +62,7 @@ const mockAdRepository = { }), }; -const mockRouteProvider: GeorouterProviderPort = { +const mockRouteProvider: GeorouterPort = { getRoute: jest .fn() .mockImplementationOnce(() => { diff --git a/src/modules/ad/tests/unit/core/match.query.spec.ts b/src/modules/ad/tests/unit/core/match.query.spec.ts index 3d5c0ce..f88aad0 100644 --- a/src/modules/ad/tests/unit/core/match.query.spec.ts +++ b/src/modules/ad/tests/unit/core/match.query.spec.ts @@ -1,5 +1,5 @@ import { DateTimeTransformerPort } from '@modules/ad/core/application/ports/datetime-transformer.port'; -import { GeorouterProviderPort } from '@modules/ad/core/application/ports/georouter-provider.port'; +import { GeorouterPort } from '@modules/ad/core/application/ports/georouter.port'; import { MatchQuery } from '@modules/ad/core/application/queries/match/match.query'; import { AlgorithmType } from '@modules/ad/core/application/types/algorithm.types'; import { Waypoint } from '@modules/ad/core/application/types/waypoint.type'; @@ -58,7 +58,7 @@ const mockInputDateTimeTransformer: DateTimeTransformerPort = { time: jest.fn().mockImplementation(() => '23:05'), }; -const mockRouteProvider: GeorouterProviderPort = { +const mockRouteProvider: GeorouterPort = { getRoute: jest .fn() .mockImplementationOnce(simpleMockGeorouter.getRoute) diff --git a/src/modules/ad/tests/unit/core/route.completer.spec.ts b/src/modules/ad/tests/unit/core/route.completer.spec.ts index 6d3f433..3e536f9 100644 --- a/src/modules/ad/tests/unit/core/route.completer.spec.ts +++ b/src/modules/ad/tests/unit/core/route.completer.spec.ts @@ -1,7 +1,7 @@ import { RouteRequest, RouteResponse, -} from '@modules/ad/core/application/ports/georouter-provider.port'; +} from '@modules/ad/core/application/ports/georouter.port'; import { RouteCompleter, RouteCompleterType, diff --git a/src/modules/ad/tests/unit/georouter.mock.ts b/src/modules/ad/tests/unit/georouter.mock.ts index 33b942a..75332c9 100644 --- a/src/modules/ad/tests/unit/georouter.mock.ts +++ b/src/modules/ad/tests/unit/georouter.mock.ts @@ -1,10 +1,10 @@ -import { GeorouterProviderPort } from '@modules/ad/core/application/ports/georouter-provider.port'; +import { GeorouterPort } from '@modules/ad/core/application/ports/georouter.port'; -export const bareMockGeorouter: GeorouterProviderPort = { +export const bareMockGeorouter: GeorouterPort = { getRoute: jest.fn(), }; -export const simpleMockGeorouter: GeorouterProviderPort = { +export const simpleMockGeorouter: GeorouterPort = { getRoute: jest.fn().mockImplementation(() => ({ distance: 350101, duration: 14422,