InvoiceServiceClient implements BackgroundResource { public final ListInvoicesResponse listInvoices( String customerId, String billingSetup, String issueYear, MonthOfYearEnum.MonthOfYear issueMonth) { ListInvoicesRequest request = ListInvoicesRequest.newBuilder() .setCustomerId(customerId) .setBillingSetup(billingSetup) .setIssueYear(issueYear) .setIssueMonth(issueMonth) .build(); return listInvoices(request); } protected  InvoiceServiceClient(InvoiceServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  InvoiceServiceClient(InvoiceServiceStub stub); static final InvoiceServiceClient create(); static final InvoiceServiceClient create(InvoiceServiceSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final InvoiceServiceClient create(InvoiceServiceStub stub); final InvoiceServiceSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") InvoiceServiceStub getStub(); final ListInvoicesResponse listInvoices(
      String customerId,
      String billingSetup,
      String issueYear,
      MonthOfYearEnum.MonthOfYear issueMonth); final ListInvoicesResponse listInvoices(ListInvoicesRequest request); final UnaryCallable<ListInvoicesRequest, ListInvoicesResponse> listInvoicesCallable(); @Override final void close(); @Override void shutdown(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override void shutdownNow(); @Override boolean awaitTermination(long duration, TimeUnit unit);  }
@Test @SuppressWarnings("all") public void listInvoicesTest() { ListInvoicesResponse expectedResponse = ListInvoicesResponse.newBuilder().build(); mockInvoiceService.addResponse(expectedResponse); String customerId = "customerId-1772061412"; String billingSetup = "billingSetup-1181632583"; String issueYear = "issueYear1443510243"; MonthOfYearEnum.MonthOfYear issueMonth = MonthOfYearEnum.MonthOfYear.UNSPECIFIED; ListInvoicesResponse actualResponse = client.listInvoices(customerId, billingSetup, issueYear, issueMonth); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockInvoiceService.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListInvoicesRequest actualRequest = (ListInvoicesRequest) actualRequests.get(0); Assert.assertEquals(customerId, actualRequest.getCustomerId()); Assert.assertEquals(billingSetup, actualRequest.getBillingSetup()); Assert.assertEquals(issueYear, actualRequest.getIssueYear()); Assert.assertEquals(issueMonth, actualRequest.getIssueMonth()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void listInvoicesExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockInvoiceService.addException(exception); try { String customerId = "customerId-1772061412"; String billingSetup = "billingSetup-1181632583"; String issueYear = "issueYear1443510243"; MonthOfYearEnum.MonthOfYear issueMonth = MonthOfYearEnum.MonthOfYear.UNSPECIFIED; client.listInvoices(customerId, billingSetup, issueYear, issueMonth); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }