-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for patterned model mappings (#39)
* Support using patterns when building the forward model mappings for a query model. Fixes #2429
- Loading branch information
Showing
4 changed files
with
118 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package datawave.query.model; | ||
|
||
import java.util.Collections; | ||
|
||
import org.junit.Test; | ||
import org.junit.jupiter.api.Assertions; | ||
|
||
public class FieldMappingTest { | ||
|
||
/** | ||
* Verify that creating a forward mapping with a regular field name does not result in any exceptions. | ||
*/ | ||
@Test | ||
public void testForwardMappingWithPlainFieldName() { | ||
Assertions.assertDoesNotThrow(() -> new FieldMapping("datatype", "DB_NAME", "FIELD_NAME", Direction.FORWARD, "ALL", Collections.emptySet())); | ||
} | ||
|
||
/** | ||
* Verify that creating a forward mapping with an invalid pattern for the field name results in an exception. | ||
*/ | ||
@Test | ||
public void testForwardMappingWithInvalidPatternFieldName() { | ||
Assertions.assertThrows(IllegalArgumentException.class, | ||
() -> new FieldMapping("datatype", "[\\]", "FIELD_NAME", Direction.FORWARD, "ALL", Collections.emptySet()), | ||
"Invalid regex pattern supplied for field name: [\\]"); | ||
} | ||
|
||
/** | ||
* Verify that creating a forward mapping with a valid pattern for the field name does not result in an exception. | ||
*/ | ||
@Test | ||
public void testForwardMappingWithValidPatternFieldName() { | ||
Assertions.assertDoesNotThrow(() -> new FieldMapping("datatype", "DB_NAME.*", "FIELD_NAME", Direction.FORWARD, "ALL", Collections.emptySet())); | ||
} | ||
} |
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