From 15cb85b1a95e12ec2f8a963b89133b931c6f35b5 Mon Sep 17 00:00:00 2001 From: Marcos Gonzalez Mayedo Date: Wed, 28 Jun 2023 14:37:50 -0700 Subject: [PATCH] Added default value test to ThresholdConfig and renamed getter for maxRequestSize Signed-off-by: Marcos Gonzalez Mayedo Signed-off-by: Marcos Gonzalez Mayedo --- data-prepper-plugins/cloudwatch-logs/build.gradle | 2 +- .../plugins/sink/config/ThresholdConfig.java | 2 +- .../sink/configuration/ThresholdConfigTest.java | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/data-prepper-plugins/cloudwatch-logs/build.gradle b/data-prepper-plugins/cloudwatch-logs/build.gradle index f2c0495085..2d00cbd2d0 100644 --- a/data-prepper-plugins/cloudwatch-logs/build.gradle +++ b/data-prepper-plugins/cloudwatch-logs/build.gradle @@ -10,7 +10,6 @@ repositories { dependencies { api project(':data-prepper-api') implementation project(':data-prepper-plugins:aws-plugin-api') - testImplementation platform('org.junit:junit-bom:5.9.1') implementation project(path: ':data-prepper-plugins:common') testImplementation 'org.junit.jupiter:junit-jupiter' implementation 'com.fasterxml.jackson.core:jackson-core' @@ -20,6 +19,7 @@ dependencies { implementation 'software.amazon.awssdk:cloudwatchlogs' implementation 'org.apache.commons:commons-lang3:3.12.0' testImplementation project(path: ':data-prepper-test-common') + testImplementation project(path: ':data-prepper-test-common') } jacocoTestCoverageVerification { diff --git a/data-prepper-plugins/cloudwatch-logs/src/main/java/org/opensearch/dataprepper/plugins/sink/config/ThresholdConfig.java b/data-prepper-plugins/cloudwatch-logs/src/main/java/org/opensearch/dataprepper/plugins/sink/config/ThresholdConfig.java index 211e3db1bc..13ba1e4dbf 100644 --- a/data-prepper-plugins/cloudwatch-logs/src/main/java/org/opensearch/dataprepper/plugins/sink/config/ThresholdConfig.java +++ b/data-prepper-plugins/cloudwatch-logs/src/main/java/org/opensearch/dataprepper/plugins/sink/config/ThresholdConfig.java @@ -48,7 +48,7 @@ public int getMaxEventSize() { return maxEventSize; } - public int getMaxBatchSize() { + public int getMaxRequestSize() { return maxRequestSize; } diff --git a/data-prepper-plugins/cloudwatch-logs/src/test/java/org/opensearch/dataprepper/plugins/sink/configuration/ThresholdConfigTest.java b/data-prepper-plugins/cloudwatch-logs/src/test/java/org/opensearch/dataprepper/plugins/sink/configuration/ThresholdConfigTest.java index cbe7ea606f..e6af96e08d 100644 --- a/data-prepper-plugins/cloudwatch-logs/src/test/java/org/opensearch/dataprepper/plugins/sink/configuration/ThresholdConfigTest.java +++ b/data-prepper-plugins/cloudwatch-logs/src/test/java/org/opensearch/dataprepper/plugins/sink/configuration/ThresholdConfigTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.opensearch.dataprepper.plugins.sink.config.ThresholdConfig; @@ -19,6 +20,18 @@ void setUp() { objectMapper = new ObjectMapper(); } + @Test + void check_default_values() { + final ThresholdConfig thresholdConfig = new ThresholdConfig(); + + assertThat(thresholdConfig.getBackOffTime(), equalTo(ThresholdConfig.DEFAULT_BACKOFF_TIME)); + assertThat(thresholdConfig.getRetryCount(), equalTo(ThresholdConfig.DEFAULT_RETRY_COUNT)); + assertThat(thresholdConfig.getBatchSize(), equalTo(ThresholdConfig.DEFAULT_BATCH_SIZE)); + assertThat(thresholdConfig.getMaxEventSize(), equalTo(ThresholdConfig.DEFAULT_EVENT_SIZE)); + assertThat(thresholdConfig.getMaxRequestSize(), equalTo(ThresholdConfig.DEFAULT_SIZE_OF_REQUEST)); + assertThat(thresholdConfig.getLogSendInterval(), equalTo(ThresholdConfig.DEFAULT_LOG_SEND_INTERVAL_TIME)); + } + @ParameterizedTest @ValueSource(ints = {1, 10, 10000}) void check_valid_batch_size(final int batchSize) { @@ -40,7 +53,7 @@ void check_valid_max_event_size(final int max_event_size) { void check_valid_request_size(final int max_batch_request_size) { final Map jsonMap = Map.of("max_request_size", max_batch_request_size); final ThresholdConfig thresholdConfigTest = objectMapper.convertValue(jsonMap, ThresholdConfig.class); - assertThat(thresholdConfigTest.getMaxBatchSize(), equalTo(max_batch_request_size)); + assertThat(thresholdConfigTest.getMaxRequestSize(), equalTo(max_batch_request_size)); } @ParameterizedTest