### Question:
GoodbyeMessage extends WampMessage { @Override public void serialize(JsonGenerator generator) throws IOException { generator.writeNumber(getCode()); generator.writeStartObject(); if (this.message != null) { generator.writeStringField("message", this.message); } generator.writeEndObject(); generator.writeString(this.reason); } GoodbyeMessage(WampError reason, @Nullable String message);  GoodbyeMessage(WampError reason); private  GoodbyeMessage(String reason, @Nullable String message); static GoodbyeMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); String getReason(); @Nullable String getMessage(); @Override String toString();  }### Answer:
@Test public void serializeTest() { GoodbyeMessage goodbyeMessage = new GoodbyeMessage(WampError.GOODBYE_AND_OUT, "theMessage"); assertThat(goodbyeMessage.getCode()).isEqualTo(6); assertThat(goodbyeMessage.getMessage()).isEqualTo("theMessage"); assertThat(goodbyeMessage.getReason()) .isEqualTo(WampError.GOODBYE_AND_OUT.getExternalValue()); String json = serializeToJson(goodbyeMessage); assertThat(json).isEqualTo( "[6,{\"message\":\"theMessage\"},\"wamp.error.goodbye_and_out\"]"); goodbyeMessage = new GoodbyeMessage(WampError.NO_SUCH_PROCEDURE); json = serializeToJson(goodbyeMessage); assertThat(json).isEqualTo("[6,{},\"wamp.error.no_such_procedure\"]"); }