Skip to content

Commit

Permalink
refactor: solve SonarQube issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmamo committed Jan 23, 2025
1 parent f53eead commit b0545a0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void apply(
}

@Override
public ApiHeadersAuthScheme encrypt(Function<String, String> encryptFunc) {
public ApiHeadersAuthScheme encrypt(UnaryOperator<String> encryptFunc) {
Map<String, String> encryptedHeaders =
headers.entrySet().stream()
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), encryptFunc.apply(e.getValue())))
Expand All @@ -71,7 +71,7 @@ public ApiHeadersAuthScheme encrypt(Function<String, String> encryptFunc) {
}

@Override
public ApiHeadersAuthScheme decrypt(Function<String, String> decryptFunc) {
public ApiHeadersAuthScheme decrypt(UnaryOperator<String> decryptFunc) {
Map<String, String> encryptedHeaders =
headers.entrySet().stream()
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), decryptFunc.apply(e.getValue())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void apply(
}

@Override
public ApiQueryParamsAuthScheme encrypt(Function<String, String> encryptFunc) {
public ApiQueryParamsAuthScheme encrypt(UnaryOperator<String> encryptFunc) {
Map<String, String> encryptedQueryParams =
queryParams.entrySet().stream()
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), encryptFunc.apply(e.getValue())))
Expand All @@ -71,7 +71,7 @@ public ApiQueryParamsAuthScheme encrypt(Function<String, String> encryptFunc) {
}

@Override
public ApiQueryParamsAuthScheme decrypt(Function<String, String> decryptFunc) {
public ApiQueryParamsAuthScheme decrypt(UnaryOperator<String> decryptFunc) {
Map<String, String> encryptedQueryParams =
queryParams.entrySet().stream()
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), decryptFunc.apply(e.getValue())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
package org.hisp.dhis.common.auth;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -67,12 +67,12 @@ public void apply(
}

@Override
public ApiTokenAuthScheme encrypt(Function<String, String> encryptFunc) {
public ApiTokenAuthScheme encrypt(UnaryOperator<String> encryptFunc) {
return copy(encryptFunc.apply(token));
}

@Override
public AuthScheme decrypt(Function<String, String> decryptFunc) {
public AuthScheme decrypt(UnaryOperator<String> decryptFunc) {
return copy(decryptFunc.apply(token));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.io.Serializable;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -67,7 +67,7 @@ protected AuthScheme(@JsonProperty("type") String type) {
public abstract void apply(
MultiValueMap<String, String> headers, MultiValueMap<String, String> queryParams);

public abstract AuthScheme encrypt(Function<String, String> encryptFunc);
public abstract AuthScheme encrypt(UnaryOperator<String> encryptFunc);

public abstract AuthScheme decrypt(Function<String, String> decryptFunc);
public abstract AuthScheme decrypt(UnaryOperator<String> decryptFunc);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Base64;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -68,12 +68,12 @@ public void apply(
}

@Override
public HttpBasicAuthScheme encrypt(Function<String, String> encryptFunc) {
public HttpBasicAuthScheme encrypt(UnaryOperator<String> encryptFunc) {
return copy(encryptFunc.apply(password));
}

@Override
public HttpBasicAuthScheme decrypt(Function<String, String> decryptFunc) {
public HttpBasicAuthScheme decrypt(UnaryOperator<String> decryptFunc) {
return copy(decryptFunc.apply(password));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ class RouteControllerTest extends PostgresControllerIntegrationTestBase {
@Test
void testRunRouteGivenApiQueryParamsAuthScheme()
throws JsonProcessingException, MalformedURLException {
final ArgumentCaptor<String> urlArgumentCaptor = ArgumentCaptor.forClass(String.class);
;
ArgumentCaptor<String> urlArgumentCaptor = ArgumentCaptor.forClass(String.class);

RestTemplate mockRestTemplate = mock(RestTemplate.class);
when(mockRestTemplate.exchange(
Expand Down Expand Up @@ -112,9 +111,8 @@ void testRunRouteGivenApiQueryParamsAuthScheme()

@Test
void testRunRouteGivenApiHeadersAuthScheme() throws JsonProcessingException {
final ArgumentCaptor<HttpEntity<?>> httpEntityArgumentCaptor =
ArgumentCaptor<HttpEntity<?>> httpEntityArgumentCaptor =
ArgumentCaptor.forClass(HttpEntity.class);
;

RestTemplate mockRestTemplate = mock(RestTemplate.class);
when(mockRestTemplate.exchange(
Expand Down

0 comments on commit b0545a0

Please sign in to comment.