MessageIdExtractor { public long getUniqueIdFromMessage(Message requestMessage, Encryptor handshake, long connectionId) throws AuthenticationRequiredException { AuthIds aIds = getAuthIdsFromMessage(requestMessage, handshake); if (connectionId != aIds.getConnectionId()) { throw new AuthenticationRequiredException( "No security credentials are provided"); } return aIds.getUniqueId(); }  long getUniqueIdFromMessage(Message requestMessage, Encryptor handshake, long connectionId);  }
@Test public void getUniqueIdFromMessage() throws Exception { assertThat(messageIdExtractor.getUniqueIdFromMessage(requestMessage, encryptor, connectionId)) .isEqualTo(uniqueId); }
@Test public void throwsWhenConnectionIdsDoNotMatch() throws Exception { long otherConnectionId = 789L; assertThatThrownBy(() -> messageIdExtractor.getUniqueIdFromMessage(requestMessage, encryptor, otherConnectionId)).isInstanceOf(AuthenticationRequiredException.class); }