Skip to content

Commit 4f4744e

Browse files
committed
Refactor using eq instead anyString()
1 parent 5377e6f commit 4f4744e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

client/runtime/src/test/java/io/quarkiverse/openapi/generator/providers/ApiKeyOpenApiSpecProviderTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void filterHeaderNotFromAuthorizationHeaderCase() throws IOException {
7575
Mockito.eq(ApiKeyAuthenticationProvider.USE_AUTHORIZATION_HEADER_VALUE));
7676

7777
doReturn(Optional.of(API_KEY_VALUE)).when(authConfig).getConfigParam(
78-
Mockito.eq("api-key"));
78+
Mockito.eq(ApiKeyAuthenticationProvider.API_KEY));
7979
doReturn(API_KEY_AUTH_HEADER_VALUE).when(requestContext).getHeaderString("Authorization");
8080
provider.filter(requestContext);
8181
assertHeader(headers, API_KEY_NAME, API_KEY_VALUE);
@@ -86,7 +86,7 @@ void filterHeaderNotFromAuthorizationHeaderCase() throws IOException {
8686
void filterHeaderCase() throws IOException {
8787

8888
doReturn(Optional.of(API_KEY_VALUE)).when(authConfig)
89-
.getConfigParam(Mockito.eq("api-key"));
89+
.getConfigParam(Mockito.eq(ApiKeyAuthenticationProvider.API_KEY));
9090
provider.filter(requestContext);
9191

9292
assertHeader(headers, API_KEY_NAME, API_KEY_VALUE);
@@ -98,7 +98,7 @@ void filterQueryCase() throws IOException {
9898
provider = new ApiKeyAuthenticationProvider(OPEN_API_FILE_SPEC_ID, AUTH_SCHEME_NAME, ApiKeyIn.query, API_KEY_NAME,
9999
authConfig, List.of());
100100
doReturn(Optional.of(API_KEY_VALUE)).when(authConfig)
101-
.getConfigParam(Mockito.eq("api-key"));
101+
.getConfigParam(Mockito.eq(ApiKeyAuthenticationProvider.API_KEY));
102102
provider.filter(requestContext);
103103
verify(requestContext).setUri(uriCaptor.capture());
104104
assertThat(uriCaptor.getValue())
@@ -110,7 +110,8 @@ void filterQueryCase() throws IOException {
110110
void filterCookieCaseEmpty() throws IOException {
111111
final MultivaluedMap<String, Object> headers = new MultivaluedTreeMap<>();
112112
doReturn(headers).when(requestContext).getHeaders();
113-
doReturn(Optional.of(API_KEY_VALUE)).when(authConfig).getConfigParam(Mockito.eq("api-key"));
113+
doReturn(Optional.of(API_KEY_VALUE)).when(authConfig)
114+
.getConfigParam(Mockito.eq(ApiKeyAuthenticationProvider.API_KEY));
114115
provider = new ApiKeyAuthenticationProvider(OPEN_API_FILE_SPEC_ID, AUTH_SCHEME_NAME, ApiKeyIn.cookie, API_KEY_NAME,
115116
authConfig, List.of());
116117
provider.filter(requestContext);
@@ -129,7 +130,9 @@ void filterCookieCaseExisting() throws IOException {
129130
.value(existingCookieValue)
130131
.build();
131132
headers.add(HttpHeaders.COOKIE, existingCookie);
132-
doReturn(Optional.of(API_KEY_VALUE)).when(authConfig).getConfigParam(Mockito.anyString());
133+
doReturn(Optional.of(API_KEY_VALUE)).when(authConfig).getConfigParam(Mockito.eq(
134+
ApiKeyAuthenticationProvider.API_KEY
135+
));
133136
doReturn(headers).when(requestContext).getHeaders();
134137
provider = new ApiKeyAuthenticationProvider(OPEN_API_FILE_SPEC_ID, AUTH_SCHEME_NAME, ApiKeyIn.cookie, API_KEY_NAME,
135138
authConfig, List.of());

0 commit comments

Comments
 (0)