changed formatter

This commit is contained in:
2026-05-17 00:26:46 +02:00
parent 4d96524adb
commit a8ecf65180
17 changed files with 180 additions and 191 deletions
@@ -52,11 +52,10 @@ class HomeboxIntegrationTest {
@Test
void shouldReturnStatusOkWhenHomeboxCredentialsAreValid(WireMockRuntimeInfo wm) {
stubFor(post(HOMEBOX_LOGIN.getValue())
.willReturn(okJson(okJsonHomeboxResponse)));
stubFor(post(HOMEBOX_LOGIN.getValue()).willReturn(okJson(okJsonHomeboxResponse)));
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN.getValue(), connectionRequest(wm),
String.class);
ResponseEntity<String> response =
restTemplate.postForEntity(LOGIN.getValue(), connectionRequest(wm), String.class);
DocumentContext documentContext = JsonPath.parse(response.getBody());
@@ -78,8 +77,8 @@ class HomeboxIntegrationTest {
stubFor(post(HOMEBOX_LOGIN.getValue()).willReturn(unauthorized()));
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN.getValue(), connectionRequest(wm),
String.class);
ResponseEntity<String> response =
restTemplate.postForEntity(LOGIN.getValue(), connectionRequest(wm), String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
assertThat(response.getBody()).contains(UNAUTHORIZED_WRONG_LOGIN.getMessage());
@@ -95,8 +94,8 @@ class HomeboxIntegrationTest {
stubFor(post(HOMEBOX_LOGIN.getValue()).willReturn(serviceUnavailable()));
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN.getValue(), connectionRequest(wm),
String.class);
ResponseEntity<String> response =
restTemplate.postForEntity(LOGIN.getValue(), connectionRequest(wm), String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE);
assertThat(response.getBody()).contains(SERVER_ERROR_GENERAL.getMessage());
@@ -112,7 +111,8 @@ class HomeboxIntegrationTest {
.willReturn(aResponse().withFault(Fault.CONNECTION_RESET_BY_PEER)));
ConnectionRequest badRequest = connectionRequest(wm);
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN.getValue(), badRequest, String.class);
ResponseEntity<String> response =
restTemplate.postForEntity(LOGIN.getValue(), badRequest, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE);
assertThat(response.getBody()).contains(SERVICE_UNAVAILABLE_UNREACHABLE_URL.getMessage());
@@ -126,34 +126,30 @@ class HomeboxIntegrationTest {
ConnectionRequest emtpyRequest = new ConnectionRequest("", "", "", "", false);
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN.getValue(), emtpyRequest, String.class);
ResponseEntity<String> response =
restTemplate.postForEntity(LOGIN.getValue(), emtpyRequest, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
assertThat(response.getBody()).contains(BAD_REQUEST_EMPTY_FIELDS.getMessage());
}
/**
* Test the exception when there is an input for serviceType but it's
* unsupported.
* Test the exception when there is an input for serviceType but it's unsupported.
*/
@Test
void shouldReturnWrongServiceTypeException(WireMockRuntimeInfo wm) {
ConnectionRequest wrongServiceTypeReq = new ConnectionRequest(
wm.getHttpBaseUrl(),
"wrong-service-type",
TEST_USER, TEST_PASS,
false);
ConnectionRequest wrongServiceTypeReq = new ConnectionRequest(wm.getHttpBaseUrl(),
"wrong-service-type", TEST_USER, TEST_PASS, false);
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN.getValue(), wrongServiceTypeReq,
String.class);
ResponseEntity<String> response =
restTemplate.postForEntity(LOGIN.getValue(), wrongServiceTypeReq, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(response.getBody()).contains(WRONG_SERVICE_TYPE.getMessage());
}
/**
* Tests the succesfull persistance of Homebox credential response to the
* database.
* Tests the succesfull persistance of Homebox credential response to the database.
*
* @param wm the WiremockRuntimeInfo object
*/
@@ -165,10 +161,12 @@ class HomeboxIntegrationTest {
ConnectionRequest request = connectionRequest(wm);
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN.getValue(), request, String.class);
ResponseEntity<String> response =
restTemplate.postForEntity(LOGIN.getValue(), request, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
ConnectionEntity dbEntry = cRepository.findByAppUrlAndUsername(request.appUrl(), request.username());
ConnectionEntity dbEntry =
cRepository.findByAppUrlAndUsername(request.appUrl(), request.username());
assertThat(dbEntry).isNotNull();
assertThat(dbEntry.getAppUrl()).isEqualTo(request.appUrl());
@@ -183,20 +181,18 @@ class HomeboxIntegrationTest {
@Test
void shouldReturnEmptyCredentialsExceptionWhenCredsAreMissing(WireMockRuntimeInfo wm) {
ConnectionRequest missingCredentials = new ConnectionRequest(wm.getHttpBaseUrl(), HOMEBOX.getValue(), TEST_USER,
null,
false);
ConnectionRequest missingCredentials = new ConnectionRequest(wm.getHttpBaseUrl(),
HOMEBOX.getValue(), TEST_USER, null, false);
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN.getValue(), missingCredentials,
String.class);
ResponseEntity<String> response =
restTemplate.postForEntity(LOGIN.getValue(), missingCredentials, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
assertThat(response.getBody()).contains(BAD_REQUEST_EMPTY_FIELDS.getMessage());
}
/**
* Creates a valid connection request with a mock Api through
* WireMockRuntimeInfo.
* Creates a valid connection request with a mock Api through WireMockRuntimeInfo.
*
* @param wm the WiremockRuntimeInfo object
* @return a mock api connection request.