SMTPStartTlsResponse extends SMTPResponse implements StartTlsResponse { @Override public Response immutable() { return new StartTlsResponse() { @Override public boolean isEndSession() { return SMTPStartTlsResponse.this.isEndSession(); } @Override public String getRetCode() { return SMTPStartTlsResponse.this.getRetCode(); } @Override public List<CharSequence> getLines() { return SMTPStartTlsResponse.this.getLines(); } }; } SMTPStartTlsResponse(String code, CharSequence description);  SMTPStartTlsResponse(String rawLine); @Override Response immutable();  }
@Test public void testImmutable() { SMTPStartTlsResponse response = new SMTPStartTlsResponse("554", "Reject"); assertThat(response).isInstanceOf(StartTlsResponse.class); assertThat(response.immutable()).isInstanceOf(StartTlsResponse.class); }