Search in sources :

Example 1 with GetAllLoadBalancersRequest

use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest in project titus-control-plane by Netflix.

the class LoadBalancerSpringResourceTest method testGetAllLoadBalancers.

@Test
public void testGetAllLoadBalancers() throws Exception {
    GetAllLoadBalancersRequest request = GetAllLoadBalancersRequest.newBuilder().setPage(NEXT_PAGE_OF_1).build();
    GetAllLoadBalancersResult response = GetAllLoadBalancersResult.newBuilder().setPagination(SpringMockMvcUtil.paginationOf(NEXT_PAGE_OF_1)).addJobLoadBalancers(GET_JOB_LOAD_BALANCERS_RESULT).build();
    when(serviceMock.getAllLoadBalancers(request, JUNIT_REST_CALL_METADATA)).thenReturn(Observable.just(response));
    GetAllLoadBalancersResult entity = SpringMockMvcUtil.doPaginatedGet(mockMvc, "/api/v3/loadBalancers", GetAllLoadBalancersResult.class, NEXT_PAGE_OF_1);
    assertThat(entity).isEqualTo(response);
    verify(serviceMock, times(1)).getAllLoadBalancers(request, JUNIT_REST_CALL_METADATA);
}
Also used : GetAllLoadBalancersResult(com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult) GetAllLoadBalancersRequest(com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 2 with GetAllLoadBalancersRequest

use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest in project titus-control-plane by Netflix.

the class LoadBalancerTests method getAllLoadBalancers.

/**
 * Common testing helper that gets all load balancers for a given page range, ensures the gRPC
 * request was successful, and returns the page result.
 */
public static GetAllLoadBalancersResult getAllLoadBalancers(Supplier<Page> pageSupplier, BiConsumer<GetAllLoadBalancersRequest, TestStreamObserver<GetAllLoadBalancersResult>> getAllLoadBalancers) {
    GetAllLoadBalancersRequest request = GetAllLoadBalancersRequest.newBuilder().setPage(pageSupplier.get()).build();
    TestStreamObserver<GetAllLoadBalancersResult> getResponse = new TestStreamObserver<>();
    getAllLoadBalancers.accept(request, getResponse);
    GetAllLoadBalancersResult result = null;
    try {
        result = getResponse.takeNext(TIMEOUT_MS, TimeUnit.MILLISECONDS);
    } catch (Exception e) {
        logger.error("Exception in getAllLoadBalancers", e);
        assert false;
    }
    assertThat(getResponse.hasError()).isFalse();
    return result;
}
Also used : TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) GetAllLoadBalancersResult(com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult) GetAllLoadBalancersRequest(com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest)

Aggregations

GetAllLoadBalancersRequest (com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest)2 GetAllLoadBalancersResult (com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult)2 TestStreamObserver (com.netflix.titus.testkit.grpc.TestStreamObserver)1 Test (org.junit.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1