### Question:
SerialPortParameters { @Override public String toString() { return "Baud Rate: "+ baudrate + ", Data Bits: " + dataBits + ", Stop Bits: " + stopBits + ", Parity: " + parity + ", Flow Control: " + flowControl; } SerialPortParameters(int baudrate, int dataBits, int stopBits, int parity, int flowControl); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final int baudrate; final int dataBits; final int stopBits; final int parity; final int flowControl; }### Answer:
@Test public void testToString() { int baudrate = 9600; int dataBits = 8; int stopBits = 1; int parity = 0; int flowControl = 0; SerialPortParameters parameters = new SerialPortParameters(baudrate, dataBits, stopBits, parity, flowControl); String result = parameters.toString(); assertThat("toString() method does not produce the expected output", result, is(equalTo( String.format("Baud Rate: %d, Data Bits: %d, Stop Bits: %d, Parity: %d, Flow Control: %d", baudrate, dataBits, stopBits, parity, flowControl)))); }