use of reactivefeign.testcase.domain.Bill in project feign-reactive by kptfh.
the class ReactiveHttpClientTest method testPayBill_success.
@Test
public void testPayBill_success() {
Bill bill = Bill.makeBill(new OrderGenerator().generate(30));
client.payBill(bill).block();
}
use of reactivefeign.testcase.domain.Bill in project feign-reactive by kptfh.
the class LoggerTest method shouldLog.
@Test
public void shouldLog() throws Exception {
Level originalLevel = setLogLevel(Level.TRACE);
IceCreamOrder order = new OrderGenerator().generate(20);
Bill billExpected = Bill.makeBill(order);
wireMockRule.stubFor(post(urlEqualTo("/icecream/orders")).withRequestBody(equalTo(TestUtils.MAPPER.writeValueAsString(order))).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(TestUtils.MAPPER.writeValueAsString(billExpected))));
IcecreamServiceApi client = builder().target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
Mono<Bill> billMono = client.makeOrder(order);
// no logs before subscription
ArgumentCaptor<LogEvent> argumentCaptor = ArgumentCaptor.forClass(LogEvent.class);
Mockito.verify(appender, never()).append(argumentCaptor.capture());
billMono.block();
Mockito.verify(appender, times(7)).append(argumentCaptor.capture());
List<LogEvent> logEvents = argumentCaptor.getAllValues();
assertLogEvent(logEvents, 0, Level.DEBUG, "[IcecreamServiceApi#makeOrder]--->POST http://localhost");
assertLogEvent(logEvents, 1, Level.TRACE, "[IcecreamServiceApi#makeOrder] REQUEST HEADERS\n" + "Accept:[application/json]");
assertLogEvent(logEvents, 2, Level.TRACE, "[IcecreamServiceApi#makeOrder] REQUEST BODY\n" + "IceCreamOrder{ id=20, balls=");
assertLogEvent(logEvents, 3, Level.TRACE, "[IcecreamServiceApi#makeOrder] RESPONSE HEADERS", "Content-Type:application/json");
assertLogEvent(logEvents, 4, Level.DEBUG, "[IcecreamServiceApi#makeOrder]<--- headers takes");
assertLogEvent(logEvents, 5, Level.TRACE, "[IcecreamServiceApi#makeOrder] RESPONSE BODY\n" + "reactivefeign.testcase.domain.Bill");
assertLogEvent(logEvents, 6, Level.DEBUG, "[IcecreamServiceApi#makeOrder]<--- body takes");
setLogLevel(originalLevel);
}
use of reactivefeign.testcase.domain.Bill in project feign-reactive by kptfh.
the class ReactiveHttpClientTest method testMakeOrder_success.
@Test
public void testMakeOrder_success() {
IceCreamOrder order = new OrderGenerator().generate(20);
Bill bill = client.makeOrder(order).block();
assertThat(bill).isEqualToComparingFieldByField(Bill.makeBill(order));
}
use of reactivefeign.testcase.domain.Bill in project feign-reactive by kptfh.
the class CompressionTest method testCompression.
@Test
public void testCompression() throws JsonProcessingException {
IceCreamOrder order = new OrderGenerator().generate(20);
Bill billExpected = Bill.makeBill(order);
wireMockRule.stubFor(post(urlEqualTo("/icecream/orders")).withHeader("Accept-Encoding", containing("gzip")).withRequestBody(equalTo(TestUtils.MAPPER.writeValueAsString(order))).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withHeader("Content-Encoding", "gzip").withBody(Gzip.gzip(TestUtils.MAPPER.writeValueAsString(billExpected)))));
IcecreamServiceApi client = builder(new ReactiveOptions.Builder().setTryUseCompression(true).build()).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
Mono<Bill> bill = client.makeOrder(order);
StepVerifier.create(bill).expectNextMatches(equalsComparingFieldByFieldRecursively(billExpected)).verifyComplete();
}
Aggregations