### Question:
TransactionalSpamProtectionService extends AbstractTransactionalEntityService<SpamRule, SpamRuleDao> implements SpamProtectionService { @Override public void saveOrUpdate(SpamRule rule) throws NotFoundException { try { Pattern.compile(rule.getRegex()); } catch (PatternSyntaxException ex){ throw new ValidationException(Sets.newHashSet(new ValidationError("regex", ex.getDescription() + " near index " + ex.getIndex()))); } getDao().saveOrUpdate(rule); } TransactionalSpamProtectionService(SpamRuleDao dao); @Override boolean isEmailInBlackList(String email); @Override void saveOrUpdate(SpamRule rule); @Override void deleteRule(long id); @Override List<SpamRule> getAllRules(); @Override SpamRule get(Long id);  }### Answer:
@Test(expectedExceptions = ValidationException.class) public void shouldThrowValidationExceptionIfRegexIsNotValid() throws NotFoundException { String brokenRegex = "())"; SpamRule spamRule = new SpamRule(brokenRegex, alphanumeric(255), bool()); spamProtectionService.saveOrUpdate(spamRule); }