#1005 Improve restricted user feature (performance, error handling)

- Move check for restricted user into validation service
- Keep restrictions in a map by name for fast lookup, avoid splitting Strings on every call
- Gracefully handle case when entry does not have the expected ';' and log exception
This commit is contained in:
ljacqu
2017-03-14 22:26:19 +01:00
parent 62368b1cda
commit 1da74cb987
6 changed files with 148 additions and 45 deletions
@@ -95,4 +95,14 @@ public class StringUtilsTest {
public void shouldHaveHiddenConstructor() {
TestHelper.validateHasOnlyPrivateEmptyConstructor(StringUtils.class);
}
@Test
public void shouldCheckIfHasNeedleInWord() {
// given/when/then
assertThat(StringUtils.isInsideString('@', "@hello"), equalTo(false));
assertThat(StringUtils.isInsideString('?', "absent"), equalTo(false));
assertThat(StringUtils.isInsideString('-', "abcd-"), equalTo(false));
assertThat(StringUtils.isInsideString('@', "hello@example"), equalTo(true));
assertThat(StringUtils.isInsideString('@', "D@Z"), equalTo(true));
}
}