Skip to content

Commit

Permalink
Using StepVerifier in async tests (Azure#94)
Browse files Browse the repository at this point in the history
* Ensure using StepVerifier in all Async tests
  • Loading branch information
rabee333 authored Sep 22, 2019
1 parent eef180c commit deb5bbd
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.azure.search.test.environment.models.ModelWithPrimitiveCollections;
import org.junit.Assert;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import java.text.ParseException;
import java.util.Arrays;
Expand All @@ -25,8 +26,10 @@ public void canGetStaticallyTypedDocument() throws ParseException {
uploadDocuments(client, INDEX_NAME, expected);

Mono<Document> result = client.getDocument(expected.hotelId());
Hotel actual = result.block().as(Hotel.class);
Assert.assertEquals(expected, actual);

StepVerifier.create(result)
.assertNext(res -> Assert.assertEquals(expected, res.as(Hotel.class)))
.verifyComplete();
}

@Override
Expand All @@ -35,8 +38,10 @@ public void canGetStaticallyTypedDocumentWithNullOrEmptyValues() {
uploadDocuments(client, INDEX_NAME, expected);

Mono<Document> result = client.getDocument(expected.hotelId());
Hotel actual = result.block().as(Hotel.class);
Assert.assertEquals(expected, actual);

StepVerifier.create(result)
.assertNext(res -> Assert.assertEquals(expected, res.as(Hotel.class)))
.verifyComplete();
}

@Override
Expand All @@ -45,8 +50,10 @@ public void canGetStaticallyTypedDocumentWithPascalCaseFields() {
uploadDocuments(client, INDEX_NAME, expected);

Mono<Document> result = client.getDocument(expected.hotelId());
Hotel actual = result.block().as(Hotel.class);
Assert.assertEquals(expected, actual);

StepVerifier.create(result)
.assertNext(res -> Assert.assertEquals(expected, res.as(Hotel.class)))
.verifyComplete();
}

@Override
Expand All @@ -55,8 +62,10 @@ public void canRoundtripStaticallyTypedPrimitiveCollections() throws ParseExcept
uploadDocuments(client, MODEL_WITH_VALUE_TYPES_INDEX_NAME, expected);

Mono<Document> result = client.getDocument(expected.key);
ModelWithPrimitiveCollections actual = result.block().as(ModelWithPrimitiveCollections.class);
Assert.assertEquals(expected, actual);

StepVerifier.create(result)
.assertNext(res -> Assert.assertEquals(expected, res.as(ModelWithPrimitiveCollections.class)))
.verifyComplete();
}

@Override
Expand All @@ -65,16 +74,20 @@ public void getStaticallyTypedDocumentSetsUnselectedFieldsToNull() throws ParseE

Hotel expected = new Hotel()
.hotelName("Countryside Hotel")
.description("Save up to 50% off traditional hotels. Free WiFi, great location near downtown, full kitchen, washer & dryer, 24/7 support, bowling alley, fitness center and more.")
.description(
"Save up to 50% off traditional hotels. Free WiFi, great location near downtown, full kitchen, "
+ "washer & dryer, 24/7 support, bowling alley, fitness center and more.")
.address(new HotelAddress().city("Durham"))
.rooms(Arrays.asList(new HotelRoom().baseRate(2.44), new HotelRoom().baseRate(7.69)));

uploadDocuments(client, INDEX_NAME, indexedDoc);

List<String> selectedFields = Arrays.asList("Description", "HotelName", "Address/City", "Rooms/BaseRate");
Mono<Document> result = client.getDocument(indexedDoc.hotelId(), selectedFields, new SearchRequestOptions());
Hotel actual = result.block().as(Hotel.class);
Assert.assertEquals(expected, actual);

StepVerifier.create(result)
.assertNext(res -> Assert.assertEquals(expected, res.as(Hotel.class)))
.verifyComplete();
}

@Override
Expand Down
Loading

0 comments on commit deb5bbd

Please sign in to comment.