Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Sep 11, 2010
1 parent ea22fb1 commit 769a983
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Expand Up @@ -774,6 +774,11 @@ protected TriggerHistory rebuildTriggerIfNecessary(StringBuilder sqlBuffer,

return hist;
}

protected String replaceCharsForTriggerName(String triggerName) {
return triggerName.replaceAll(
"[^a-zA-Z0-9_]|[a|e|i|o|u|A|E|I|O|U]", "");
}

protected String getTriggerName(DataEventType dml, int maxTriggerNameLength, Trigger trigger) {

Expand All @@ -799,9 +804,8 @@ protected String getTriggerName(DataEventType dml, int maxTriggerNameLength, Tri
if (StringUtils.isBlank(triggerName)) {
String triggerPrefix1 = tablePrefix + "_";
String triggerSuffix1 = "on_" + dml.getCode().toLowerCase() + "_for_";
String triggerSuffix2 = (trigger.getTriggerId() + "_"
+ parameterService.getNodeGroupId()).replaceAll(
"[^a-zA-Z0-9]|[a|e|i|o|u|A|E|I|O|U]", "");
String triggerSuffix2 = replaceCharsForTriggerName(trigger.getTriggerId() + "_"
+ parameterService.getNodeGroupId());
triggerName = triggerPrefix1 + triggerSuffix1 + triggerSuffix2;
// use the node group id as part of the trigger if we can because it
// helps uniquely identify
Expand Down
Expand Up @@ -91,6 +91,14 @@ public class TriggerRouterServiceTest extends AbstractDatabaseTest {
public TriggerRouterServiceTest() throws Exception {
super();
}

@Test
public void testReplaceCharactersForTriggerName() {
TriggerRouterService triggerRouterService = new TriggerRouterService();
Assert.assertEquals("123456_54321", triggerRouterService.replaceCharsForTriggerName("123456_54321"));
Assert.assertEquals("tst_1234_rght_n", triggerRouterService.replaceCharsForTriggerName("test_1234_right::_on"));

}

@Test
public void testSchemaSync() throws Exception {
Expand Down

0 comments on commit 769a983

Please sign in to comment.