Java Code Examples for org.mockito.BDDMockito#BDDMyOngoingStubbing

The following examples show how to use org.mockito.BDDMockito#BDDMyOngoingStubbing . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CircuitBreakerSecuredJdbcClientTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> void givenExecuteQueryReturning(List<Future<T>> results) {
    BDDMockito.BDDMyOngoingStubbing<Future<Object>> given =
            given(wrappedJdbcClient.executeQuery(any(), any(), any(), any()));
    for (Future<T> result : results) {
        given = given.willReturn((Future<Object>) result);
    }
}
 
Example 2
Source File: CircuitBreakerSecuredHttpClientTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> void givenHttpClientReturning(T... results) {
    BDDMockito.BDDMyOngoingStubbing<Future<HttpClientResponse>> stubbing =
            given(wrappedHttpClient.request(any(), anyString(), any(), any(), anyLong()));
    for (T result : results) {
        if (result instanceof Exception) {
            stubbing = stubbing.willReturn(Future.failedFuture((Throwable) result));
        } else {
            stubbing = stubbing.willReturn(Future.succeededFuture((HttpClientResponse) result));
        }
    }
}
 
Example 3
Source File: CircuitBreakerSecuredGeoLocationServiceTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> void givenWrappedGeoLocationReturning(Future... results) {
    BDDMockito.BDDMyOngoingStubbing<Future<GeoInfo>> given =
            given(wrappedGeoLocationService.lookup(any(), any()));
    for (Future<T> result : results) {
        given = given.willReturn((Future<GeoInfo>) result);
    }
}
 
Example 4
Source File: HttpBidderRequesterTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private void givenHttpClientReturnsResponses(HttpClientResponse... httpClientResponses) {
    BDDMockito.BDDMyOngoingStubbing<Future<HttpClientResponse>> stubbing =
            given(httpClient.request(any(), anyString(), any(), any(), anyLong()));

    // setup multiple answers
    for (HttpClientResponse httpClientResponse : httpClientResponses) {
        stubbing = stubbing.willReturn(Future.succeededFuture(httpClientResponse));
    }
}
 
Example 5
Source File: HttpAdapterConnectorTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private void givenHttpClientReturnsResponses(HttpClientResponse... httpClientResponses) {
    BDDMockito.BDDMyOngoingStubbing<Future<HttpClientResponse>> stubbing =
            given(httpClient.request(any(), anyString(), any(), any(), anyLong()));

    // setup multiple answers
    for (HttpClientResponse httpClientResponse : httpClientResponses) {
        stubbing = stubbing.willReturn(Future.succeededFuture(httpClientResponse));
    }
}
 
Example 6
Source File: MobileNetworkInformationTest.java    From mobile-messaging-sdk-android with Apache License 2.0 4 votes vote down vote up
private void givenMethodWillReturn(String method, String[] values) {
    BDDMockito.BDDMyOngoingStubbing<String> stubbing = given(method);
    for (String value : values) {
        stubbing = stubbing.willReturn(value);
    }
}
 
Example 7
Source File: WithBDDMockito.java    From mockito-java8 with Apache License 2.0 4 votes vote down vote up
/**
 * Delegates call to {@link BDDMockito#given(Object)}
 */
default <T> BDDMockito.BDDMyOngoingStubbing<T> given(T methodCall) {
    return BDDMockito.given(methodCall);
}