diff --git a/src/modules/ad/adapters/primaries/ad-messager.controller.ts b/src/modules/ad/adapters/primaries/ad-messager.controller.ts index 5a09dd4..24bef87 100644 --- a/src/modules/ad/adapters/primaries/ad-messager.controller.ts +++ b/src/modules/ad/adapters/primaries/ad-messager.controller.ts @@ -5,28 +5,44 @@ import { InjectMapper } from '@automapper/nestjs'; import { Mapper } from '@automapper/core'; import { CommandBus } from '@nestjs/cqrs'; import { CreateAdCommand } from '../../commands/create-ad.command'; -import { AdPresenter } from './ad.presenter'; import { CreateAdRequest } from '../../domain/dtos/create-ad.request'; +import { ValidationError, validateOrReject } from 'class-validator'; @Controller() export class AdMessagerController { constructor( - private readonly _commandBus: CommandBus, - @InjectMapper() private readonly _mapper: Mapper, + private readonly commandBus: CommandBus, + @InjectMapper() private readonly mapper: Mapper, ) {} @RabbitSubscribe({ name: 'adCreated', }) - async adCreatedHandler(message: string): Promise { + async adCreatedHandler(message: string): Promise { try { - const createAdRequest: CreateAdRequest = JSON.parse(message); - const ad: Ad = await this._commandBus.execute( + // parse message to conform to CreateAdRequest (not a real instance yet) + const parsedMessage: CreateAdRequest = JSON.parse(message); + // create a real instance of CreateAdRequest from parsed message + const createAdRequest: CreateAdRequest = this.mapper.map( + parsedMessage, + CreateAdRequest, + CreateAdRequest, + ); + console.log(createAdRequest); + // validate instance + await validateOrReject(createAdRequest); + const ad: Ad = await this.commandBus.execute( new CreateAdCommand(createAdRequest), ); - return this._mapper.map(ad, Ad, AdPresenter); + console.log(ad); } catch (e) { - console.log('error', e); + if (Array.isArray(e)) { + e.forEach((error) => + error instanceof ValidationError + ? console.log(error.constraints) + : console.log(error), + ); + } } } } diff --git a/src/modules/ad/domain/dtos/create-ad.request.ts b/src/modules/ad/domain/dtos/create-ad.request.ts index 1b0e230..dd4ea53 100644 --- a/src/modules/ad/domain/dtos/create-ad.request.ts +++ b/src/modules/ad/domain/dtos/create-ad.request.ts @@ -1,5 +1,18 @@ import { AutoMap } from '@automapper/classes'; -import { IsBoolean, IsNotEmpty, IsNumber, IsString } from 'class-validator'; +import { + ArrayMinSize, + IsArray, + IsBoolean, + IsEnum, + IsNotEmpty, + IsNumber, + IsOptional, + IsString, + ValidateNested, +} from 'class-validator'; +import { PointType } from '../../../geography/domain/types/point-type.enum'; +import { Frequency } from '../types/frequency.enum'; +import { Point } from '../../../geography/domain/types/point.type'; export class CreateAdRequest { @IsString() @@ -15,9 +28,10 @@ export class CreateAdRequest { @AutoMap() passenger: boolean; - @IsNumber() + @IsNotEmpty() + @IsEnum(Frequency) @AutoMap() - frequency: number; + frequency: Frequency; @IsString() @AutoMap() @@ -27,33 +41,40 @@ export class CreateAdRequest { @AutoMap() toDate: string; + @IsOptional() @IsString() @AutoMap() - monTime: string; + monTime: string | null; + @IsOptional() @IsString() @AutoMap() - tueTime: string; + tueTime: string | null; + @IsOptional() @IsString() @AutoMap() - wedTime: string; + wedTime: string | null; + @IsOptional() @IsString() @AutoMap() - thuTime: string; + thuTime!: string | null; + @IsOptional() @IsString() @AutoMap() - friTime: string; + friTime: string | null; + @IsOptional() @IsString() @AutoMap() - satTime: string; + satTime: string | null; + @IsOptional() @IsString() @AutoMap() - sunTime: string; + sunTime: string | null; @IsNumber() @AutoMap() @@ -83,16 +104,19 @@ export class CreateAdRequest { @AutoMap() sunMargin: number; - @IsNumber() + @IsEnum(PointType) @AutoMap() - originType: number; + originType: PointType; - @IsNumber() + @IsEnum(PointType) @AutoMap() - destinationType: number; + destinationType: PointType; + @IsArray() + @ArrayMinSize(2) + @ValidateNested({ each: true }) @AutoMap() - waypoints: []; + waypoints: Array; @IsNumber() @AutoMap() @@ -102,6 +126,7 @@ export class CreateAdRequest { @AutoMap() seatsPassenger: number; + @IsOptional() @IsNumber() @AutoMap() seatsUsed: number; diff --git a/src/modules/ad/domain/entities/ad.ts b/src/modules/ad/domain/entities/ad.ts index e8998ec..817738e 100644 --- a/src/modules/ad/domain/entities/ad.ts +++ b/src/modules/ad/domain/entities/ad.ts @@ -1,4 +1,7 @@ import { AutoMap } from '@automapper/classes'; +import { ArrayMinSize, IsArray, IsEnum, ValidateNested } from 'class-validator'; +import { PointType } from '../../../geography/domain/types/point-type.enum'; +import { Point } from '../../../geography/domain/types/point.type'; export class Ad { @AutoMap() @@ -14,10 +17,10 @@ export class Ad { frequency: number; @AutoMap() - fromDate: string; + fromDate: Date; @AutoMap() - toDate: string; + toDate: Date; @AutoMap() monTime: string; @@ -73,14 +76,19 @@ export class Ad { @AutoMap() passengerDistance: number; + @IsEnum(PointType) @AutoMap() - originType: number; + originType: PointType; + @IsEnum(PointType) @AutoMap() - destinationType: number; + destinationType: PointType; + @IsArray() + @ArrayMinSize(2) + @ValidateNested({ each: true }) @AutoMap() - waypoints: []; + waypoints: Array; @AutoMap() direction: string; @@ -101,8 +109,8 @@ export class Ad { seatsUsed: number; @AutoMap() - createdAt: string; + createdAt: Date; @AutoMap() - updatedAt: string; + updatedAt: Date; } diff --git a/src/modules/ad/domain/types/frequency.enum.ts b/src/modules/ad/domain/types/frequency.enum.ts new file mode 100644 index 0000000..ec435e8 --- /dev/null +++ b/src/modules/ad/domain/types/frequency.enum.ts @@ -0,0 +1,4 @@ +export enum Frequency { + PUNCTUAL = 1, + RECURRENT = 2, +} diff --git a/src/modules/ad/domain/usecases/create-ad.usecase.ts b/src/modules/ad/domain/usecases/create-ad.usecase.ts index b9b3b9e..d85bf81 100644 --- a/src/modules/ad/domain/usecases/create-ad.usecase.ts +++ b/src/modules/ad/domain/usecases/create-ad.usecase.ts @@ -2,14 +2,26 @@ import { CommandHandler } from '@nestjs/cqrs'; import { CreateAdCommand } from '../../commands/create-ad.command'; import { Ad } from '../entities/ad'; import { AdRepository } from '../../adapters/secondaries/ad.repository'; +import { InjectMapper } from '@automapper/nestjs'; +import { Mapper } from '@automapper/core'; +import { CreateAdRequest } from '../dtos/create-ad.request'; @CommandHandler(CreateAdCommand) export class CreateAdUseCase { - constructor(private readonly adRepository: AdRepository) {} + constructor( + @InjectMapper() private readonly mapper: Mapper, + private readonly adRepository: AdRepository, + ) {} async execute(command: CreateAdCommand): Promise { try { - return await this.adRepository.createAd(command.createAdRequest); + const adToCreate: Ad = this.mapper.map( + command.createAdRequest, + CreateAdRequest, + Ad, + ); + return adToCreate; + // return await this.adRepository.createAd(adToCreate); } catch (error) { throw error; } diff --git a/src/modules/ad/mappers/ad.profile.ts b/src/modules/ad/mappers/ad.profile.ts index 289adbc..09a247f 100644 --- a/src/modules/ad/mappers/ad.profile.ts +++ b/src/modules/ad/mappers/ad.profile.ts @@ -1,8 +1,9 @@ -import { createMap, Mapper } from '@automapper/core'; +import { createMap, forMember, mapFrom, Mapper } from '@automapper/core'; import { AutomapperProfile, InjectMapper } from '@automapper/nestjs'; import { Injectable } from '@nestjs/common'; import { Ad } from '../domain/entities/ad'; import { AdPresenter } from '../adapters/primaries/ad.presenter'; +import { CreateAdRequest } from '../domain/dtos/create-ad.request'; @Injectable() export class AdProfile extends AutomapperProfile { @@ -13,6 +14,28 @@ export class AdProfile extends AutomapperProfile { override get profile() { return (mapper: any) => { createMap(mapper, Ad, AdPresenter); + createMap(mapper, CreateAdRequest, CreateAdRequest); + createMap( + mapper, + CreateAdRequest, + Ad, + forMember( + (dest) => dest.fromDate, + mapFrom((source) => new Date(source.fromDate)), + ), + forMember( + (dest) => dest.toDate, + mapFrom((source) => new Date(source.toDate)), + ), + forMember( + (dest) => dest.createdAt, + mapFrom((source) => new Date(source.createdAt)), + ), + forMember( + (dest) => dest.updatedAt, + mapFrom((source) => new Date(source.updatedAt)), + ), + ); }; } } diff --git a/src/modules/geography/domain/types/coordinates.type.ts b/src/modules/geography/domain/types/coordinates.type.ts new file mode 100644 index 0000000..8e149ed --- /dev/null +++ b/src/modules/geography/domain/types/coordinates.type.ts @@ -0,0 +1,4 @@ +export type Coordinates = { + lon: number; + lat: number; +}; diff --git a/src/modules/matcher/domain/types/geography.enum.ts b/src/modules/geography/domain/types/point-type.enum.ts similarity index 100% rename from src/modules/matcher/domain/types/geography.enum.ts rename to src/modules/geography/domain/types/point-type.enum.ts diff --git a/src/modules/geography/domain/types/point.type.ts b/src/modules/geography/domain/types/point.type.ts new file mode 100644 index 0000000..9285d70 --- /dev/null +++ b/src/modules/geography/domain/types/point.type.ts @@ -0,0 +1,6 @@ +import { PointType } from './point-type.enum'; +import { Coordinates } from './coordinates.type'; + +export type Point = Coordinates & { + type?: PointType; +}; diff --git a/src/modules/matcher/adapters/secondaries/graphhopper-georouter.ts b/src/modules/matcher/adapters/secondaries/graphhopper-georouter.ts index 9d85e85..2475a43 100644 --- a/src/modules/matcher/adapters/secondaries/graphhopper-georouter.ts +++ b/src/modules/matcher/adapters/secondaries/graphhopper-georouter.ts @@ -154,7 +154,7 @@ export class GraphhopperGeorouter implements IGeorouter { return indices.map( (index) => new SpacetimePoint( - points[index], + { lon: points[index][1], lat: points[index][0] }, times.find((time) => time.index == index)?.duration, distances.find((distance) => distance.index == index)?.distance, ), diff --git a/src/modules/matcher/domain/dtos/match.request.ts b/src/modules/matcher/domain/dtos/match.request.ts index 4cb1ff2..0ce4127 100644 --- a/src/modules/matcher/domain/dtos/match.request.ts +++ b/src/modules/matcher/domain/dtos/match.request.ts @@ -10,7 +10,7 @@ import { Min, } from 'class-validator'; import { AutoMap } from '@automapper/classes'; -import { Point } from '../types/point.type'; +import { Point } from '../../../geography/domain/types/point.type'; import { Schedule } from '../types/schedule.type'; import { MarginDurations } from '../types/margin-durations.type'; import { AlgorithmType } from '../types/algorithm.enum'; diff --git a/src/modules/matcher/domain/entities/ecosystem/algorithm-settings.ts b/src/modules/matcher/domain/entities/ecosystem/algorithm-settings.ts index a6d4963..158ddfd 100644 --- a/src/modules/matcher/domain/entities/ecosystem/algorithm-settings.ts +++ b/src/modules/matcher/domain/entities/ecosystem/algorithm-settings.ts @@ -1,15 +1,15 @@ import { IRequestAlgorithmSettings } from '../../interfaces/algorithm-settings-request.interface'; import { DefaultAlgorithmSettings } from '../../types/default-algorithm-settings.type'; import { AlgorithmType } from '../../types/algorithm.enum'; -import { TimingFrequency } from '../../types/timing'; import { ICreateGeorouter } from '../../interfaces/georouter-creator.interface'; import { IGeorouter } from '../../interfaces/georouter.interface'; +import { Frequency } from '../../../../ad/domain/types/frequency.enum'; export class AlgorithmSettings { private algorithmSettingsRequest: IRequestAlgorithmSettings; private strict: boolean; algorithmType: AlgorithmType; - restrict: TimingFrequency; + restrict: Frequency; remoteness: number; useProportion: boolean; proportion: number; @@ -22,7 +22,7 @@ export class AlgorithmSettings { constructor( algorithmSettingsRequest: IRequestAlgorithmSettings, defaultAlgorithmSettings: DefaultAlgorithmSettings, - frequency: TimingFrequency, + frequency: Frequency, georouterCreator: ICreateGeorouter, ) { this.algorithmSettingsRequest = algorithmSettingsRequest; diff --git a/src/modules/matcher/domain/entities/ecosystem/geography.ts b/src/modules/matcher/domain/entities/ecosystem/geography.ts index 56a08a5..59af204 100644 --- a/src/modules/matcher/domain/entities/ecosystem/geography.ts +++ b/src/modules/matcher/domain/entities/ecosystem/geography.ts @@ -3,8 +3,8 @@ import { MatcherExceptionCode, } from '../../../exceptions/matcher.exception'; import { IRequestGeography } from '../../interfaces/geography-request.interface'; -import { PointType } from '../../types/geography.enum'; -import { Point } from '../../types/point.type'; +import { PointType } from '../../../../geography/domain/types/point-type.enum'; +import { Point } from '../../../../geography/domain/types/point.type'; import { Route } from './route'; import { Role } from '../../types/role.enum'; import { IGeorouter } from '../../interfaces/georouter.interface'; diff --git a/src/modules/matcher/domain/entities/ecosystem/route.ts b/src/modules/matcher/domain/entities/ecosystem/route.ts index 2bb27b8..f9670e4 100644 --- a/src/modules/matcher/domain/entities/ecosystem/route.ts +++ b/src/modules/matcher/domain/entities/ecosystem/route.ts @@ -1,5 +1,5 @@ import { IGeodesic } from '../../../../geography/domain/interfaces/geodesic.interface'; -import { Point } from '../../types/point.type'; +import { Point } from '../../../../geography/domain/types/point.type'; import { SpacetimePoint } from './spacetime-point'; import { Waypoint } from './waypoint'; diff --git a/src/modules/matcher/domain/entities/ecosystem/spacetime-point.ts b/src/modules/matcher/domain/entities/ecosystem/spacetime-point.ts index 98fe80f..57e21d6 100644 --- a/src/modules/matcher/domain/entities/ecosystem/spacetime-point.ts +++ b/src/modules/matcher/domain/entities/ecosystem/spacetime-point.ts @@ -1,10 +1,12 @@ +import { Coordinates } from 'src/modules/geography/domain/types/coordinates.type'; + export class SpacetimePoint { - point: Array; + coordinates: Coordinates; duration: number; distance: number; - constructor(point: Array, duration: number, distance: number) { - this.point = point; + constructor(coordinates: Coordinates, duration: number, distance: number) { + this.coordinates = coordinates; this.duration = duration; this.distance = distance; } diff --git a/src/modules/matcher/domain/entities/ecosystem/time.ts b/src/modules/matcher/domain/entities/ecosystem/time.ts index 183a69a..417cd22 100644 --- a/src/modules/matcher/domain/entities/ecosystem/time.ts +++ b/src/modules/matcher/domain/entities/ecosystem/time.ts @@ -4,14 +4,16 @@ import { } from '../../../exceptions/matcher.exception'; import { MarginDurations } from '../../types/margin-durations.type'; import { IRequestTime } from '../../interfaces/time-request.interface'; -import { TimingDays, TimingFrequency, Days } from '../../types/timing'; +import { DAYS } from '../../types/days.const'; import { Schedule } from '../../types/schedule.type'; +import { Frequency } from '../../../../ad/domain/types/frequency.enum'; +import { Day } from '../../types/day.type'; export class Time { private timeRequest: IRequestTime; private defaultMarginDuration: number; private defaultValidityDuration: number; - frequency: TimingFrequency; + frequency: Frequency; fromDate: Date; toDate: Date; schedule: Schedule; @@ -106,7 +108,7 @@ export class Time { } if ( !Object.keys(this.timeRequest.schedule).some((elem) => - Days.includes(elem), + DAYS.includes(elem), ) ) { throw new MatcherException( @@ -127,15 +129,15 @@ export class Time { private setPunctualRequest = (): void => { if (this.timeRequest.departure) { - this.frequency = TimingFrequency.FREQUENCY_PUNCTUAL; - this.schedule[TimingDays[this.fromDate.getDay()]] = + this.frequency = Frequency.PUNCTUAL; + this.schedule[Day[this.fromDate.getDay()]] = this.fromDate.getHours() + ':' + this.fromDate.getMinutes(); } }; private setRecurrentRequest = (): void => { if (this.timeRequest.fromDate) { - this.frequency = TimingFrequency.FREQUENCY_RECURRENT; + this.frequency = Frequency.RECURRENT; if (!this.toDate) { this.toDate = this.addDays(this.fromDate, this.defaultValidityDuration); } @@ -165,7 +167,7 @@ export class Time { if (this.timeRequest.marginDurations) { if ( !Object.keys(this.timeRequest.marginDurations).some((elem) => - Days.includes(elem), + DAYS.includes(elem), ) ) { throw new MatcherException( diff --git a/src/modules/matcher/domain/entities/ecosystem/waypoint.ts b/src/modules/matcher/domain/entities/ecosystem/waypoint.ts index fdcbea0..3695dc2 100644 --- a/src/modules/matcher/domain/entities/ecosystem/waypoint.ts +++ b/src/modules/matcher/domain/entities/ecosystem/waypoint.ts @@ -1,4 +1,4 @@ -import { Point } from '../../types/point.type'; +import { Point } from '../../../../geography/domain/types/point.type'; import { Actor } from './actor'; export class Waypoint { diff --git a/src/modules/matcher/domain/interfaces/geography-request.interface.ts b/src/modules/matcher/domain/interfaces/geography-request.interface.ts index d10a6ac..6cf3673 100644 --- a/src/modules/matcher/domain/interfaces/geography-request.interface.ts +++ b/src/modules/matcher/domain/interfaces/geography-request.interface.ts @@ -1,4 +1,4 @@ -import { Point } from '../types/point.type'; +import { Point } from '../../../geography/domain/types/point.type'; export interface IRequestGeography { waypoints: Array; diff --git a/src/modules/matcher/domain/types/day.type.ts b/src/modules/matcher/domain/types/day.type.ts new file mode 100644 index 0000000..c275d7a --- /dev/null +++ b/src/modules/matcher/domain/types/day.type.ts @@ -0,0 +1,9 @@ +export enum Day { + 'sun', + 'mon', + 'tue', + 'wed', + 'thu', + 'fri', + 'sat', +} diff --git a/src/modules/matcher/domain/types/days.const.ts b/src/modules/matcher/domain/types/days.const.ts new file mode 100644 index 0000000..4794839 --- /dev/null +++ b/src/modules/matcher/domain/types/days.const.ts @@ -0,0 +1 @@ +export const DAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']; diff --git a/src/modules/matcher/domain/types/path.type.ts b/src/modules/matcher/domain/types/path.type.ts index 8a1bfe9..49437bd 100644 --- a/src/modules/matcher/domain/types/path.type.ts +++ b/src/modules/matcher/domain/types/path.type.ts @@ -1,4 +1,4 @@ -import { Point } from './point.type'; +import { Point } from '../../../geography/domain/types/point.type'; export type Path = { key: string; diff --git a/src/modules/matcher/domain/types/point.type.ts b/src/modules/matcher/domain/types/point.type.ts deleted file mode 100644 index 8d32fe0..0000000 --- a/src/modules/matcher/domain/types/point.type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { PointType } from './geography.enum'; - -export type Point = { - lon: number; - lat: number; - type?: PointType; -}; diff --git a/src/modules/matcher/domain/types/timing.ts b/src/modules/matcher/domain/types/timing.ts deleted file mode 100644 index 567595a..0000000 --- a/src/modules/matcher/domain/types/timing.ts +++ /dev/null @@ -1,16 +0,0 @@ -export enum TimingFrequency { - FREQUENCY_PUNCTUAL = 1, - FREQUENCY_RECURRENT = 2, -} - -export enum TimingDays { - 'sun', - 'mon', - 'tue', - 'wed', - 'thu', - 'fri', - 'sat', -} - -export const Days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']; diff --git a/src/modules/matcher/domain/types/waypoint.ts b/src/modules/matcher/domain/types/waypoint.ts index 6ee5941..8628fd1 100644 --- a/src/modules/matcher/domain/types/waypoint.ts +++ b/src/modules/matcher/domain/types/waypoint.ts @@ -1,5 +1,5 @@ import { Actor } from './actor.type.'; -import { Point } from './point.type'; +import { Point } from '../../../geography/domain/types/point.type'; export type Waypoint = { point: Point; diff --git a/src/modules/matcher/tests/unit/adapters/secondaries/geo-timezone-finder.spec.ts b/src/modules/matcher/tests/unit/adapters/secondaries/timezone-finder.spec.ts similarity index 96% rename from src/modules/matcher/tests/unit/adapters/secondaries/geo-timezone-finder.spec.ts rename to src/modules/matcher/tests/unit/adapters/secondaries/timezone-finder.spec.ts index 5dccb46..63d8462 100644 --- a/src/modules/matcher/tests/unit/adapters/secondaries/geo-timezone-finder.spec.ts +++ b/src/modules/matcher/tests/unit/adapters/secondaries/timezone-finder.spec.ts @@ -6,7 +6,7 @@ const mockGeoTimezoneFinder = { timezones: jest.fn().mockImplementation(() => ['Europe/Paris']), }; -describe('Geo TZ Finder', () => { +describe('Timezone Finder', () => { let timezoneFinder: TimezoneFinder; beforeAll(async () => { diff --git a/src/modules/matcher/tests/unit/domain/ecosystem/geography.spec.ts b/src/modules/matcher/tests/unit/domain/ecosystem/geography.spec.ts index 2503dcc..9b870e8 100644 --- a/src/modules/matcher/tests/unit/domain/ecosystem/geography.spec.ts +++ b/src/modules/matcher/tests/unit/domain/ecosystem/geography.spec.ts @@ -7,7 +7,7 @@ import { Role } from '../../../../domain/types/role.enum'; import { NamedRoute } from '../../../../domain/entities/ecosystem/named-route'; import { Route } from '../../../../domain/entities/ecosystem/route'; import { IGeodesic } from '../../../../../geography/domain/interfaces/geodesic.interface'; -import { PointType } from '../../../../domain/types/geography.enum'; +import { PointType } from '../../../../../geography/domain/types/point-type.enum'; const person: Person = new Person( { diff --git a/src/modules/matcher/tests/unit/domain/ecosystem/route.spec.ts b/src/modules/matcher/tests/unit/domain/ecosystem/route.spec.ts index 16d27a3..70c9460 100644 --- a/src/modules/matcher/tests/unit/domain/ecosystem/route.spec.ts +++ b/src/modules/matcher/tests/unit/domain/ecosystem/route.spec.ts @@ -57,8 +57,8 @@ describe('Route entity', () => { }); it('should set spacetimePoints for a route', () => { const route = new Route(mockGeodesic); - const spacetimePoint1 = new SpacetimePoint([0, 0], 0, 0); - const spacetimePoint2 = new SpacetimePoint([10, 10], 500, 5000); + const spacetimePoint1 = new SpacetimePoint({ lon: 0, lat: 0 }, 0, 0); + const spacetimePoint2 = new SpacetimePoint({ lon: 10, lat: 10 }, 500, 5000); route.setSpacetimePoints([spacetimePoint1, spacetimePoint2]); expect(route.spacetimePoints.length).toBe(2); }); diff --git a/src/modules/matcher/tests/unit/queries/match.query.spec.ts b/src/modules/matcher/tests/unit/queries/match.query.spec.ts index 92dae34..7640929 100644 --- a/src/modules/matcher/tests/unit/queries/match.query.spec.ts +++ b/src/modules/matcher/tests/unit/queries/match.query.spec.ts @@ -1,9 +1,9 @@ import { MatchRequest } from '../../../domain/dtos/match.request'; import { Role } from '../../../domain/types/role.enum'; -import { TimingFrequency } from '../../../domain/types/timing'; import { IDefaultParams } from '../../../domain/types/default-params.type'; import { MatchQuery } from '../../../queries/match.query'; import { AlgorithmType } from '../../../domain/types/algorithm.enum'; +import { Frequency } from '../../../../ad/domain/types/frequency.enum'; const defaultParams: IDefaultParams = { DEFAULT_IDENTIFIER: 0, @@ -209,9 +209,7 @@ describe('Match query', () => { expect(matchQuery.algorithmSettings.algorithmType).toBe( AlgorithmType.CLASSIC, ); - expect(matchQuery.algorithmSettings.restrict).toBe( - TimingFrequency.FREQUENCY_PUNCTUAL, - ); + expect(matchQuery.algorithmSettings.restrict).toBe(Frequency.PUNCTUAL); expect(matchQuery.algorithmSettings.useProportion).toBeTruthy(); expect(matchQuery.algorithmSettings.proportion).toBe(0.45); expect(matchQuery.algorithmSettings.useAzimuth).toBeTruthy();