Endpoints { Optional<MessageEndpoint<I, M>> get(InboxLabel label, M envelope) { if (!endpoints.containsKey(label)) { return Optional.empty(); } return Optional.of(endpoints.get(label) .apply(envelope)); }    }
@Test @DisplayName("return `Optional.empty()` if no endpoint providers configured for the label") void returnEmpty() { Endpoints<String, CommandEnvelope> endpoints = new Endpoints<>(); Optional<MessageEndpoint<String, CommandEnvelope>> result = endpoints.get(REACT_UPON_EVENT, cmdEnvelope()); assertThat(result.isPresent()).isFalse(); }