From e96c0896b90a6aba47862b3ea7624f89d8822bea Mon Sep 17 00:00:00 2001 From: js0ny Date: Fri, 28 Nov 2025 03:54:40 +0000 Subject: [PATCH] fix: Check if is under restricted --- flake.nix | 1 + .../js0ny/ilp_coursework/service/PathFinderService.java | 9 +++++++++ .../ilp_coursework/controller/ApiControllerTest.java | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index ffed493..11365ce 100644 --- a/flake.nix +++ b/flake.nix @@ -31,6 +31,7 @@ newman gron fx + google-java-format ]; shellHook = '' export JAVA_HOME=${pkgs.jdk21} diff --git a/src/main/java/io/github/js0ny/ilp_coursework/service/PathFinderService.java b/src/main/java/io/github/js0ny/ilp_coursework/service/PathFinderService.java index 6e0a4cf..6195f4f 100644 --- a/src/main/java/io/github/js0ny/ilp_coursework/service/PathFinderService.java +++ b/src/main/java/io/github/js0ny/ilp_coursework/service/PathFinderService.java @@ -118,6 +118,15 @@ public class PathFinderService { return new DeliveryPathResponse(0f, 0, new DronePath[0]); } + for (var r : records) { + if (isRestricted(r.delivery())) { + throw new IllegalStateException( + "Delivery " + + r.id() + + " is located within a restricted area and cannot be fulfilled"); + } + } + Map> assigned = assignDeliveries(records); List paths = new ArrayList<>(); diff --git a/src/test/java/io/github/js0ny/ilp_coursework/controller/ApiControllerTest.java b/src/test/java/io/github/js0ny/ilp_coursework/controller/ApiControllerTest.java index fc0c886..a2989c5 100644 --- a/src/test/java/io/github/js0ny/ilp_coursework/controller/ApiControllerTest.java +++ b/src/test/java/io/github/js0ny/ilp_coursework/controller/ApiControllerTest.java @@ -264,7 +264,7 @@ public class ApiControllerTest { @Test @DisplayName( "POST /isInRegion -> 400 Bad Request: Passing a list of empty vertices to" - + " isInRegion") + + " isInRegion") void getIsInRegion_shouldReturn400_whenPassingIllegalArguments() throws Exception { var position = new LngLat(1, 1); var region = new Region("illegal", List.of()); @@ -281,7 +281,7 @@ public class ApiControllerTest { @Test @DisplayName( "POST /isInRegion -> 400 Bad Request: Passing a list of not-closing vertices to" - + " isInRegion") + + " isInRegion") void getIsInRegion_shouldReturn400_whenPassingNotClosingVertices() throws Exception { var position = new LngLat(1, 1); var region =