use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class DashboardServiceImplTest method should_getStatus_inside_trial_period.
@Test
public void should_getStatus_inside_trial_period() {
// given
when(customerIdProvider.getCustomerId()).thenReturn(1L);
PricePlanDefaults ppd = PricePlanDefaults.TEST;
Instant collectionStartedAt = now.minus(3, DAYS);
Instant trialPeriodEndsAt = now.plus(3, DAYS);
CustomerData customerData = CustomerData.builder().customerId(1L).customerName("customerName").pricePlan(PricePlan.of(ppd)).source("source").collectionStartedAt(collectionStartedAt).trialPeriodEndsAt(trialPeriodEndsAt).build();
when(customerService.getCustomerDataByCustomerId(eq(1L))).thenReturn(customerData);
when(customerService.countMethods(eq(1L))).thenReturn(1000);
// when
GetStatusResponse status = webappService.getStatus();
// then
assertNotNull(status);
assertThat(status.getPricePlan(), is("TEST"));
assertThat(status.getCollectedSinceMillis(), is(collectionStartedAt.toEpochMilli()));
assertThat(status.getTrialPeriodEndsAtMillis(), is(trialPeriodEndsAt.toEpochMilli()));
assertThat(status.getTrialPeriodPercent(), is(50));
assertThat(status.getTrialPeriodExpired(), is(false));
assertThat(status.getMaxNumberOfAgents(), is(ppd.getMaxNumberOfAgents()));
assertThat(status.getMaxNumberOfMethods(), is(ppd.getMaxMethods()));
assertThat(status.getNumMethods(), is(1000));
assertThat(status.getNumAgents(), is(0));
System.out.println("status = " + status);
verify(customerService).getCustomerDataByCustomerId(eq(1L));
verify(customerService).countMethods(eq(1L));
verify(customerIdProvider).getCustomerId();
verifyNoMoreInteractions(customerService, customerIdProvider);
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class DashboardServiceImplTest method should_getStatus_not_started_no_trial_period.
@Test
public void should_getStatus_not_started_no_trial_period() {
// given
when(customerIdProvider.getCustomerId()).thenReturn(1L);
PricePlanDefaults ppd = PricePlanDefaults.TEST;
CustomerData customerData = CustomerData.builder().customerId(1L).customerName("customerName").pricePlan(PricePlan.of(ppd)).source("source").collectionStartedAt(null).trialPeriodEndsAt(null).build();
when(customerService.getCustomerDataByCustomerId(eq(1L))).thenReturn(customerData);
when(customerService.countMethods(eq(1L))).thenReturn(1000);
// when
GetStatusResponse status = webappService.getStatus();
// then
assertNotNull(status);
assertThat(status.getCollectedSinceMillis(), is(nullValue()));
assertThat(status.getTrialPeriodEndsAtMillis(), is(nullValue()));
assertThat(status.getTrialPeriodPercent(), is(nullValue()));
assertThat(status.getTrialPeriodExpired(), is(false));
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class CustomerServiceImplTest method should_return_sensible_CustomerData.
@Test
public void should_return_sensible_CustomerData() {
CustomerData data = service.getCustomerDataByLicenseKey("key");
assertThat(data.getCustomerId(), is(1L));
assertThat(data.getPricePlan().getName(), is("TEST"));
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class MariadbIntegrationTest method should_accept_valid_getCustomerDataByCustomerId.
@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByCustomerId() {
CustomerData customerData = customerService.getCustomerDataByCustomerId(1L);
assertThat(customerData.getCustomerId(), is(1L));
assertThat(customerData.getCustomerName(), is("Demo"));
assertThat(customerData.getPricePlan().getName(), is("DEMO"));
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class MariadbIntegrationTest method should_accept_valid_getCustomerDataByExternalId_trialPeriodExpired.
@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByExternalId_trialPeriodExpired() {
// see base-data.sql
Instant now = Instant.parse("2017-09-21T16:21:19Z").plus(1, DAYS);
CustomerData customerData = customerService.getCustomerDataByExternalId("external-3");
assertThat(customerData.getCustomerId(), is(3L));
assertThat(customerData.isTrialPeriodExpired(now), is(true));
}
Aggregations