-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: David Venable <[email protected]>
- Loading branch information
Showing
4 changed files
with
387 additions
and
185 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
46 changes: 46 additions & 0 deletions
46
...on/src/test/java/org/opensearch/dataprepper/plugins/source/file/FileSourceConfigTest.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,46 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.source.file; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import org.opensearch.dataprepper.model.configuration.PluginModel; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
class FileSourceConfigTest { | ||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {FileSourceConfig.EVENT_TYPE, FileSourceConfig.DEFAULT_FORMAT}) | ||
void codeRequiresRecordTypeEvent_returns_true_if_no_codec(final String recordType) { | ||
final Map<String, String> fileConfigMap = Map.of(FileSourceConfig.ATTRIBUTE_TYPE, recordType); | ||
final FileSourceConfig objectUnderTest = OBJECT_MAPPER.convertValue(fileConfigMap, FileSourceConfig.class); | ||
|
||
assertThat(objectUnderTest.codeRequiresRecordTypeEvent(), equalTo(true)); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
FileSourceConfig.EVENT_TYPE + ",true", | ||
FileSourceConfig.DEFAULT_FORMAT + ",false" | ||
}) | ||
void codeRequiresRecordTypeEvent_returns_expected_value_when_there_is_a_codec(final String recordType, final boolean expected) { | ||
final Map<String, Object> fileConfigMap = Map.of( | ||
FileSourceConfig.ATTRIBUTE_TYPE, recordType, | ||
"codec", new PluginModel("fake_codec", Collections.emptyMap()) | ||
); | ||
final FileSourceConfig objectUnderTest = OBJECT_MAPPER.convertValue(fileConfigMap, FileSourceConfig.class); | ||
|
||
assertThat(objectUnderTest.codeRequiresRecordTypeEvent(), equalTo(expected)); | ||
} | ||
} |
Oops, something went wrong.