Search in sources :

Example 1 with ServiceLimits

use of io.lumeer.api.model.ServiceLimits in project engine by Lumeer.

the class PaymentFacade method getCurrentServiceLimits.

public ServiceLimits getCurrentServiceLimits(final Organization organization) {
    checkReadPermissions(organization);
    final Payment payment = getCurrentPayment(organization);
    if (payment != null) {
        workspaceKeeper.setServiceLevel(organization, payment.getServiceLevel());
        if (payment.getServiceLevel() == Payment.ServiceLevel.BASIC) {
            return new ServiceLimits(Payment.ServiceLevel.BASIC, Math.min(ServiceLimits.BASIC_LIMITS.getUsers(), payment.getUsers()), ServiceLimits.BASIC_LIMITS.getProjects(), ServiceLimits.BASIC_LIMITS.getFiles(), ServiceLimits.BASIC_LIMITS.getDocuments(), ServiceLimits.BASIC_LIMITS.getDbSizeMb(), payment.getValidUntil());
        }
    }
    return ServiceLimits.FREE_LIMITS;
}
Also used : Payment(io.lumeer.api.model.Payment) ServiceLimits(io.lumeer.api.model.ServiceLimits)

Example 2 with ServiceLimits

use of io.lumeer.api.model.ServiceLimits in project engine by Lumeer.

the class PaymentFacadeIT method testTimezones.

@Test
public void testTimezones() {
    createPayment("2008-04-01T00:00:00.000-0500", "2008-04-30T23:59:59.999-0500", true);
    ServiceLimits limits = paymentFacade.getServiceLimitsAt(organization, getDate("2008-04-15T12:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("No matter what time zone, in the middle of the paid period, we should be on the BASIC tier.").isEqualTo(Payment.ServiceLevel.BASIC);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2008-04-01T06:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("No matter the time zone, at the beginning of the paid period, we should be on the BASIC tier.").isEqualTo(Payment.ServiceLevel.BASIC);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2008-05-01T05:59:59.999+0100"));
    assertThat(limits.getServiceLevel()).as("No matter the time zone, at the end of the paid period, we should be on the BASIC tier.").isEqualTo(Payment.ServiceLevel.BASIC);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2008-04-01T05:59:59.999+0100"));
    assertThat(limits.getServiceLevel()).as("No matter the time zone, before the beginning of the paid period, we should be on the FREE tier.").isEqualTo(Payment.ServiceLevel.FREE);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2008-05-01T06:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("No matter the time zone, after the end of the paid period, we should be on the FREE tier.").isEqualTo(Payment.ServiceLevel.FREE);
}
Also used : ServiceLimits(io.lumeer.api.model.ServiceLimits) Test(org.junit.Test)

Example 3 with ServiceLimits

use of io.lumeer.api.model.ServiceLimits in project engine by Lumeer.

the class PaymentFacadeIT method testServiceLevels.

@Test
public void testServiceLevels() {
    final String paymentId = createPayment("2011-04-01T00:00:00.000+0100", "2011-04-30T23:59:59.999+0100", false);
    ServiceLimits limits = paymentFacade.getServiceLimitsAt(organization, getDate("2011-04-15T12:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("With unpaid payment, we should still be on the FREE tier.").isEqualTo(Payment.ServiceLevel.FREE);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2010-04-15T12:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("With unpaid payment, we should still be on the FREE tier even before the terms.").isEqualTo(Payment.ServiceLevel.FREE);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2012-04-15T12:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("With unpaid payment, we should still be on the FREE tier and also after the terms.").isEqualTo(Payment.ServiceLevel.FREE);
    // now set it to paid
    paymentFacade.updatePayment(organization, paymentId);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2011-04-15T12:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("With paid payment, we should be on the BASIC tier.").isEqualTo(Payment.ServiceLevel.BASIC);
}
Also used : ServiceLimits(io.lumeer.api.model.ServiceLimits) Test(org.junit.Test)

Example 4 with ServiceLimits

use of io.lumeer.api.model.ServiceLimits in project engine by Lumeer.

the class PaymentFacadeIT method testCornerCases.

@Test
public void testCornerCases() {
    createPayment("2009-04-01T00:00:00.000+0100", "2009-04-30T23:59:59.999+0100", true);
    ServiceLimits limits = paymentFacade.getServiceLimitsAt(organization, getDate("2009-04-15T12:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("With paid payment, we should be on the BASIC tier.").isEqualTo(Payment.ServiceLevel.BASIC);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2009-04-01T00:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("At the beginning of the paid period, we should be on the BASIC tier.").isEqualTo(Payment.ServiceLevel.BASIC);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2009-04-30T23:59:59.999+0100"));
    assertThat(limits.getServiceLevel()).as("At the end of the paid period, we should be on the BASIC tier.").isEqualTo(Payment.ServiceLevel.BASIC);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2009-03-31T23:59:59.999+0100"));
    assertThat(limits.getServiceLevel()).as("Before the beginning of the paid period, we should be on the FREE tier.").isEqualTo(Payment.ServiceLevel.FREE);
    limits = paymentFacade.getServiceLimitsAt(organization, getDate("2009-05-01T00:00:00.000+0100"));
    assertThat(limits.getServiceLevel()).as("After the end of the paid period, we should be on the FREE tier.").isEqualTo(Payment.ServiceLevel.FREE);
}
Also used : ServiceLimits(io.lumeer.api.model.ServiceLimits) Test(org.junit.Test)

Example 5 with ServiceLimits

use of io.lumeer.api.model.ServiceLimits in project engine by Lumeer.

the class PaymentFacade method getServiceLimitsAt.

public ServiceLimits getServiceLimitsAt(final Organization organization, final Date date) {
    checkManagePermissions(organization);
    final Payment payment = getPaymentAt(organization, date);
    if (payment != null) {
        if (payment.getServiceLevel() == Payment.ServiceLevel.BASIC) {
            return new ServiceLimits(Payment.ServiceLevel.BASIC, Math.min(ServiceLimits.BASIC_LIMITS.getUsers(), payment.getUsers()), ServiceLimits.BASIC_LIMITS.getProjects(), ServiceLimits.BASIC_LIMITS.getFiles(), ServiceLimits.BASIC_LIMITS.getDocuments(), ServiceLimits.BASIC_LIMITS.getDbSizeMb(), payment.getValidUntil());
        }
    }
    return ServiceLimits.FREE_LIMITS;
}
Also used : Payment(io.lumeer.api.model.Payment) ServiceLimits(io.lumeer.api.model.ServiceLimits)

Aggregations

ServiceLimits (io.lumeer.api.model.ServiceLimits)7 Test (org.junit.Test)5 Payment (io.lumeer.api.model.Payment)3 Date (java.util.Date)2