@Test public void response_list_bills() { var invoice = createInvoice(); billingController.addInvoice(tenant, invoice, true); billingController.addInvoice(tenant, invoice, false); billingController.setPlan(tenant, PlanId.from("some-plan"), true); var request = request("/billing/v1/tenant/tenant1/billing?until=2020-05-28").roles(tenantRole); tester.assertResponse(request, new File("tenant-billing-view")); }
private HttpResponse createInvoice(HttpRequest request, String userId) { Inspector inspector = inspectorOrThrow(request); TenantName tenantName = TenantName.from(getInspectorFieldOrThrow(inspector, "tenant")); LocalDate startDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "startTime")); LocalDate endDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "endTime")); ZonedDateTime startTime = startDate.atStartOfDay(ZoneId.of("UTC")); ZonedDateTime endTime = endDate.atStartOfDay(ZoneId.of("UTC")); var invoiceId = billingController.createInvoiceForPeriod(tenantName, startTime, endTime, userId); return new MessageResponse("Created invoice with ID " + invoiceId.value()); }
BillingApiHandler extends LoggingRequestHandler { private HttpResponse createInvoice(HttpRequest request, String userId) { Inspector inspector = inspectorOrThrow(request); TenantName tenantName = TenantName.from(getInspectorFieldOrThrow(inspector, "tenant")); LocalDate startDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "startTime")); LocalDate endDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "endTime")); ZonedDateTime startTime = startDate.atStartOfDay(ZoneId.of("UTC")); ZonedDateTime endTime = endDate.atStartOfDay(ZoneId.of("UTC")); var invoiceId = billingController.createInvoiceForPeriod(tenantName, startTime, endTime, userId); return new MessageResponse("Created invoice with ID " + invoiceId.value()); } }
BillingApiHandler extends LoggingRequestHandler { private HttpResponse createInvoice(HttpRequest request, String userId) { Inspector inspector = inspectorOrThrow(request); TenantName tenantName = TenantName.from(getInspectorFieldOrThrow(inspector, "tenant")); LocalDate startDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "startTime")); LocalDate endDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "endTime")); ZonedDateTime startTime = startDate.atStartOfDay(ZoneId.of("UTC")); ZonedDateTime endTime = endDate.atStartOfDay(ZoneId.of("UTC")); var invoiceId = billingController.createInvoiceForPeriod(tenantName, startTime, endTime, userId); return new MessageResponse("Created invoice with ID " + invoiceId.value()); } BillingApiHandler(Executor executor,
                             AccessLog accessLog,
                             Controller controller); }
BillingApiHandler extends LoggingRequestHandler { private HttpResponse createInvoice(HttpRequest request, String userId) { Inspector inspector = inspectorOrThrow(request); TenantName tenantName = TenantName.from(getInspectorFieldOrThrow(inspector, "tenant")); LocalDate startDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "startTime")); LocalDate endDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "endTime")); ZonedDateTime startTime = startDate.atStartOfDay(ZoneId.of("UTC")); ZonedDateTime endTime = endDate.atStartOfDay(ZoneId.of("UTC")); var invoiceId = billingController.createInvoiceForPeriod(tenantName, startTime, endTime, userId); return new MessageResponse("Created invoice with ID " + invoiceId.value()); } BillingApiHandler(Executor executor,
                             AccessLog accessLog,
                             Controller controller); @Override HttpResponse handle(HttpRequest request); }
BillingApiHandler extends LoggingRequestHandler { private HttpResponse createInvoice(HttpRequest request, String userId) { Inspector inspector = inspectorOrThrow(request); TenantName tenantName = TenantName.from(getInspectorFieldOrThrow(inspector, "tenant")); LocalDate startDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "startTime")); LocalDate endDate = LocalDate.parse(getInspectorFieldOrThrow(inspector, "endTime")); ZonedDateTime startTime = startDate.atStartOfDay(ZoneId.of("UTC")); ZonedDateTime endTime = endDate.atStartOfDay(ZoneId.of("UTC")); var invoiceId = billingController.createInvoiceForPeriod(tenantName, startTime, endTime, userId); return new MessageResponse("Created invoice with ID " + invoiceId.value()); } BillingApiHandler(Executor executor,
                             AccessLog accessLog,
                             Controller controller); @Override HttpResponse handle(HttpRequest request);  }