### Question:
KeySerialNumber implements Serializable, Loggeable { public void dump (PrintStream p, String indent) { String inner = indent + " "; p.println(indent + "<key-serial-number>"); p.println(inner + "<base-key-id>" + getBaseKeyID() + "</base-key-id>"); p.println(inner + "<device-id>" + getDeviceID() + "</device-id>"); p.println(inner + "<transaction-counter>" + getTransactionCounter() + "</transaction-counter"); p.println(indent + "</key-serial-number>"); } KeySerialNumber();  KeySerialNumber(String baseKeyID, String deviceID, String transactionCounter); void setBaseKeyID(String baseKeyID); String getBaseKeyID(); void setDeviceID(String deviceID); String getDeviceID(); void setTransactionCounter(String transactionCounter); String getTransactionCounter(); void dump(PrintStream p, String indent);  }### Answer:
@Test public void testDump() throws Throwable { PrintStream p = new PrintStream(new ByteArrayOutputStream(), true, "UTF-8"); Object[] objects = new Object[1]; p.format("testKeySerialNumberParam1", objects); new KeySerialNumber("testKeySerialNumberBaseKeyID", "testKeySerialNumberDeviceID", "testKeySerialNumberTransactionCounter") .dump(p, "testKeySerialNumberIndent"); assertTrue(true, "Test completed without Exception"); }
@Test public void testDumpThrowsNullPointerException() throws Throwable { try { new KeySerialNumber().dump(null, "testKeySerialNumberIndent"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.io.PrintStream.println(String)\" because \"p\" is null", ex.getMessage(), "ex.getMessage()"); } } }