mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 07:52:41 +00:00
remove waypoints where not relevant
This commit is contained in:
@@ -2,17 +2,15 @@ import { GeorouterPort } from '@modules/geography/core/application/ports/georout
|
||||
import { GetRouteQuery } from '@modules/geography/core/application/queries/get-route/get-route.query';
|
||||
import { GetRouteQueryHandler } from '@modules/geography/core/application/queries/get-route/get-route.query-handler';
|
||||
import { RouteEntity } from '@modules/geography/core/domain/route.entity';
|
||||
import { Waypoint } from '@modules/geography/core/domain/route.types';
|
||||
import { Point } from '@modules/geography/core/domain/route.types';
|
||||
import { GEOROUTER } from '@modules/geography/geography.di-tokens';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
const originWaypoint: Waypoint = {
|
||||
position: 0,
|
||||
const originWaypoint: Point = {
|
||||
lat: 48.689445,
|
||||
lon: 6.17651,
|
||||
};
|
||||
const destinationWaypoint: Waypoint = {
|
||||
position: 1,
|
||||
const destinationWaypoint: Point = {
|
||||
lat: 48.8566,
|
||||
lon: 2.3522,
|
||||
};
|
||||
|
||||
@@ -44,16 +44,7 @@ const mockGeorouter: GeorouterPort = {
|
||||
};
|
||||
|
||||
const createRouteProps: CreateRouteProps = {
|
||||
waypoints: [
|
||||
{
|
||||
position: 0,
|
||||
...originPoint,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
...destinationPoint,
|
||||
},
|
||||
],
|
||||
waypoints: [originPoint, destinationPoint],
|
||||
georouter: mockGeorouter,
|
||||
georouterSettings: {
|
||||
points: true,
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
import {
|
||||
ArgumentInvalidException,
|
||||
ArgumentOutOfRangeException,
|
||||
} from '@mobicoop/ddd-library';
|
||||
import { Waypoint } from '@modules/geography/core/domain/value-objects/waypoint.value-object';
|
||||
|
||||
describe('Waypoint value object', () => {
|
||||
it('should create a waypoint value object', () => {
|
||||
const waypointVO = new Waypoint({
|
||||
position: 0,
|
||||
lat: 48.689445,
|
||||
lon: 6.17651,
|
||||
});
|
||||
expect(waypointVO.position).toBe(0);
|
||||
expect(waypointVO.lat).toBe(48.689445);
|
||||
expect(waypointVO.lon).toBe(6.17651);
|
||||
});
|
||||
it('should throw an exception if position is invalid', () => {
|
||||
try {
|
||||
new Waypoint({
|
||||
position: -1,
|
||||
lat: 48.689445,
|
||||
lon: 6.17651,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentInvalidException);
|
||||
}
|
||||
});
|
||||
it('should throw an exception if longitude is invalid', () => {
|
||||
try {
|
||||
new Waypoint({
|
||||
position: 0,
|
||||
lat: 48.689445,
|
||||
lon: 186.17651,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
|
||||
}
|
||||
try {
|
||||
new Waypoint({
|
||||
position: 0,
|
||||
lat: 48.689445,
|
||||
lon: -186.17651,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
|
||||
}
|
||||
});
|
||||
it('should throw an exception if latitude is invalid', () => {
|
||||
try {
|
||||
new Waypoint({
|
||||
position: 0,
|
||||
lat: 148.689445,
|
||||
lon: 6.17651,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
|
||||
}
|
||||
try {
|
||||
new Waypoint({
|
||||
position: 0,
|
||||
lat: -148.689445,
|
||||
lon: 6.17651,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -297,12 +297,10 @@ describe('Graphhopper Georouter', () => {
|
||||
graphhopperGeorouter.route(
|
||||
[
|
||||
{
|
||||
position: 0,
|
||||
lon: 0,
|
||||
lat: 0,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
lon: 1,
|
||||
lat: 1,
|
||||
},
|
||||
@@ -321,12 +319,10 @@ describe('Graphhopper Georouter', () => {
|
||||
graphhopperGeorouter.route(
|
||||
[
|
||||
{
|
||||
position: 0,
|
||||
lon: 0,
|
||||
lat: 0,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
lon: 1,
|
||||
lat: 1,
|
||||
},
|
||||
@@ -344,12 +340,10 @@ describe('Graphhopper Georouter', () => {
|
||||
const route: Route = await graphhopperGeorouter.route(
|
||||
[
|
||||
{
|
||||
position: 0,
|
||||
lon: 0,
|
||||
lat: 0,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
lon: 10,
|
||||
lat: 10,
|
||||
},
|
||||
@@ -367,12 +361,10 @@ describe('Graphhopper Georouter', () => {
|
||||
const route: Route = await graphhopperGeorouter.route(
|
||||
[
|
||||
{
|
||||
position: 0,
|
||||
lon: 0,
|
||||
lat: 0,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
lon: 10,
|
||||
lat: 10,
|
||||
},
|
||||
@@ -394,12 +386,10 @@ describe('Graphhopper Georouter', () => {
|
||||
const route: Route = await graphhopperGeorouter.route(
|
||||
[
|
||||
{
|
||||
position: 0,
|
||||
lon: 0,
|
||||
lat: 0,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
lon: 10,
|
||||
lat: 10,
|
||||
},
|
||||
@@ -419,17 +409,14 @@ describe('Graphhopper Georouter', () => {
|
||||
const route: Route = await graphhopperGeorouter.route(
|
||||
[
|
||||
{
|
||||
position: 0,
|
||||
lon: 0,
|
||||
lat: 0,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
lon: 5,
|
||||
lat: 5,
|
||||
},
|
||||
{
|
||||
position: 2,
|
||||
lon: 10,
|
||||
lat: 10,
|
||||
},
|
||||
@@ -452,12 +439,10 @@ describe('Graphhopper Georouter', () => {
|
||||
const route: Route = await graphhopperGeorouter.route(
|
||||
[
|
||||
{
|
||||
position: 0,
|
||||
lon: 0,
|
||||
lat: 0,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
lon: 10,
|
||||
lat: 10,
|
||||
},
|
||||
|
||||
@@ -49,12 +49,10 @@ describe('Get Basic Route Controller', () => {
|
||||
await getBasicRouteController.get({
|
||||
waypoints: [
|
||||
{
|
||||
position: 0,
|
||||
lat: 48.689445,
|
||||
lon: 6.17651,
|
||||
},
|
||||
{
|
||||
position: 1,
|
||||
lat: 48.8566,
|
||||
lon: 2.3522,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user