From c244af1370e738652af4fd74f4955d607eff11db Mon Sep 17 00:00:00 2001 From: lindenmckenzie Date: Wed, 4 Feb 2026 16:05:29 +0000 Subject: [PATCH 1/4] Upgrade httpcomponents to client5 --- pom.xml | 6 +++--- .../dp/authorisation/permissions/APIClient.java | 14 +++++++------- .../authorisation/permissions/APIClientTest.java | 15 +++++---------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 3a4be5f..f7a34fc 100644 --- a/pom.xml +++ b/pom.xml @@ -37,9 +37,9 @@ - org.apache.httpcomponents - httpclient - 4.5.14 + org.apache.httpcomponents.client5 + httpclient5 + 5.3.1 diff --git a/src/main/java/com/github/onsdigital/dp/authorisation/permissions/APIClient.java b/src/main/java/com/github/onsdigital/dp/authorisation/permissions/APIClient.java index 0691364..16b86bc 100644 --- a/src/main/java/com/github/onsdigital/dp/authorisation/permissions/APIClient.java +++ b/src/main/java/com/github/onsdigital/dp/authorisation/permissions/APIClient.java @@ -3,12 +3,12 @@ import com.github.onsdigital.dp.authorisation.exceptions.Messages; import com.github.onsdigital.dp.authorisation.permissions.models.Bundle; import com.google.gson.Gson; -import org.apache.http.HttpEntity; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.ClientProtocolException; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; import java.io.IOException; import java.io.InputStream; @@ -52,7 +52,7 @@ public Bundle getPermissionsBundle() throws Exception { try (CloseableHttpClient httpClient = httpClientSupplier.get(); CloseableHttpResponse response = httpClient.execute(request)) { - int statusCode = response.getStatusLine().getStatusCode(); + int statusCode = response.getCode(); info().data(statusCodeTitle, statusCode).log("GetPermissionsBundle: request successfully executed"); diff --git a/src/test/java/com/github/onsdigital/dp/authorisation/permissions/APIClientTest.java b/src/test/java/com/github/onsdigital/dp/authorisation/permissions/APIClientTest.java index fa088ca..922b3c3 100644 --- a/src/test/java/com/github/onsdigital/dp/authorisation/permissions/APIClientTest.java +++ b/src/test/java/com/github/onsdigital/dp/authorisation/permissions/APIClientTest.java @@ -6,10 +6,9 @@ import com.github.onsdigital.dp.authorisation.permissions.models.Policy; import com.github.onsdigital.dp.authorisation.permissions.models.Condition; import com.google.gson.Gson; -import org.apache.http.HttpEntity; -import org.apache.http.StatusLine; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.hamcrest.CoreMatchers; import org.junit.Before; import org.junit.Test; @@ -60,9 +59,7 @@ public void testGetPermissionBundle_success() throws Exception { try (InputStream responseBody = new ByteArrayInputStream(expectedJson.getBytes())) { when(httpClient.execute(Matchers.any())).thenReturn(response); - StatusLine statusLine = mock(StatusLine.class); - when(response.getStatusLine()).thenReturn(statusLine); - when(statusLine.getStatusCode()).thenReturn(200); + when(response.getCode()).thenReturn(200); HttpEntity entity = mock(HttpEntity.class); when(response.getEntity()).thenReturn(entity); when(entity.getContent()).thenReturn(responseBody); @@ -77,11 +74,9 @@ public void testGetPermissionBundle_success() throws Exception { public void testGetContentHash_non200Status() { try { CloseableHttpResponse response = mock(CloseableHttpResponse.class); - StatusLine statusLine = mock(StatusLine.class); when(httpClient.execute(Matchers.any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(statusLine); - when(statusLine.getStatusCode()).thenReturn(400); + when(response.getCode()).thenReturn(400); client.getPermissionsBundle(); } catch (Exception ex) { From cda0dac6ef2e12fd002aa4f580ec188d6f03ebf4 Mon Sep 17 00:00:00 2001 From: lindenmckenzie Date: Wed, 4 Feb 2026 16:15:20 +0000 Subject: [PATCH 2/4] Ensure logging import order specified --- pom.xml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index f7a34fc..832d335 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,13 @@ + + + com.github.onsdigital + dp-logging + ${dp.logging.version} + + org.apache.httpcomponents.client5 httpclient5 @@ -95,12 +102,6 @@ 2.12.2 - - com.github.onsdigital - dp-logging - ${dp.logging.version} - - From 351f085c86e448fb641c00309e908e399712fbf5 Mon Sep 17 00:00:00 2001 From: lindenmckenzie Date: Wed, 4 Feb 2026 16:15:31 +0000 Subject: [PATCH 3/4] Upgrade mockito --- pom.xml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 832d335..14d6994 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ 3.1.0 2.22.2 3.2.2 - + 3.12.4 @@ -81,13 +81,20 @@ 4.13.2 test + org.mockito - mockito-all - 2.0.2-beta + mockito-core + ${mockito.version} test + + org.mockito + mockito-inline + ${mockito.version} + test + org.hamcrest From 64bb786813e5c6bfb59e9996b360cde5780a49ce Mon Sep 17 00:00:00 2001 From: lindenmckenzie Date: Wed, 4 Feb 2026 16:17:07 +0000 Subject: [PATCH 4/4] Fix import order --- .../onsdigital/dp/authorisation/permissions/APIClient.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/onsdigital/dp/authorisation/permissions/APIClient.java b/src/main/java/com/github/onsdigital/dp/authorisation/permissions/APIClient.java index 16b86bc..468dd0e 100644 --- a/src/main/java/com/github/onsdigital/dp/authorisation/permissions/APIClient.java +++ b/src/main/java/com/github/onsdigital/dp/authorisation/permissions/APIClient.java @@ -3,12 +3,12 @@ import com.github.onsdigital.dp.authorisation.exceptions.Messages; import com.github.onsdigital.dp.authorisation.permissions.models.Bundle; import com.google.gson.Gson; -import org.apache.hc.core5.http.HttpEntity; import org.apache.hc.client5.http.ClientProtocolException; -import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; import org.apache.hc.client5.http.classic.methods.HttpGet; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.core5.http.HttpEntity; import java.io.IOException; import java.io.InputStream;