refactor: consolidate test mock constants into shared Mockdata class
Moved Mockdata from the connection package to the root test package and extended it with MOCK_USER, MOCK_PASS, MOCK_TITLE, and MOCK_DESCRIPTION so all test modules share a single source of truth. Removed duplicate inline constants from ConnectionControllerTest, HomeboxIntegrationTest, and SearchControllerTest. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.vaessl.app.connection;
|
||||
|
||||
import static com.vaessl.app.Mockdata.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.resttestclient.TestRestTemplate;
|
||||
@@ -41,9 +42,6 @@ class HomeboxIntegrationTest {
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String TEST_USER = "admin";
|
||||
private static final String TEST_PASS = "pw";
|
||||
|
||||
/**
|
||||
* Returns Token and status code OK when login is successful.
|
||||
*
|
||||
@@ -139,7 +137,7 @@ class HomeboxIntegrationTest {
|
||||
@Test
|
||||
void shouldReturnWrongServiceTypeException(WireMockRuntimeInfo wm) {
|
||||
ConnectionRequest wrongServiceTypeReq = new ConnectionRequest(wm.getHttpBaseUrl(),
|
||||
"wrong-service-type", TEST_USER, TEST_PASS, false);
|
||||
"wrong-service-type", MOCK_USER, MOCK_PASS, false);
|
||||
|
||||
ResponseEntity<String> response =
|
||||
restTemplate.postForEntity(LOGIN.getValue(), wrongServiceTypeReq, String.class);
|
||||
@@ -182,7 +180,7 @@ class HomeboxIntegrationTest {
|
||||
@Test
|
||||
void shouldReturnEmptyCredentialsExceptionWhenCredsAreMissing(WireMockRuntimeInfo wm) {
|
||||
ConnectionRequest missingCredentials = new ConnectionRequest(wm.getHttpBaseUrl(),
|
||||
HOMEBOX.getValue(), TEST_USER, null, false);
|
||||
HOMEBOX.getValue(), MOCK_USER, null, false);
|
||||
|
||||
ResponseEntity<String> response =
|
||||
restTemplate.postForEntity(LOGIN.getValue(), missingCredentials, String.class);
|
||||
@@ -198,7 +196,7 @@ class HomeboxIntegrationTest {
|
||||
* @return a mock api connection request.
|
||||
*/
|
||||
private ConnectionRequest connectionRequest(WireMockRuntimeInfo wm) {
|
||||
return new ConnectionRequest(wm.getHttpBaseUrl(), HOMEBOX.getValue(), TEST_USER, TEST_PASS,
|
||||
return new ConnectionRequest(wm.getHttpBaseUrl(), HOMEBOX.getValue(), MOCK_USER, MOCK_PASS,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user