Skip to content

Commit

Permalink
DROOLS-2263: Cover case when not all enums use quote character
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Marko committed Jan 30, 2018
1 parent e916c34 commit 2e27aea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class InnerSplitter {
} else {
result.add(item.substring(item.indexOf(this.quoteCharacter) + 1, item.lastIndexOf(this.quoteCharacter)));
}
} else if (item.startsWith(this.quoteCharacter)) {
} else if (item.trim().startsWith(this.quoteCharacter)) {
current = item.substring(item.indexOf(this.quoteCharacter) + 1) + ",";
} else {
if (trim) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,37 @@ public void changeQuoteCharacterSkipTrimming() throws Exception {
assertEquals("Helsinki, Finland", split[0]);
assertEquals(" Boston", split[1]);
}

@Test
public void testQuoteCharacterUsedJustForComplexEnumEnd() throws Exception {
final String[] split = ListSplitter.split("\"",
true,
"Prague, Boston, \"Helsinki, Finland\"");
assertEquals(3, split.length);
assertEquals("Prague", split[0]);
assertEquals("Boston", split[1]);
assertEquals("Helsinki, Finland", split[2]);
}

@Test
public void testQuoteCharacterUsedJustForComplexEnumMiddle() throws Exception {
final String[] split = ListSplitter.split("\"",
true,
"Prague, \"Helsinki, Finland\", Boston");
assertEquals(3, split.length);
assertEquals("Prague", split[0]);
assertEquals("Helsinki, Finland", split[1]);
assertEquals("Boston", split[2]);
}

@Test
public void testQuoteCharacterUsedJustForComplexEnumStart() throws Exception {
final String[] split = ListSplitter.split("\"",
true,
"\"Helsinki, Finland\", Prague, Boston");
assertEquals(3, split.length);
assertEquals("Helsinki, Finland", split[0]);
assertEquals("Prague", split[1]);
assertEquals("Boston", split[2]);
}
}

0 comments on commit 2e27aea

Please sign in to comment.