@Test public void detectsAtlasDbHttpClientAgentInPresenceOfUnparseableHeaders() { assertThat(ProtocolAwareExceptionMapper.parseProtocolVersionFromUserAgentHeader( ImmutableList.of("Ich weiß nicht, was ein 'User-Agent' bedeutet", FORMATTED_USER_AGENT_WITH_HTTP_CLIENT))) .contains(HTTP_PROTOCOL_VERSION); }
@VisibleForTesting static Optional<String> parseProtocolVersionFromUserAgentHeader(@Nonnull List<String> userAgentHeader) { return userAgentHeader .stream() .map(UserAgents::tryParse) .map(UserAgent::informational) .flatMap(List::stream) .filter(agent -> agent.name().equals(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT)) .findFirst() .map(UserAgent.Agent::version); }
ProtocolAwareExceptionMapper implements ExceptionMapper<E> { @VisibleForTesting static Optional<String> parseProtocolVersionFromUserAgentHeader(@Nonnull List<String> userAgentHeader) { return userAgentHeader .stream() .map(UserAgents::tryParse) .map(UserAgent::informational) .flatMap(List::stream) .filter(agent -> agent.name().equals(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT)) .findFirst() .map(UserAgent.Agent::version); } }
ProtocolAwareExceptionMapper implements ExceptionMapper<E> { @VisibleForTesting static Optional<String> parseProtocolVersionFromUserAgentHeader(@Nonnull List<String> userAgentHeader) { return userAgentHeader .stream() .map(UserAgents::tryParse) .map(UserAgent::informational) .flatMap(List::stream) .filter(agent -> agent.name().equals(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT)) .findFirst() .map(UserAgent.Agent::version); }  }
ProtocolAwareExceptionMapper implements ExceptionMapper<E> { @VisibleForTesting static Optional<String> parseProtocolVersionFromUserAgentHeader(@Nonnull List<String> userAgentHeader) { return userAgentHeader .stream() .map(UserAgents::tryParse) .map(UserAgent::informational) .flatMap(List::stream) .filter(agent -> agent.name().equals(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT)) .findFirst() .map(UserAgent.Agent::version); }  @Override Response toResponse(E exception); }
ProtocolAwareExceptionMapper implements ExceptionMapper<E> { @VisibleForTesting static Optional<String> parseProtocolVersionFromUserAgentHeader(@Nonnull List<String> userAgentHeader) { return userAgentHeader .stream() .map(UserAgents::tryParse) .map(UserAgent::informational) .flatMap(List::stream) .filter(agent -> agent.name().equals(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT)) .findFirst() .map(UserAgent.Agent::version); }  @Override Response toResponse(E exception);  }