### Question:
RecipientService extends ReactorRecipientServiceGrpc.RecipientServiceImplBase { @Override public Mono<RecipientServiceProto.Recipient> getRecipient(Mono<RecipientServiceProto.GetRecipientRequest> request) { return request.flatMap(req -> async(() -> repository.getByUsername(req.getUserName()) .orElseThrow(() -> Status.NOT_FOUND .withDescription("Notifications for user '" + req.getUserName() + "' not found") .asRuntimeException()) ).doOnNext(recipient -> logger.debug("Notifications for user '{}' found", recipient)) ).map(RECIPIENT_CONVERTER::convert); }  @Override Mono<RecipientServiceProto.Recipient> getRecipient(Mono<RecipientServiceProto.GetRecipientRequest> request); @Override Mono<RecipientServiceProto.Recipient> updateRecipient(Mono<RecipientServiceProto.Recipient> request);  }### Answer:
@Test void shouldGetRecipient() { Recipient recipient = stubRecipient(); when(repository.getByUsername(USERNAME)).thenReturn(Optional.of(recipient)); Mono<RecipientServiceProto.Recipient> recipientMono = recipientService.getRecipient(Mono.just(GET_RECIPINET_REQUEST)); StepVerifier.create(recipientMono) .expectNextMatches(r -> { assertThat(r.getUserName()).isEqualTo(USERNAME); assertThat(r.getEmail()).isEqualTo(EMAIL); assertThat(r.getNotificationsMap()).containsOnlyKeys(BACKUP.name()); assertThat(r.getNotificationsMap().get(BACKUP.name())).extracting( RecipientServiceProto.NotificationSettings::getActive, RecipientServiceProto.NotificationSettings::getFrequency, RecipientServiceProto.NotificationSettings::getNotifyDate ).containsExactly(true, Frequency.QUARTERLY.getKey(), Date.getDefaultInstance()); return true; }).verifyComplete(); }
@Test void shouldFailToGetRecipientWhenNoNotificationsFound() { when(repository.getByUsername(USERNAME)).thenReturn(Optional.empty()); Mono<RecipientServiceProto.Recipient> recipientMono = recipientService.getRecipient(Mono.just(GET_RECIPINET_REQUEST)); StepVerifier.create(recipientMono) .expectErrorMatches(t -> { assertThat(t).isInstanceOf(StatusRuntimeException.class); assertThat(Status.fromThrowable(t).getCode()).isEqualTo(Status.Code.NOT_FOUND); return true; }).verify(); }