@Test public void returnsNotFoundIfNoWardWhenGettingTownStreetsByWardCode() throws Exception { User u = user().build(); String wardCode = "E0911135"; given(wardService.getByCode(wardCode, u)) .willReturn(Try.failure(new NotFoundFailure("failed"))); Try<StreetsByWardResponse> streets = underTest.getTownStreetsByWardCode(wardCode, u); assertThat(streets.isSuccess(), is(false)); assertThat(streets.getFailure(), instanceOf(NotFoundFailure.class)); }
public Try<StreetsByWardResponse> getTownStreetsByWardCode(String wardCode, User user) { return wardService .getByCode(wardCode, user) .flatMap(ward -> pafAddressService.getStreetsByWard(ward.getCode())); }
AddressService { public Try<StreetsByWardResponse> getTownStreetsByWardCode(String wardCode, User user) { return wardService .getByCode(wardCode, user) .flatMap(ward -> pafAddressService.getStreetsByWard(ward.getCode())); } }
AddressService { public Try<StreetsByWardResponse> getTownStreetsByWardCode(String wardCode, User user) { return wardService .getByCode(wardCode, user) .flatMap(ward -> pafAddressService.getStreetsByWard(ward.getCode())); } @Autowired  AddressService(WardService wardService,
                          PafAddressService pafAddressService); }
AddressService { public Try<StreetsByWardResponse> getTownStreetsByWardCode(String wardCode, User user) { return wardService .getByCode(wardCode, user) .flatMap(ward -> pafAddressService.getStreetsByWard(ward.getCode())); } @Autowired  AddressService(WardService wardService,
                          PafAddressService pafAddressService); Try<StreetsByWardResponse> getTownStreetsByWardCode(String wardCode, User user); }
AddressService { public Try<StreetsByWardResponse> getTownStreetsByWardCode(String wardCode, User user) { return wardService .getByCode(wardCode, user) .flatMap(ward -> pafAddressService.getStreetsByWard(ward.getCode())); } @Autowired  AddressService(WardService wardService,
                          PafAddressService pafAddressService); Try<StreetsByWardResponse> getTownStreetsByWardCode(String wardCode, User user);  }