Skip to content

Commit

Permalink
Added default value test to ThresholdConfig and renamed getter for ma…
Browse files Browse the repository at this point in the history
…xRequestSize

Signed-off-by: Marcos Gonzalez Mayedo <alemayed@amazon.com>

Signed-off-by: Marcos Gonzalez Mayedo <alemayed@amazon.com>
  • Loading branch information
Marcos Gonzalez Mayedo committed Jun 28, 2023
1 parent 0823045 commit 15cb85b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data-prepper-plugins/cloudwatch-logs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public int getMaxEventSize() {
return maxEventSize;
}

public int getMaxBatchSize() {
public int getMaxRequestSize() {
return maxRequestSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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<String, Integer> 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
Expand Down

0 comments on commit 15cb85b

Please sign in to comment.