aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@verizonmedia.com>2021-11-03 12:39:12 +0100
committerØyvind Grønnesby <oyving@verizonmedia.com>2021-11-03 12:39:12 +0100
commit41bf6baf7256cfa2619457bb47a935b61d0e7a7b (patch)
tree5151e9a6a5c1d8b1ccba6cb02abd344a4b7763da /controller-server/src/test
parent8cbeb2b57269e64ea05ccf9f1044f57843a6e80c (diff)
Make the bill end date inclusive instead of exclusive
Before the end date for the billing was used to calculate startOfDay to generate the timestamp we actually use. Now we are changing it to .plusDays(1).startOfDay to make it so UI will effectively use the end of today as the timestamp. Also added some more implementations to ManualClock to get some tests to work.
Diffstat (limited to 'controller-server/src/test')
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java9
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerV2Test.java7
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/responses/tenant-billing-view3
3 files changed, 12 insertions, 7 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java
index 3c4ed8bc8df..74ed1a0bb10 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerTest.java
@@ -122,8 +122,11 @@ public class BillingApiHandlerTest extends ControllerContainerCloudTest {
bills = billingController.getBillsForTenant(tenant);
assertEquals(1, bills.size());
Bill bill = bills.get(0);
- assertEquals(bill.getStartTime().toString(), "2020-04-20T00:00Z[UTC]");
- assertEquals(bill.getEndTime().toString(), "2020-05-20T00:00Z[UTC]");
+ assertEquals("2020-04-20T00:00Z[UTC]", bill.getStartTime().toString());
+ assertEquals("2020-05-21T00:00Z[UTC]", bill.getEndTime().toString());
+
+ assertEquals("2020-04-20", bill.getStartDate().toString());
+ assertEquals("2020-05-20", bill.getEndDate().toString());
}
@Test
@@ -223,7 +226,7 @@ public class BillingApiHandlerTest extends ControllerContainerCloudTest {
static Bill createBill() {
var start = LocalDate.of(2020, 5, 23).atStartOfDay(ZoneOffset.UTC);
- var end = start.plusDays(5);
+ var end = start.toLocalDate().plusDays(6).atStartOfDay(ZoneOffset.UTC);
var statusHistory = new Bill.StatusHistory(new TreeMap<>(Map.of(start, "OPEN")));
return new Bill(
Bill.Id.of("id-1"),
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerV2Test.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerV2Test.java
index 178cb6f9909..c41616dbba5 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerV2Test.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandlerV2Test.java
@@ -13,6 +13,7 @@ import com.yahoo.vespa.hosted.controller.security.CloudTenantSpec;
import org.junit.Before;
import org.junit.Test;
+import java.time.Duration;
import java.time.Instant;
import java.util.Set;
@@ -105,10 +106,10 @@ public class BillingApiHandlerV2Test extends ControllerContainerCloudTest {
@Test
public void require_tenant_invoice() {
var listRequest = request("/billing/v2/tenant/" + tenant + "/bill").roles(tenantReader);
- tester.assertResponse(listRequest, "{\"invoices\":[{\"id\":\"id-1\",\"from\":\"2020-05-23\",\"to\":\"2020-05-23\",\"total\":\"123.00\",\"status\":\"OPEN\"}]}");
+ tester.assertResponse(listRequest, "{\"invoices\":[{\"id\":\"id-1\",\"from\":\"2020-05-23\",\"to\":\"2020-05-28\",\"total\":\"123.00\",\"status\":\"OPEN\"}]}");
var singleRequest = request("/billing/v2/tenant/" + tenant + "/bill/id-1").roles(tenantReader);
- tester.assertResponse(singleRequest, "{\"id\":\"id-1\",\"from\":\"2020-05-23\",\"to\":\"2020-05-23\",\"total\":\"123.00\",\"status\":\"OPEN\",\"statusHistory\":[{\"at\":\"2020-05-23T00:00:00Z\",\"status\":\"OPEN\"}],\"items\":[{\"id\":\"some-id\",\"description\":\"description\",\"amount\":\"123.00\",\"plan\":\"some-plan\",\"planName\":\"Plan with id: some-plan\",\"cpu\":{},\"memory\":{},\"disk\":{}}]}");
+ tester.assertResponse(singleRequest, "{\"id\":\"id-1\",\"from\":\"2020-05-23\",\"to\":\"2020-05-28\",\"total\":\"123.00\",\"status\":\"OPEN\",\"statusHistory\":[{\"at\":\"2020-05-23T00:00:00Z\",\"status\":\"OPEN\"}],\"items\":[{\"id\":\"some-id\",\"description\":\"description\",\"amount\":\"123.00\",\"plan\":\"some-plan\",\"planName\":\"Plan with id: some-plan\",\"cpu\":{},\"memory\":{},\"disk\":{}}]}");
}
@Test
@@ -126,7 +127,7 @@ public class BillingApiHandlerV2Test extends ControllerContainerCloudTest {
@Test
public void require_accountant_tenant_preview() {
var accountantRequest = request("/billing/v2/accountant/preview/tenant/tenant1").roles(Role.hostedAccountant());
- tester.assertResponse(accountantRequest, "{\"id\":\"empty\",\"from\":\"2021-04-13\",\"to\":\"2021-04-13\",\"total\":\"0.00\",\"status\":\"OPEN\",\"statusHistory\":[{\"at\":\"2021-04-13T00:00:00Z\",\"status\":\"OPEN\"}],\"items\":[]}");
+ tester.assertResponse(accountantRequest, "{\"id\":\"empty\",\"from\":\"2021-04-13\",\"to\":\"2021-04-12\",\"total\":\"0.00\",\"status\":\"OPEN\",\"statusHistory\":[{\"at\":\"2021-04-13T00:00:00Z\",\"status\":\"OPEN\"}],\"items\":[]}");
}
@Test
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/responses/tenant-billing-view b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/responses/tenant-billing-view
index c0deca3d671..e5588c45677 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/responses/tenant-billing-view
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/billing/responses/tenant-billing-view
@@ -21,7 +21,8 @@
{
"id":"id-1",
"from":"2020-05-23",
- "to":"2020-05-28","amount":"123.00",
+ "to":"2020-05-28",
+ "amount":"123.00",
"status":"OPEN",
"statusHistory":[
{