From 702e6bb9738b72466af1ffba657e409a19402769 Mon Sep 17 00:00:00 2001 From: kasun Date: Wed, 8 Apr 2026 20:49:28 +0200 Subject: [PATCH] revised HBTest to match new request body --- .../app/connection/HomeboxIntegrationTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/backend/src/test/java/com/vaessl/app/connection/HomeboxIntegrationTest.java b/backend/src/test/java/com/vaessl/app/connection/HomeboxIntegrationTest.java index 4ea7388..1ba9122 100644 --- a/backend/src/test/java/com/vaessl/app/connection/HomeboxIntegrationTest.java +++ b/backend/src/test/java/com/vaessl/app/connection/HomeboxIntegrationTest.java @@ -17,8 +17,6 @@ import com.vaessl.app.dto.ConnectionRequest; import static org.assertj.core.api.Assertions.assertThat; -import java.util.Map; - import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.vaessl.app.connection.Endpoint.*; import static com.vaessl.app.exception.ErrorMessage.*; @@ -97,6 +95,7 @@ class HomeboxIntegrationTest { * Tests a server error from the external api. * * @param wm + * the WiremockRuntimeInfo object */ @Test void shouldFailToConnectWhenHomeboxReturnsServiceUnavailable(WireMockRuntimeInfo wm) { @@ -119,7 +118,7 @@ class HomeboxIntegrationTest { ConnectionRequest badRequest = new ConnectionRequest( MOCK_URL, HOMEBOX.getValue(), - Map.of("username", TEST_USER, "password", TEST_PASS), + TEST_USER, TEST_PASS, null, false); ResponseEntity response = restTemplate.postForEntity(LOGIN.getValue(), badRequest, String.class); @@ -134,7 +133,7 @@ class HomeboxIntegrationTest { @Test void shouldReturnBadRequestWhenHomeboxFieldsAreEmpty() { - ConnectionRequest emtpyRequest = new ConnectionRequest("", "", Map.of(), false); + ConnectionRequest emtpyRequest = new ConnectionRequest("", "", "", "", false); ResponseEntity response = restTemplate.postForEntity(LOGIN.getValue(), emtpyRequest, String.class); @@ -150,7 +149,7 @@ class HomeboxIntegrationTest { ConnectionRequest wrongServiceTypeReq = new ConnectionRequest( MOCK_URL, "wrong-service-type", - Map.of("username", TEST_USER, "password", TEST_PASS), + TEST_USER, TEST_PASS, false); ResponseEntity response = restTemplate.postForEntity(LOGIN.getValue(), wrongServiceTypeReq, @@ -179,12 +178,12 @@ class HomeboxIntegrationTest { DocumentContext responseContext = JsonPath.parse(response.getBody()); - ConnectionEntity dbEntry = cRepository.findByAppUrlAndUsername(request.appUrl(), request.credentials().get("username")); + ConnectionEntity dbEntry = cRepository.findByAppUrlAndUsername(request.appUrl(), request.username()); assertThat(dbEntry).isNotNull(); assertThat(dbEntry.getAppUrl()).isEqualTo(request.appUrl()); - assertThat(dbEntry.getUsername()).isEqualTo(request.credentials().get("username")); + assertThat(dbEntry.getUsername()).isEqualTo(request.username()); if (dbEntry instanceof HomeboxEntity hbE) { assertThat(hbE.getToken()).isEqualTo(responseContext.read("$.token")); @@ -202,8 +201,7 @@ class HomeboxIntegrationTest { * @return a mock api connection request. */ private ConnectionRequest connectionRequest(WireMockRuntimeInfo wm) { - return new ConnectionRequest(wm.getHttpBaseUrl(), HOMEBOX.getValue(), - Map.of("username", TEST_USER, "password", TEST_PASS), + return new ConnectionRequest(wm.getHttpBaseUrl(), HOMEBOX.getValue(), TEST_USER, TEST_PASS, null); } }