Skip to content

Commit

Permalink
chore: Replace replaceAll with replace
Browse files Browse the repository at this point in the history
  • Loading branch information
en-milie committed Jun 8, 2024
1 parent b856510 commit c875228
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class StringGenerator {
private static final org.cornutum.regexpgen.Provider REGEXPGEN_PROVIDER = Provider.forEcmaScript();

private static final PrettyLogger LOGGER = PrettyLoggerFactory.getLogger(StringGenerator.class);
public static final String CASE_INSENSITIVE = "\\(\\?i\\)";
public static final String CASE_INSENSITIVE = "(?i)";

private StringGenerator() {
//ntd
Expand Down Expand Up @@ -181,7 +181,7 @@ public static String cleanPattern(String pattern) {
pattern = StringUtils.removeEnd(pattern, "/");
}
pattern = pattern.replaceAll(EMPTY_PATTERN, EMPTY);
pattern = pattern.replaceAll(CASE_INSENSITIVE, EMPTY);
pattern = pattern.replace(CASE_INSENSITIVE, EMPTY);
return pattern;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import java.util.List;

@QuarkusTest
class StringGeneratorTest {

Expand Down Expand Up @@ -134,4 +136,12 @@ void shouldRemoveCaseInsensitive() {
String generated = StringGenerator.cleanPattern("^(?i)(http:\\/\\/|https:\\/\\/)([a-z0-9./\\-_.~+=:;%&?]+)$");
Assertions.assertThat(generated).isEqualTo("^(http:\\/\\/|https:\\/\\/)([a-z0-9./\\-_.~+=:;%&?]+)$");
}

@Test
void shouldGenerateLeftBoundaryForEnum() {
Schema<String> schema = new StringSchema();
schema.setEnum(List.of("test", "b", "c"));
String generated = StringGenerator.generateLeftBoundString(schema);
Assertions.assertThat(generated).hasSize(4);
}
}

0 comments on commit c875228

Please sign in to comment.