FingerprintEncryptionResult extends FingerprintAuthenticationResult { public String getEncrypted() { if (!isSuccess()) { throw new IllegalAccessError("Fingerprint authentication was not successful, cannot access encryption result"); } return encrypted; } FingerprintEncryptionResult(FingerprintResult result, String message, String encrypted); String getEncrypted();  }
@Test public void getResultSuccess() throws Exception { String decrypted = "decrypted"; FingerprintEncryptionResult result = new FingerprintEncryptionResult(FingerprintResult.AUTHENTICATED, null, decrypted); assertNull(result.getMessage()); assertEquals(decrypted, result.getEncrypted()); }
@Test(expected = IllegalAccessError.class) public void getResultFailure() throws Exception { String message = "some error happened"; FingerprintEncryptionResult result = new FingerprintEncryptionResult(FingerprintResult.FAILED, message, null); assertEquals(message, result.getMessage()); result.getEncrypted(); }
@Test(expected = IllegalAccessError.class) public void getResultHelp() throws Exception { String message = "help"; FingerprintEncryptionResult result = new FingerprintEncryptionResult(FingerprintResult.HELP, message, null); assertEquals(message, result.getMessage()); result.getEncrypted(); }