### Question:
RpcMessage { protected void validateMessageType(Type expected) { if (expected != messageType) { throw new IllegalArgumentException("Message type is expected to be " + expected + " but got " + messageType); } } RpcMessage(int xid, Type messageType); abstract XDR write(XDR xdr); int getXid(); Type getMessageType();  }### Answer:
@Test public void testValidateMessage() { RpcMessage msg = getRpcMessage(0, RpcMessage.Type.RPC_CALL); msg.validateMessageType(RpcMessage.Type.RPC_CALL); }
@Test(expected = IllegalArgumentException.class) public void testValidateMessageException() { RpcMessage msg = getRpcMessage(0, RpcMessage.Type.RPC_CALL); msg.validateMessageType(RpcMessage.Type.RPC_REPLY); }