use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class DashboardServiceImplTest method should_getStatus_after_trial_period.
@Test
public void should_getStatus_after_trial_period() {
// given
when(customerIdProvider.getCustomerId()).thenReturn(1L);
PricePlanDefaults ppd = PricePlanDefaults.TEST;
Instant collectionStartedAt = now.minus(3, DAYS);
Instant trialPeriodEndsAt = now.minus(1, MILLIS);
CustomerData customerData = CustomerData.builder().customerId(1L).customerName("customerName").pricePlan(PricePlan.of(ppd).toBuilder().retentionPeriodDays(-1).build()).source("source").collectionStartedAt(collectionStartedAt).trialPeriodEndsAt(trialPeriodEndsAt).build();
when(customerService.getCustomerDataByCustomerId(eq(1L))).thenReturn(customerData);
when(customerService.countMethods(eq(1L))).thenReturn(1000);
// when
GetStatusResponse status = dashboardService.getStatus();
// then
assertNotNull(status);
assertThat(status.getCollectedSinceMillis(), is(collectionStartedAt.toEpochMilli()));
assertThat(status.getTrialPeriodEndsAtMillis(), is(trialPeriodEndsAt.toEpochMilli()));
assertThat(status.getTrialPeriodPercent(), is(100));
assertThat(status.getTrialPeriodExpired(), is(true));
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class IntakeIntegrationTest method should_accept_valid_getCustomerDataByCustomerId_1.
@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByCustomerId_1() {
CustomerData customerData = customerService.getCustomerDataByCustomerId(1L);
assertThat(customerData.getCustomerId(), is(1L));
assertThat(customerData.getCustomerName(), is("Demo"));
assertThat(customerData.getPricePlan().getName(), is("DEMO"));
assertThat(customerData.getContactEmail(), is("contactEmail1"));
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class IntakeIntegrationTest method should_not_start_trial_period_at_first_agent_poll.
@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_not_start_trial_period_at_first_agent_poll() {
// given
Instant now = Instant.now();
CustomerData customerData = customerService.getCustomerDataByCustomerId(1L);
assertThat(customerData.getPricePlan().getTrialPeriodDays(), is(PricePlanDefaults.DEMO.getTrialPeriodDays()));
assertThat(customerData.getCollectionStartedAt(), is(nullValue()));
assertThat(customerData.getTrialPeriodEndsAt(), is(nullValue()));
assertThat(customerData.isTrialPeriodExpired(now), is(false));
// when
customerData = customerService.registerAgentPoll(customerData, now);
// then
assertThat(customerData.getCollectionStartedAt(), is(now));
assertThat(customerData.getTrialPeriodEndsAt(), is(nullValue()));
assertThat(customerData.isTrialPeriodExpired(now), is(false));
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class IntakeIntegrationTest method should_start_trial_period_at_first_agent_poll.
@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_start_trial_period_at_first_agent_poll() {
// given
Instant now = Instant.now();
customerService.changePlanForExternalId("test", "external-1", "test");
CustomerData customerData = customerService.getCustomerDataByCustomerId(1L);
assertThat(customerData.getPricePlan().getTrialPeriodDays(), is(PricePlanDefaults.TEST.getTrialPeriodDays()));
assertThat(customerData.getCollectionStartedAt(), is(nullValue()));
assertThat(customerData.getTrialPeriodEndsAt(), is(nullValue()));
assertThat(customerData.isTrialPeriodExpired(now), is(false));
// when
customerData = customerService.registerAgentPoll(customerData, now);
// then
assertThat(customerData.getCollectionStartedAt(), is(now));
int days = customerData.getPricePlan().getTrialPeriodDays();
assertThat(customerData.getTrialPeriodEndsAt(), is(now.plus(days, DAYS)));
assertThat(customerData.isTrialPeriodExpired(now.plus(days - 1, DAYS)), is(false));
assertThat(customerData.isTrialPeriodExpired(now.plus(days + 1, DAYS)), is(true));
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class IntakeIntegrationTest method should_accept_valid_getCustomerDataByCustomerId_2.
@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByCustomerId_2() {
CustomerData customerData = customerService.getCustomerDataByCustomerId(2L);
assertThat(customerData.getCustomerId(), is(2L));
assertThat(customerData.getContactEmail(), nullValue());
}
Aggregations