-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added option for normalizing field names
- Loading branch information
1 parent
68de78e
commit 3564c5b
Showing
4 changed files
with
209 additions
and
120 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
42 changes: 42 additions & 0 deletions
42
src/test/java/org/elasticsearch/river/hbase/HBaseRiverTest.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,42 @@ | ||
package org.elasticsearch.river.hbase; | ||
|
||
import mockit.Mock; | ||
import mockit.MockUp; | ||
|
||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.river.AbstractRiverComponent; | ||
import org.elasticsearch.river.RiverName; | ||
import org.elasticsearch.river.RiverSettings; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
public class HBaseRiverTest { | ||
@Test | ||
public void testNormalizeField() { | ||
new MockUp<AbstractRiverComponent>() { | ||
@Mock | ||
void $init(final RiverName riverName, final RiverSettings settings) {} | ||
}; | ||
new MockUp<HBaseRiver>() { | ||
@Mock | ||
void $init(final RiverName riverName, final RiverSettings settings, final Client esClient) {} | ||
|
||
@Mock | ||
boolean isNormalizeFields() { | ||
return true; | ||
} | ||
}; | ||
|
||
final HBaseRiver river = new HBaseRiver(null, null, null); | ||
|
||
Assert.assertEquals(river.normalizeField(""), ""); | ||
Assert.assertEquals(river.normalizeField(" "), ""); | ||
Assert.assertEquals(river.normalizeField("a"), "a"); | ||
Assert.assertEquals(river.normalizeField("A"), "a"); | ||
Assert.assertEquals(river.normalizeField("Aa"), "aa"); | ||
Assert.assertEquals(river.normalizeField("a-b"), "a-b"); | ||
Assert.assertEquals(river.normalizeField("a_b"), "a_b"); | ||
Assert.assertEquals(river.normalizeField("90aS"), "90as"); | ||
Assert.assertEquals(river.normalizeField("&*($@#!ui^&$(#:\"8ui"), "ui8ui"); | ||
} | ||
} |