Skip to content

Commit

Permalink
better naming
Browse files Browse the repository at this point in the history
Signed-off-by: Santhosh Gandhe <[email protected]>
  • Loading branch information
san81 committed Jan 16, 2025
1 parent 009eafe commit 78de3aa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
*
* @since 2.11
*/
public class FailedToUpdateSecretException extends RuntimeException {
public class FailedToUpdatePluginConfigValueException extends RuntimeException {

public FailedToUpdateSecretException(final String message) {
public FailedToUpdatePluginConfigValueException(final String message) {
super(message);
}

public FailedToUpdateSecretException(final String message, Throwable e) {
public FailedToUpdatePluginConfigValueException(final String message, Throwable e) {
super(message, e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

public class FailedToUpdateSecretExceptionTest extends RuntimeException {
public class FailedToUpdatePluginConfigValueExceptionTest extends RuntimeException {
private String message;

@BeforeEach
Expand All @@ -28,14 +28,14 @@ void setUp() {

@Test
void testGetMessage_should_return_correct_message() {
FailedToUpdateSecretException failedToUpdateSecretException = new FailedToUpdateSecretException(message);
FailedToUpdatePluginConfigValueException failedToUpdateSecretException = new FailedToUpdatePluginConfigValueException(message);
assertThat(failedToUpdateSecretException.getMessage(), equalTo(message));
}

@Test
void testGetMessage_should_return_correct_message_with_throwable() {
RuntimeException cause = new RuntimeException("testException");
FailedToUpdateSecretException failedToUpdateSecretException = new FailedToUpdateSecretException(message, cause);
FailedToUpdatePluginConfigValueException failedToUpdateSecretException = new FailedToUpdatePluginConfigValueException(message, cause);
assertThat(failedToUpdateSecretException.getMessage(), equalTo(message));
assertThat(failedToUpdateSecretException.getCause(), equalTo(cause));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
package org.opensearch.dataprepper.plugins.aws;

import org.opensearch.dataprepper.model.plugin.FailedToUpdateSecretException;
import org.opensearch.dataprepper.model.plugin.FailedToUpdatePluginConfigValueException;
import org.opensearch.dataprepper.model.plugin.PluginConfigVariable;

/**
Expand Down Expand Up @@ -41,7 +41,7 @@ public Object getValue() {
@Override
public void setValue(Object newValue, String secretVersionIdToSet) {
if (!isUpdatable()) {
throw new FailedToUpdateSecretException(
throw new FailedToUpdatePluginConfigValueException(
String.format("Trying to update a secrets that is not updatable. SecretId: %s SecretKey: %s", this.secretId, this.secretKey));
}
this.secretsSupplier.updateValue(secretId, secretKey, newValue, secretVersionIdToSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opensearch.dataprepper.model.plugin.FailedToUpdateSecretException;
import org.opensearch.dataprepper.model.plugin.FailedToUpdatePluginConfigValueException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
Expand Down Expand Up @@ -169,7 +169,7 @@ public String updateValue(String secretId, String keyToUpdate, Object newValue,
keyToUpdate, secretId, putSecretValueResponse.versionId());
return putSecretValueResponse.versionId();
} catch (Exception e) {
throw new FailedToUpdateSecretException(
throw new FailedToUpdatePluginConfigValueException(
String.format("Failed to update the secret: %s to put a new value for the key: %s",
awsSecretManagerConfiguration.getAwsSecretId(), keyToUpdate), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opensearch.dataprepper.model.plugin.FailedToUpdateSecretException;
import org.opensearch.dataprepper.model.plugin.FailedToUpdatePluginConfigValueException;

import java.util.UUID;

Expand Down Expand Up @@ -56,7 +56,7 @@ void testSetValueFailure_when_secret_is_not_updatable() {
secretId, secretKey,
secretValue, false
);
assertThrows(FailedToUpdateSecretException.class, () -> objectUnderTest.setValue("new-secret-to-set", "randomSecretId"));
assertThrows(FailedToUpdatePluginConfigValueException.class, () -> objectUnderTest.setValue("new-secret-to-set", "randomSecretId"));
}

@ParameterizedTest
Expand Down

0 comments on commit 78de3aa

Please sign in to comment.