### Question:
PasswordChecker { public static void check(String password) throws CheckerException { for (Rule r : Rule.values()) { if (!r.getItem().test(password)) { throw new CheckerException(r.getMessage()); } } } private  PasswordChecker(); static void check(String password);  }### Answer:
@Test public void lengthTest() { String password = "aA3456"; try { PasswordChecker.check(password); fail("exception expected"); } catch (PasswordChecker.CheckerException e) { assertTrue(e.getMessage().contains("seven (7) characters")); } }
@Test public void upperTest() { String password = "a234567"; try { PasswordChecker.check(password); fail("exception expected"); } catch (PasswordChecker.CheckerException e) { assertTrue(e.getMessage().contains("UPPER character")); } }
@Test public void lowerTest() { String password = "A234567"; try { PasswordChecker.check(password); fail("exception expected"); } catch (PasswordChecker.CheckerException e) { assertTrue(e.getMessage().contains("lowercase character")); } }
@Test public void digitTest() { String password = "AaAAAAA"; try { PasswordChecker.check(password); fail("exception expected"); } catch (PasswordChecker.CheckerException e) { assertTrue(e.getMessage().contains("numeric character")); } }
@Test public void userTest() { String password = "Aa345678asi"; try { PasswordChecker.check(password); fail("exception expected"); } catch (PasswordChecker.CheckerException e) { assertTrue(e.getMessage().contains("consecutive characters from your user account name")); } }
@Test public void validTest() throws PasswordChecker.CheckerException { String password = "Aa345678"; PasswordChecker.check(password); }