### Question:
ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (matchingStatuses.size() > 1) { LOG.error("Multiple matching statuses for throwable={} statuses={}", throwable, matchingStatuses); return Optional.empty(); } return matchingStatuses.stream().findFirst(); } private  ExceptionStatusMapper(Builder builder);   }### Answer:
@Test public void returnsEmptyIfNoStatusMatches() { assertThat(mapper.statusFor(new UnmappedException()), isAbsent()); }
@Test public void retrievesStatus() { assertThat(mapper.statusFor(new Exception1()), isValue(REQUEST_TIMEOUT)); }
@Test public void exceptionMayNotBeMappedToMultipleExceptions() { ExceptionStatusMapper mapper = new ExceptionStatusMapper.Builder() .add(BAD_GATEWAY, Exception1.class) .add(GATEWAY_TIMEOUT, DoubleMappedException.class) .build(); LoggingTestSupport support = new LoggingTestSupport(ExceptionStatusMapper.class); Optional<HttpResponseStatus> status; try { status = mapper.statusFor(new DoubleMappedException()); } finally { assertThat(support.lastMessage(), is(loggingEvent(ERROR, "Multiple matching statuses for throwable=" + quote(DoubleMappedException.class.getName()) + " statuses=\\[502 Bad Gateway, 504 Gateway Timeout\\]" ))); } assertThat(status, isAbsent()); }