### Question:
CramMD5Mechanism extends AbstractMechanism { @Override public boolean isApplicable(String username, String password, Principal localPrincipal) { return username != null && username.length() > 0 && password != null && password.length() > 0; }  @Override int getPriority(); @Override String getName(); @Override byte[] getInitialResponse(); @Override byte[] getChallengeResponse(byte[] challenge); @Override void verifyCompletion(); @Override boolean isApplicable(String username, String password, Principal localPrincipal);  }### Answer:
@Test public void testIsNotApplicableWithNoCredentials() { CramMD5Mechanism mech = new CramMD5Mechanism(); assertFalse("Should not be applicable with no credentials", mech.isApplicable(null, null, null)); }
@Test public void testIsNotApplicableWithNoUser() { CramMD5Mechanism mech = new CramMD5Mechanism(); assertFalse("Should not be applicable with no username", mech.isApplicable(null, "pass", null)); }
@Test public void testIsNotApplicableWithNoPassword() { CramMD5Mechanism mech = new CramMD5Mechanism(); assertFalse("Should not be applicable with no password", mech.isApplicable("user", null, null)); }
@Test public void testIsNotApplicableWithEmtpyUser() { CramMD5Mechanism mech = new CramMD5Mechanism(); assertFalse("Should not be applicable with empty username", mech.isApplicable("", "pass", null)); }
@Test public void testIsNotApplicableWithEmtpyPassword() { CramMD5Mechanism mech = new CramMD5Mechanism(); assertFalse("Should not be applicable with empty password", mech.isApplicable("user", "", null)); }
@Test public void testIsNotApplicableWithEmtpyUserAndPassword() { CramMD5Mechanism mech = new CramMD5Mechanism(); assertFalse("Should not be applicable with empty user and password", mech.isApplicable("", "", null)); }
@Test public void testIsApplicableWithUserAndPassword() { CramMD5Mechanism mech = new CramMD5Mechanism(); assertTrue("Should be applicable with user and password", mech.isApplicable("user", "password", null)); }
@Test public void testIsApplicableWithUserAndPasswordAndPrincipal() { CramMD5Mechanism mech = new CramMD5Mechanism(); assertTrue("Should be applicable with user and password and principal", mech.isApplicable("user", "password", new Principal() { @Override public String getName() { return "name"; } })); }