Skip to content

Commit

Permalink
Communication - Refactor Common Tests to replace block with StepVerif…
Browse files Browse the repository at this point in the history
…ier (Azure#16644)

* Communication - Refactor Common Tests to replace block with StepVerifier

* Fix build

Co-authored-by: Minnie Liu <[email protected]>
  • Loading branch information
minnieliu and Minnie Liu authored Oct 21, 2020
1 parent f0445e4 commit 5788f10
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.net.MalformedURLException;
Expand Down Expand Up @@ -124,7 +124,8 @@ public void getRequestTest() throws MalformedURLException {
.build();

HttpRequest request = new HttpRequest(HttpMethod.GET, new URL("https://localhost?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
pipeline.send(request).block();
StepVerifier.create(pipeline.send(request))
.verifyComplete();
}

@Test
Expand All @@ -138,7 +139,8 @@ public void postRequestTest() throws MalformedURLException {

HttpRequest request = new HttpRequest(HttpMethod.POST, new URL("https://localhost?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
request.setBody("{\"propName\":\"name\", \"propValue\": \"value\"}");
pipeline.send(request).block();
StepVerifier.create(pipeline.send(request))
.verifyComplete();
}

@Test
Expand All @@ -152,7 +154,8 @@ public void postRequestWithPortTest() throws MalformedURLException {

HttpRequest request = new HttpRequest(HttpMethod.POST, new URL("https://localhost:443?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
request.setBody("{\"propName\":\"name\", \"propValue\": \"value\"}");
pipeline.send(request).block();
StepVerifier.create(pipeline.send(request))
.verifyComplete();
}

@Test
Expand All @@ -166,7 +169,8 @@ public void crossLanguageAsciiHashMatchTest() throws MalformedURLException {

HttpRequest request = new HttpRequest(HttpMethod.POST, new URL("https://localhost?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
request.setBody("banana");
pipeline.send(request).block();
StepVerifier.create(pipeline.send(request))
.verifyComplete();
}

@Test
Expand All @@ -180,7 +184,8 @@ public void crossLanguageUnicodeHashMatchTest() throws MalformedURLException {

HttpRequest request = new HttpRequest(HttpMethod.POST, new URL("https://localhost?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
request.setBody("😀");
pipeline.send(request).block();
StepVerifier.create(pipeline.send(request))
.verifyComplete();
}

@Test
Expand All @@ -194,7 +199,8 @@ public void patchRequestTest() throws MalformedURLException {

HttpRequest request = new HttpRequest(HttpMethod.PATCH, new URL("https://localhost?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
request.setBody("{\"propName\":\"name1\", \"propValue\": \"value1\"}");
pipeline.send(request).block();
StepVerifier.create(pipeline.send(request))
.verifyComplete();
}

@Test
Expand All @@ -208,7 +214,8 @@ public void putRequestTest() throws MalformedURLException {

HttpRequest request = new HttpRequest(HttpMethod.PUT, new URL("https://localhost?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
request.setBody("{\"propName\":\"name2\", \"propValue\": \"value2\"}");
pipeline.send(request).block();
StepVerifier.create(pipeline.send(request))
.verifyComplete();
}

@Test
Expand All @@ -221,7 +228,8 @@ public void deleteRequestTest() throws MalformedURLException {
.build();

HttpRequest request = new HttpRequest(HttpMethod.DELETE, new URL("https://localhost?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
pipeline.send(request).block();
StepVerifier.create(pipeline.send(request))
.verifyComplete();
}

@Test
Expand All @@ -234,9 +242,8 @@ public void httpRequestTest() throws MalformedURLException {
.build();

HttpRequest request = new HttpRequest(HttpMethod.GET, new URL("http://localhost?id=b93a5ef4-f622-44d8-a80b-ff983122554e"));
assertThrows(RuntimeException.class, () -> {
pipeline.send(request).block();
});
StepVerifier.create(pipeline.send(request))
.expectError(RuntimeException.class);
}

}

0 comments on commit 5788f10

Please sign in to comment.