### Question:
EncryptedPIN implements Serializable, Loggeable { public void setAccountNumber (String extractedAccountNumber) { if(extractedAccountNumber.length() != 12) throw new InvalidParameterException( "Extracted account number length should be 12, got '" +ISOUtil.protect(extractedAccountNumber) + "'" ); this.accountNumber = extractedAccountNumber; } EncryptedPIN();  EncryptedPIN(byte[] pinBlock, byte pinBlockFormat, String accountNumber);  EncryptedPIN(byte[] pinBlock, byte pinBlockFormat, String accountNumber, boolean extract);  EncryptedPIN(String pinBlockHexString, byte pinBlockFormat, String accountNumber);  EncryptedPIN(String pinBlockHexString, byte pinBlockFormat, String accountNumber, boolean extract); void dump(PrintStream p, String indent); void setPINBlock(byte[] pinBlock); byte[] getPINBlock(); void setPINBlockFormat(byte pinBlockFormat); byte getPINBlockFormat(); void setAccountNumber(String extractedAccountNumber); String getAccountNumber(); static String extractAccountNumberPart(String accountNumber);  }### Answer:
@Test public void testSetAccountNumber() throws Throwable { byte[] pinBlock = new byte[3]; EncryptedPIN encryptedPIN = new EncryptedPIN(pinBlock, (byte) 0, "testEncryptedPINAccountNumber"); try { encryptedPIN.setAccountNumber("13CharactersX"); fail("Expected InvalidParameterException"); } catch (InvalidParameterException ignored) { } }
@Test public void testSetAccountNumber1() throws Throwable { EncryptedPIN encryptedPIN = new EncryptedPIN("testEncryptedPINPinBlockHexString1", (byte) 0, "testEncryptedPINAccountNumber"); encryptedPIN.setAccountNumber("12Characters"); assertEquals("12Characters", encryptedPIN.accountNumber, "encryptedPIN.accountNumber"); }
@Test public void testSetAccountNumberThrowsNullPointerException() throws Throwable { EncryptedPIN encryptedPIN = new EncryptedPIN("testEncryptedPINPinBlockHexString1", (byte) 0, "testEncryptedPINAccountNumber"); try { encryptedPIN.setAccountNumber(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"String.length()\" because \"extractedAccountNumber\" is null", ex.getMessage(), "ex.getMessage()"); } assertEquals("AccountNumbe", encryptedPIN.accountNumber, "encryptedPIN.accountNumber"); } }