### Question:
AccountService extends ReactorAccountServiceGrpc.AccountServiceImplBase { @Override public Mono<AccountServiceProto.Account> getAccount(Mono<GetAccountRequest> request) { return request.flatMap(req -> async(() -> repository.getByName(req.getName()) .orElseThrow(() -> Status.NOT_FOUND .withDescription("Account for user '" + req.getName() + "' not found") .asRuntimeException()) ).doOnNext(account -> logger.debug("Account for user '{}' found", req.getName())) ).map(ACCOUNT_CONVERTER::convert); }  @Override Mono<AccountServiceProto.Account> getAccount(Mono<GetAccountRequest> request); @Override Mono<AccountServiceProto.Account> updateAccount(Mono<AccountServiceProto.Account> request);  }### Answer:
@Test public void shouldGetAccount() { Account account = stubAccount(); when(repository.getByName(NAME)).thenReturn(Optional.of(account)); StepVerifier.create(accountServiceStub.getAccount(GET_ACCOUNT_REQUEST)) .expectNextMatches(a -> { assertThat(a.getName()).isEqualTo(NAME); assertThat(a.getItemsList()).extracting( AccountServiceProto.Item::getType, AccountServiceProto.Item::getTitle, AccountServiceProto.Item::getMoney, AccountServiceProto.Item::getPeriod, AccountServiceProto.Item::getIcon ).containsExactlyInAnyOrder( tuple( ItemType.EXPENSE, GROCERY.getTitle(), moneyConverter().convert(GROCERY.getMoneyAmount()), TimePeriod.DAY, GROCERY.getIcon() ), tuple( ItemType.INCOME, SALARY.getTitle(), moneyConverter().convert(SALARY.getMoneyAmount()), TimePeriod.MONTH, SALARY.getIcon() ) ); assertThat(a.getSaving().getMoney()).isEqualTo(moneyConverter().convert(SAVING.getMoneyAmount())); assertThat(a.getSaving().getInterest()).isEqualTo(bigDecimalConverter().convert(SAVING.getInterest())); assertThat(a.getSaving().getDeposit()).isFalse(); assertThat(a.getSaving().getCapitalization()).isFalse(); assertThat(a.getUpdateTime()).isNotNull(); assertThat(a.getNote()).isEmpty(); return true; }).verifyComplete(); }
@Test public void shouldFailToFindAccountWhenNotFound() { when(repository.getByName(NAME)).thenReturn(Optional.empty()); StepVerifier.create(accountServiceStub.getAccount(GET_ACCOUNT_REQUEST)) .expectErrorMatches(t -> { assertThat(t).isInstanceOf(StatusRuntimeException.class); assertThat(Status.fromThrowable(t).getCode()).isEqualTo(Status.Code.NOT_FOUND); return true; }).verify(); }