handle case where version list is quoted

This commit is contained in:
Ken Stevens 2019-12-14 21:02:31 -05:00
parent 50b802279a
commit 9f422efd7a
2 changed files with 27 additions and 0 deletions

View File

@ -21,6 +21,9 @@ public class MigrationTaskSkipper {
} }
Set<String> skippedVersionSet = Stream.of(theSkipVersions.split(",")) Set<String> skippedVersionSet = Stream.of(theSkipVersions.split(","))
.map(String::trim) .map(String::trim)
// TODO KHS filter out all characters that aren't numbers, periods and underscores
.map(s -> s.replace("'", ""))
.map(s -> s.replace("\"", ""))
.filter(StringUtils::isNotBlank) .filter(StringUtils::isNotBlank)
.collect(Collectors.toSet()); .collect(Collectors.toSet());

View File

@ -50,6 +50,12 @@ public class MigrationTaskSkipperTest {
assertSkipped(myTasks, 4); assertSkipped(myTasks, 4);
} }
@Test
public void skipTwo() {
MigrationTaskSkipper.setDoNothingOnSkippedTasks(myTasks, VERSION_PREFIX + 2 + "," + VERSION_PREFIX + 3);
assertSkipped(myTasks, 2, 3);
}
@Test @Test
public void skipWeirdSpacing() { public void skipWeirdSpacing() {
MigrationTaskSkipper.setDoNothingOnSkippedTasks(myTasks, " " + VERSION_PREFIX + 2 + " , " + VERSION_PREFIX + 3 + " "); MigrationTaskSkipper.setDoNothingOnSkippedTasks(myTasks, " " + VERSION_PREFIX + 2 + " , " + VERSION_PREFIX + 3 + " ");
@ -68,6 +74,24 @@ public class MigrationTaskSkipperTest {
assertSkipped(myTasks, 2, 3); assertSkipped(myTasks, 2, 3);
} }
@Test
public void quoted() {
MigrationTaskSkipper.setDoNothingOnSkippedTasks(myTasks, "\"" + VERSION_PREFIX + 2 + "," + VERSION_PREFIX + 3 + "\"");
assertSkipped(myTasks, 2, 3);
}
@Test
public void allQuoted() {
MigrationTaskSkipper.setDoNothingOnSkippedTasks(myTasks, "\"" + VERSION_PREFIX + 2 + "\",\"" + VERSION_PREFIX + 3 + "\"");
assertSkipped(myTasks, 2, 3);
}
@Test
public void oneQuoted() {
MigrationTaskSkipper.setDoNothingOnSkippedTasks(myTasks, "\"" + VERSION_PREFIX + 2 + "\"" );
assertSkipped(myTasks, 2);
}
@Test @Test
public void endComma() { public void endComma() {
MigrationTaskSkipper.setDoNothingOnSkippedTasks(myTasks, VERSION_PREFIX + 2 + "," + VERSION_PREFIX + 3 + ","); MigrationTaskSkipper.setDoNothingOnSkippedTasks(myTasks, VERSION_PREFIX + 2 + "," + VERSION_PREFIX + 3 + ",");