/** * Ensures, that a {@link NullPointerException} is thrown by the method, which allows to set the * regular expression, if the regular expression is null. */ public final void testSetRegexThrowsException() { try { RegexConstraint regexConstraint = new RegexConstraint(Pattern.compile(".")); regexConstraint.setRegex(null); Assert.fail(); } catch (NullPointerException e) { } }
/** Tests the functionality of the isSatisfied-method, if it fails. */ public final void testIsSatisfiedFails() { RegexConstraint regexConstraint = new RegexConstraint(REGEX); assertFalse(regexConstraint.isSatisfied("abcdefghijkl")); }
/** Tests the functionality of the isSatisfied-method, if it succeeds. */ public final void testIsSatisfiedSucceeds() { RegexConstraint regexConstraint = new RegexConstraint(REGEX); assertTrue(regexConstraint.isSatisfied("0123456789")); }
/** Tests the functionality of the method, which allows to set the regular expression. */ public final void testSetRegex() { RegexConstraint regexConstraint = new RegexConstraint(Pattern.compile(".")); regexConstraint.setRegex(REGEX); assertEquals(REGEX, regexConstraint.getRegex()); }
/** Tests, if all properties are set correctly by the constructor. */ public final void testConstructor() { RegexConstraint regexConstraint = new RegexConstraint(REGEX); assertEquals(REGEX, regexConstraint.getRegex()); }