How can i mock a multiple page response?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu với MockHttpTransport.Builder và các dòng 214-220 được liên kết trong SubscriptionsFetcherTest.kt, sau đó theo dõi cách mockResponse được sử dụng qua các yêu cầu lặp lại. Công việc được xem là hoàn tất khi đã lập tài liệu và kiểm thử một cách được hỗ trợ để mô phỏng hai phản hồi YouTube được phân trang, bao gồm cả lỗi quan sát được ở yêu cầu thứ hai.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello,
I am trying to test my integration with the Youtube API.
For that one i'm creating a mockHttpTransport with a mockResponse (or a mockRequest, the same issue presented below arises):
val mockHttpTransport = MockHttpTransport.Builder()
// .setLowLevelHttpRequest(mockRequest)
.setLowLevelHttpResponse(mockResponse)
.build()
val youtube = YouTube.Builder(
mockHttpTransport,
mockGoogleCredential.jsonFactory,
mockGoogleCredential
).build()
I want to get all my subscriptions, but they are more than 50 so I get a paged response ("nextPageToken": "CAUQAA"), so i need to make a second request to execute:
val request = youtube
.subscriptions()
.list(listOf("snippet", "contentDetails"))
.setMaxResults(5000)
.setMine(true)
.setFields("*")
.setPrettyPrint(true)
val responseWhichReturnsTheCorrectSubscriptionListPage: SubscriptionListResponse = request.execute()
println(responseWhichReturnsTheCorrectSubscriptionListPage)
val responseWhichThrowsIAE: SubscriptionListResponse = request.setPageToken("CAUQAA").execute()
println(responseWhichThrowsIAE)
Q1: why can't i return the same mock response multiple times? the second iteration throws java.lang.IllegalArgumentException: no JSON input found
Q2: How can i pass multiple different mockResponses to the transport, to simulate that i have to fetch multiple pages from youtube?
I have already tried searching on Stackoverflow, but i had little success: https://stackoverflow.com/search?tab=votes&q=%5bgoogle-cloud-platform%5d%20%20mock.
- Ngôn ngữ chính
- Java
- Star
- 1.4k
- Fork
- 476
- Merge trung bình
- 10 giờ 47 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-http-java-client
-
Core: Validate header names and values to prevent CRLF injectionCó thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Core: XmlPullParser processes external DTD entities (XXE) — disable FEATURE_PROCESS_DOCDECL in Xml#createParser()Có thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Core: LowLevelHttpResponse not disconnected when HttpResponse construction throws RuntimeExceptionCó thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
type: cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
org.apache.http.conn.ssl.SSLSocketFactory is deprecatedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởpriority: p2 type: cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Tất cả issue của googleapis/google-http-java-client
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 84/100
cpp-best-practices/project_validator#251 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend enhancement
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 70/100
damodharg6/payledger#16 ·
-
[Bug]: An initiative list with no current entry logs an error on every changeCó thể đã có người làm @dwizard0 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày