-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added function for creating target index mapping that considers trans…
…form mapping json. Added unit tests. Removed target index date field values formatting. Signed-off-by: Stevan Buzejic <[email protected]>
- Loading branch information
Showing
5 changed files
with
104 additions
and
52 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
27 changes: 27 additions & 0 deletions
27
src/test/kotlin/org/opensearch/indexmanagement/transform/TargetIndexMappingServiceTests.kt
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,27 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.indexmanagement.transform | ||
|
||
import org.junit.Assert | ||
import org.opensearch.test.OpenSearchTestCase | ||
|
||
class TargetIndexMappingServiceTests : OpenSearchTestCase() { | ||
|
||
fun `test create target index mapping fields mapped correctly`() { | ||
val expectedResult = """{"_meta":{"schema_version":1},"dynamic_templates":[{"strings":{"match_mapping_type":"string","mapping":{"type":"keyword"}}}],"properties":{"tpep_pickup_datetime":{"type":"date"}}}""" | ||
val dateFieldMap = mapOf("tpep_pickup_datetime" to mapOf("type" to "date")) | ||
val result = TargetIndexMappingService.createTargetIndexMapping(dateFieldMap) | ||
Assert.assertNotNull(result) | ||
assertEquals("Target index mapping with date fields not correct", expectedResult.trimIndent(), result.trimIndent()) | ||
} | ||
|
||
fun `test create target index mapping empty map`() { | ||
val expectedResult = """{"_meta":{"schema_version":1},"dynamic_templates":[{"strings":{"match_mapping_type":"string","mapping":{"type":"keyword"}}}]}""" | ||
val result = TargetIndexMappingService.createTargetIndexMapping(emptyMap()) | ||
Assert.assertNotNull(result) | ||
assertEquals("Target index mapping with date fields not correct", expectedResult.trimIndent(), result.trimIndent()) | ||
} | ||
} |
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