YkneoBitcoinSoft implements YkneoBitcoin { @Override public void setUserPin(String oldPin, String newPin) throws IncorrectPINException, IOException { unlockUser(oldPin); userPin = newPin; } YkneoBitcoinSoft(); @Override byte[] exportExtendedPublicKey(); @Override String getAppletVersion(); @Override boolean isKeyLoaded(); @Override void unlockUser(String pin); @Override void unlockAdmin(String pin); @Override boolean isUserUnlocked(); @Override boolean isAdminUnlocked(); @Override void setUserPin(String oldPin, String newPin); @Override void setAdminPin(String oldPin, String newPin); @Override void resetUserPin(String newPin); @Override byte[] getHeader(); @Override void setAdminRetryCount(int attempts); @Override void setUserRetryCount(int attempts); @Override byte[] getPublicKey(boolean compress, int... index); @Override byte[] sign(byte[] hash, int... index); @Override byte[] generateMasterKeyPair(boolean allowExport, boolean returnPrivateKey, boolean testnetKey); @Override void importExtendedKeyPair(byte[] extendedPrivateKey, boolean allowExport);  }
@Test public void testSetUserPin() throws Exception { String newPin = "hello world"; neo.setUserPin(userPin, newPin); try { neo.unlockUser(userPin); fail("Unlocked with wrong PIN!"); } catch (IncorrectPINException e) { assertEquals(5, e.getTriesRemaining()); assertEquals(PinMode.USER, e.getPinMode()); assertFalse(neo.isUserUnlocked()); } neo.unlockUser(newPin); neo.setUserPin(newPin, userPin); }