Skip to content

Commit

Permalink
removed code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
alexradzin committed Nov 1, 2023
1 parent 3d8f4e4 commit ae7046e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public abstract class FireboltConnection implements Connection {
protected FireboltConnection(@NonNull String url,
Properties connectionSettings,
FireboltAuthenticationService fireboltAuthenticationService,
FireboltStatementService fireboltStatementService) throws SQLException {
FireboltStatementService fireboltStatementService) {
this.loginProperties = extractFireboltProperties(url, connectionSettings);

this.fireboltAuthenticationService = fireboltAuthenticationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;

import static java.lang.String.format;
import static java.util.Optional.ofNullable;
Expand All @@ -27,8 +26,8 @@ public class FireboltAuthenticationService {
.variableExpiration().build();
private static final long TOKEN_EXPIRATION_OFFSET = 5L;
private static final long TOKEN_TTL_THRESHOLD = 60L;
private static final String errorMessage = "Failed to connect to Firebolt with the error: %s, see logs for more info.";
private static final String errorMessageFromServer = "Failed to connect to Firebolt with the error from the server: %s, see logs for more info.";
private static final String ERROR_MESSAGE = "Failed to connect to Firebolt with the error: %s, see logs for more info.";
private static final String ERROR_MESSAGE_FROM_SERVER = "Failed to connect to Firebolt with the error from the server: %s, see logs for more info.";
private final FireboltAuthenticationClient fireboltAuthenticationClient;

public FireboltConnectionTokens getConnectionTokens(String host, FireboltProperties loginProperties) throws FireboltException {
Expand All @@ -48,11 +47,11 @@ public FireboltConnectionTokens getConnectionTokens(String host, FireboltPropert
}
} catch (FireboltException e) {
log.error("Failed to connect to Firebolt", e);
String msg = ofNullable(e.getErrorMessageFromServer()).map(m -> format(errorMessageFromServer, m)).orElse(format(errorMessage, e.getMessage()));
String msg = ofNullable(e.getErrorMessageFromServer()).map(m -> format(ERROR_MESSAGE_FROM_SERVER, m)).orElse(format(ERROR_MESSAGE, e.getMessage()));
throw new FireboltException(msg, e);
} catch (Exception e) {
log.error("Failed to connect to Firebolt", e);
throw new FireboltException(format(errorMessage, e.getMessage()), e);
throw new FireboltException(format(ERROR_MESSAGE, e.getMessage()), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

public class FireboltConnectionServiceSecretAuthenticationTest extends FireboltConnectionTest {
class FireboltConnectionServiceSecretAuthenticationTest extends FireboltConnectionTest {
private static final String SYSTEM_ENGINE_URL = "jdbc:firebolt:db?env=dev&account=dev";

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;

public class FireboltConnectionUserPasswordAuthenticationTest extends FireboltConnectionTest {
class FireboltConnectionUserPasswordAuthenticationTest extends FireboltConnectionTest {
private static final String SYSTEM_ENGINE_URL = "jdbc:firebolt:db?env=dev&account=dev&engine=system";
@Test
void shouldNotValidateConnectionWhenCallingIsValidWhenUsingSystemEngine() throws SQLException {
Expand Down

0 comments on commit ae7046e

Please sign in to comment.