Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge-beauregard committed Oct 29, 2020
1 parent f11ee53 commit 6cb5892
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,11 @@ Mono<Void>> purchaseSearchFetchResultOperation() {
public PollerFlux<PhoneNumberRelease, PhoneNumberRelease>
beginReleasePhoneNumbers(List<PhoneNumber> phoneNumbers, Duration pollInterval) {
Objects.requireNonNull(phoneNumbers, "'phoneNumbers' cannot be null.");
Objects.requireNonNull(pollInterval, "'pollInterval' cannot be null.");

if (pollInterval == null) {
pollInterval = defaultPollInterval;
}

return new PollerFlux<PhoneNumberRelease, PhoneNumberRelease>(pollInterval,
releaseNumbersActivationOperation(phoneNumbers),
releaseNumbersPollOperation(),
Expand All @@ -933,8 +937,7 @@ Mono<Void>> purchaseSearchFetchResultOperation() {
};
}

private Function<PollingContext<PhoneNumberRelease>,
Mono<PollResponse<PhoneNumberRelease>>>
private Function<PollingContext<PhoneNumberRelease>, Mono<PollResponse<PhoneNumberRelease>>>
releaseNumbersPollOperation() {
return pollingContext ->
getReleaseById(pollingContext.getLatestResponse().getValue().getReleaseId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,13 @@ public void beginCreateSearch(HttpClient httpClient) {
PhoneNumberAsyncClient client = this.getClient(httpClient);
PollerFlux<PhoneNumberSearch, PhoneNumberSearch> poller =
client.beginCreateSearch(createSearchOptions, duration);
AsyncPollResponse<PhoneNumberSearch, PhoneNumberSearch> asyncRes =
poller.takeUntil(apr -> apr.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED)
.blockLast();
PhoneNumberSearch testResult = asyncRes.getValue();
assertEquals(testResult.getPhoneNumbers().size(), 2);
assertNotNull(testResult.getSearchId());
Mono<AsyncPollResponse<PhoneNumberSearch, PhoneNumberSearch>> asyncRes = poller.last();
StepVerifier.create(asyncRes)
.assertNext(item -> {
assertEquals(item.getValue().getPhoneNumbers().size(), 2);
assertNotNull(item.getValue().getSearchId());
})
.verifyComplete();
}

@ParameterizedTest
Expand All @@ -500,14 +501,15 @@ public void beginReleasePhoneNumbers(HttpClient httpClient) {
PhoneNumber phoneNumber = new PhoneNumber(PHONENUMBER_TO_RELEASE);
List<PhoneNumber> phoneNumbers = new ArrayList<>();
phoneNumbers.add(phoneNumber);
Duration pollInterval = Duration.ofSeconds(5);
Duration pollInterval = Duration.ofSeconds(1);
PollerFlux<PhoneNumberRelease, PhoneNumberRelease> poller =
this.getClient(httpClient).beginReleasePhoneNumbers(phoneNumbers, pollInterval);
AsyncPollResponse<PhoneNumberRelease, PhoneNumberRelease> asyncRes =
poller.takeUntil(apr -> apr.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED).
blockLast();
PhoneNumberRelease testResult = asyncRes.getValue();
assertEquals(ReleaseStatus.COMPLETE, testResult.getStatus());
Mono<AsyncPollResponse<PhoneNumberRelease, PhoneNumberRelease>> asyncRes = poller.last();
StepVerifier.create(asyncRes)
.assertNext(item -> {
assertEquals(ReleaseStatus.COMPLETE, item.getValue().getStatus());
})
.verifyComplete();
}

private PhoneNumberAsyncClient getClient(HttpClient httpClient) {
Expand Down

0 comments on commit 6cb5892

Please sign in to comment.