From 61a1d5671795c8e44aea63b430995b47af8c8081 Mon Sep 17 00:00:00 2001 From: sbriat Date: Wed, 6 Sep 2023 16:54:53 +0200 Subject: [PATCH] fix tests --- .../queries/match/match.query-handler.ts | 4 +- .../selector/passenger-oriented.selector.ts | 1 + .../core/application/types/algorithm.types.ts | 7 +++ .../passenger-oriented-geo-filter.spec.ts | 44 +++++++++++++++++++ ...enger-oriented-waypoints-completer.spec.ts | 44 +++++++++++++++++++ 5 files changed, 98 insertions(+), 2 deletions(-) diff --git a/src/modules/ad/core/application/queries/match/match.query-handler.ts b/src/modules/ad/core/application/queries/match/match.query-handler.ts index 7aa5770..7510a5f 100644 --- a/src/modules/ad/core/application/queries/match/match.query-handler.ts +++ b/src/modules/ad/core/application/queries/match/match.query-handler.ts @@ -28,7 +28,7 @@ export class MatchQueryHandler implements IQueryHandler { @Inject(INPUT_DATETIME_TRANSFORMER) private readonly datetimeTransformer: DateTimeTransformerPort, @Inject(AD_CARPOOL_ROUTE_PROVIDER) - private readonly routeProvider: CarpoolRouteProviderPort, + private readonly carpoolRouteProvider: CarpoolRouteProviderPort, ) { this._defaultParams = defaultParamsProvider.getParams(); } @@ -54,7 +54,7 @@ export class MatchQueryHandler implements IQueryHandler { maxDetourDurationRatio: this._defaultParams.MAX_DETOUR_DURATION_RATIO, }) .setDatesAndSchedule(this.datetimeTransformer); - await query.setCarpoolRoute(this.routeProvider); + await query.setCarpoolRoute(this.carpoolRouteProvider); let algorithm: Algorithm; switch (query.algorithmType) { diff --git a/src/modules/ad/core/application/queries/match/selector/passenger-oriented.selector.ts b/src/modules/ad/core/application/queries/match/selector/passenger-oriented.selector.ts index 70f3cf0..fe9e67b 100644 --- a/src/modules/ad/core/application/queries/match/selector/passenger-oriented.selector.ts +++ b/src/modules/ad/core/application/queries/match/selector/passenger-oriented.selector.ts @@ -39,6 +39,7 @@ export class PassengerOrientedSelector extends Selector { id: adReadModel.uuid, }, role: adsRole.role, + baseCarpoolRoute: this.query.carpoolRoute, }, ), ) diff --git a/src/modules/ad/core/application/types/algorithm.types.ts b/src/modules/ad/core/application/types/algorithm.types.ts index a3e75a8..83cc2aa 100644 --- a/src/modules/ad/core/application/types/algorithm.types.ts +++ b/src/modules/ad/core/application/types/algorithm.types.ts @@ -1,12 +1,19 @@ import { Role } from '../../domain/ad.types'; +import { CarpoolRoute } from './carpool-route.type'; export enum AlgorithmType { PASSENGER_ORIENTED = 'PASSENGER_ORIENTED', } +/** + * A candidate is a potential match + */ export type Candidate = { ad: Ad; role: Role; + baseCarpoolRoute: CarpoolRoute; + // driverRoute?: Route; ? + // crewRoute?: Route; ? }; export type Ad = { diff --git a/src/modules/ad/tests/unit/core/passenger-oriented-geo-filter.spec.ts b/src/modules/ad/tests/unit/core/passenger-oriented-geo-filter.spec.ts index 6d58d08..9d34a9f 100644 --- a/src/modules/ad/tests/unit/core/passenger-oriented-geo-filter.spec.ts +++ b/src/modules/ad/tests/unit/core/passenger-oriented-geo-filter.spec.ts @@ -48,12 +48,56 @@ const candidates: Candidate[] = [ id: 'cc260669-1c6d-441f-80a5-19cd59afb777', }, role: Role.DRIVER, + baseCarpoolRoute: { + driverDistance: 350101, + driverDuration: 14422, + passengerDistance: 350101, + passengerDuration: 14422, + fwdAzimuth: 273, + backAzimuth: 93, + points: [ + { + lon: 6.1765102, + lat: 48.689445, + }, + { + lon: 4.984578, + lat: 48.725687, + }, + { + lon: 2.3522, + lat: 48.8566, + }, + ], + }, }, { ad: { id: '5600ccfb-ab69-4d03-aa30-0fbe84fcedc0', }, role: Role.PASSENGER, + baseCarpoolRoute: { + driverDistance: 350101, + driverDuration: 14422, + passengerDistance: 350101, + passengerDuration: 14422, + fwdAzimuth: 273, + backAzimuth: 93, + points: [ + { + lon: 6.1765102, + lat: 48.689445, + }, + { + lon: 4.984578, + lat: 48.725687, + }, + { + lon: 2.3522, + lat: 48.8566, + }, + ], + }, }, ]; diff --git a/src/modules/ad/tests/unit/core/passenger-oriented-waypoints-completer.spec.ts b/src/modules/ad/tests/unit/core/passenger-oriented-waypoints-completer.spec.ts index 097c89f..5ca81c3 100644 --- a/src/modules/ad/tests/unit/core/passenger-oriented-waypoints-completer.spec.ts +++ b/src/modules/ad/tests/unit/core/passenger-oriented-waypoints-completer.spec.ts @@ -48,12 +48,56 @@ const candidates: Candidate[] = [ id: 'cc260669-1c6d-441f-80a5-19cd59afb777', }, role: Role.DRIVER, + baseCarpoolRoute: { + driverDistance: 350101, + driverDuration: 14422, + passengerDistance: 350101, + passengerDuration: 14422, + fwdAzimuth: 273, + backAzimuth: 93, + points: [ + { + lon: 6.1765102, + lat: 48.689445, + }, + { + lon: 4.984578, + lat: 48.725687, + }, + { + lon: 2.3522, + lat: 48.8566, + }, + ], + }, }, { ad: { id: '5600ccfb-ab69-4d03-aa30-0fbe84fcedc0', }, role: Role.PASSENGER, + baseCarpoolRoute: { + driverDistance: 350101, + driverDuration: 14422, + passengerDistance: 350101, + passengerDuration: 14422, + fwdAzimuth: 273, + backAzimuth: 93, + points: [ + { + lon: 6.1765102, + lat: 48.689445, + }, + { + lon: 4.984578, + lat: 48.725687, + }, + { + lon: 2.3522, + lat: 48.8566, + }, + ], + }, }, ];