Skip to content

Commit

Permalink
add showcase tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeWang1127 committed Mar 1, 2023
1 parent 206c46f commit 6fcfa9b
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;
import javax.annotation.Generated;
import org.junit.After;
import org.junit.AfterClass;
Expand Down Expand Up @@ -442,6 +443,41 @@ public void listUsersTest() throws Exception {
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
public void listUsersTest2() throws Exception {
User responsesElement = User.newBuilder().build();
ListUsersResponse expectedResponse =
ListUsersResponse.newBuilder()
.setNextPageToken("")
.addAllUsers(Arrays.asList(responsesElement))
.build();
mockIdentity.addResponse(expectedResponse);

ListUsersRequest request =
ListUsersRequest.newBuilder()
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();

ListUsersPagedResponse pagedListResponse = client.listUsers(request);

Stream<User> resources = pagedListResponse.getPage().streamAll();

Assert.assertEquals(1, resources.count());
Assert.assertEquals(responsesElement, resources.findFirst().get());

List<AbstractMessage> actualRequests = mockIdentity.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListUsersRequest actualRequest = ((ListUsersRequest) actualRequests.get(0));

Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
public void listUsersExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
Expand Down

0 comments on commit 6fcfa9b

Please sign in to comment.