-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added changes to tests for readability, fixed typos, and renamed file…
…s for CloudWatchLogs prefixing Signed-off-by: Marcos Gonzalez Mayedo <[email protected]>
- Loading branch information
Marcos Gonzalez Mayedo
committed
Jul 10, 2023
1 parent
976f06a
commit 1a24f1a
Showing
11 changed files
with
161 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...c/test/java/org/opensearch/dataprepper/plugins/sink/buffer/InMemoryBufferFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.sink.buffer; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
public class InMemoryBufferFactoryTest { | ||
@Test | ||
void check_buffer_not_null() { | ||
Buffer buffer = new InMemoryBufferFactory().getBuffer(); | ||
assertThat(buffer, notNullValue()); | ||
assertThat(buffer.getClass(), typeCompatibleWith(Buffer.class)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...est/java/org/opensearch/dataprepper/plugins/sink/config/CloudWatchLogsSinkConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.sink.config; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.opensearch.dataprepper.plugins.sink.config.AwsConfig; | ||
import org.opensearch.dataprepper.plugins.sink.config.CloudWatchLogsSinkConfig; | ||
import org.opensearch.dataprepper.plugins.sink.config.ThresholdConfig; | ||
import org.opensearch.dataprepper.test.helper.ReflectivelySetField; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
public class CloudWatchLogsSinkConfigTest { | ||
private CloudWatchLogsSinkConfig cloudWatchLogsSinkConfig; | ||
private AwsConfig awsConfig; | ||
private ThresholdConfig thresholdConfig; | ||
private final String LOG_GROUP = "testLogGroup"; | ||
private final String LOG_STREAM = "testLogStream"; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
cloudWatchLogsSinkConfig = new CloudWatchLogsSinkConfig(); | ||
awsConfig = new AwsConfig(); | ||
thresholdConfig = new ThresholdConfig(); | ||
} | ||
|
||
@Test | ||
void check_null_auth_config_test() { | ||
assertThat(new CloudWatchLogsSinkConfig().getAwsConfig(), equalTo(null)); | ||
} | ||
|
||
@Test | ||
void check_null_threshold_config_test() { | ||
assertThat(new CloudWatchLogsSinkConfig().getThresholdConfig(), notNullValue()); | ||
} | ||
|
||
@Test | ||
void check_default_buffer_type_test() { | ||
assertThat(new CloudWatchLogsSinkConfig().getBufferType(), equalTo(CloudWatchLogsSinkConfig.DEFAULT_BUFFER_TYPE)); | ||
} | ||
|
||
@Test | ||
void check_null_log_group_test() { | ||
assertThat(new CloudWatchLogsSinkConfig().getLogGroup(), equalTo(null)); | ||
} | ||
|
||
@Test | ||
void check_null_log_stream_test() { | ||
assertThat(new CloudWatchLogsSinkConfig().getLogStream(), equalTo(null)); | ||
} | ||
|
||
@Test | ||
void check_valid_log_group_and_log_stream_test() throws NoSuchFieldException, IllegalAccessException { | ||
ReflectivelySetField.setField(cloudWatchLogsSinkConfig.getClass(), cloudWatchLogsSinkConfig, "logGroup", LOG_GROUP); | ||
ReflectivelySetField.setField(cloudWatchLogsSinkConfig.getClass(), cloudWatchLogsSinkConfig, "logStream", LOG_STREAM); | ||
|
||
assertThat(cloudWatchLogsSinkConfig.getLogGroup(), equalTo(LOG_GROUP)); | ||
assertThat(cloudWatchLogsSinkConfig.getLogStream(), equalTo(LOG_STREAM)); | ||
} | ||
|
||
@Test | ||
void check_valid_sub_config_test() throws NoSuchFieldException, IllegalAccessException { | ||
ReflectivelySetField.setField(cloudWatchLogsSinkConfig.getClass(), cloudWatchLogsSinkConfig, "thresholdConfig", thresholdConfig); | ||
ReflectivelySetField.setField(cloudWatchLogsSinkConfig.getClass(), cloudWatchLogsSinkConfig, "awsConfig", awsConfig); | ||
|
||
assertThat(cloudWatchLogsSinkConfig.getAwsConfig(), equalTo(awsConfig)); | ||
assertThat(cloudWatchLogsSinkConfig.getThresholdConfig(), equalTo(thresholdConfig)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.