From 31266688122f8fe0066b8e9f70edc602f0c03261 Mon Sep 17 00:00:00 2001 From: Stefan Ranoszek Date: Mon, 18 May 2026 15:32:57 +0100 Subject: [PATCH] fix: re-enable vehicle size declaration for PSV applications The VehiclesSizeReviewService in vol-app expects psvWhichVehicleSizes to be set when generating a grant snapshot for PSV applications. Without this, granting a PSV licence fails with 'Trying to access array offset on null' in VehiclesSizeReviewService.php. Updated the endpoint from the old vehicle-declaration/submit (POST) to the current vehicle-size (PUT) endpoint, sending only the required fields (id, psvVehicleSize, version). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../apiCalls/actions/CreateApplication.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/main/java/apiCalls/actions/CreateApplication.java b/src/main/java/apiCalls/actions/CreateApplication.java index d7ef8b2..4c27338 100644 --- a/src/main/java/apiCalls/actions/CreateApplication.java +++ b/src/main/java/apiCalls/actions/CreateApplication.java @@ -1384,25 +1384,26 @@ public synchronized ValidatableResponse addVehicleDetails() throws HttpException return apiResponse; } - // NO LONGER USED -// public synchronized ValidatableResponse submitVehicleDeclaration() throws HttpException { -// if (licenceType.equals(LicenceType.SPECIAL_RESTRICTED.asString())) { -// return null; -// } -// -// var vehicleDeclarationResource = ApiUrl.build(env, String.format(String.format("application/%s/vehicle-declaration/submit", applicationId))).toString(); -// int applicationVersion = Integer.parseInt(fetchApplicationInformation(getApplicationId(), "version", "1")); -// -// VehicleDeclarationBuilder vehicleDeclarationBuilder = new VehicleDeclarationBuilder().withId(getApplicationId() -// ).withPsvVehicleSize(psvVehicleSize) -// .withPsvLimousines(psvLimousines).withPsvNoSmallVhlConfirmation(psvNoSmallVhlConfirmation).withPsvOperateSmallVhl(psvOperateSmallVhl).withPsvSmallVhlNotes(psvSmallVhlNotes) -// .withPsvNoLimousineConfirmation(psvNoLimousineConfirmation).withPsvOnlyLimousinesConfirmation(psvOnlyLimousinesConfirmation).withVersion(applicationVersion); -// apiResponse = RestUtils.post(vehicleDeclarationBuilder, vehicleDeclarationResource, apiHeaders.getApiHeader()); -// -// Utils.checkHTTPStatusCode(apiResponse, HttpStatus.SC_OK); -// -// return apiResponse; -// } + public synchronized ValidatableResponse submitVehicleDeclaration() throws HttpException { + if (licenceType.equals(LicenceType.SPECIAL_RESTRICTED.asString())) { + return null; + } + if (!operatorType.equals(OperatorType.PUBLIC.asString())) { + return null; + } + + var vehicleSizeResource = ApiUrl.build(env, String.format("application/%s/vehicle-size", applicationId)).toString(); + int applicationVersion = Integer.parseInt(fetchApplicationInformation(getApplicationId(), "version", "1")); + + VehicleDeclarationBuilder vehicleDeclarationBuilder = new VehicleDeclarationBuilder().withId(getApplicationId()) + .withPsvVehicleSize(psvVehicleSize) + .withVersion(applicationVersion); + apiResponse = RestUtils.put(vehicleDeclarationBuilder, vehicleSizeResource, apiHeaders.getApiHeader()); + + Utils.checkHTTPStatusCode(apiResponse, HttpStatus.SC_OK); + + return apiResponse; + } public synchronized ValidatableResponse addFinancialHistory() throws HttpException { if (operatorType.equals(OperatorType.PUBLIC.asString()) && (licenceType.equals(LicenceType.SPECIAL_RESTRICTED.asString()))) {