use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class CustomerServiceImplTest method should_update_customers_but_not_start_trial_period_when_agent_polls_the_first_time_and_no_trial_period_days.
@Test
void should_update_customers_but_not_start_trial_period_when_agent_polls_the_first_time_and_no_trial_period_days() {
// given
CustomerData customerData = CustomerData.builder().customerId(1L).source("test").customerName("customerName").collectionStartedAt(null).pricePlan(PricePlan.of(PricePlanDefaults.TEST).toBuilder().trialPeriodDays(-1).build()).build();
when(jdbcTemplate.update(anyString(), any(Timestamp.class), isNull(), anyLong())).thenReturn(1);
// when
CustomerData data = service.registerAgentPoll(customerData, NOW);
// then
assertThat(data.getCollectionStartedAt(), is(NOW));
verify(jdbcTemplate).update(startsWith("UPDATE customers SET"), eq(Timestamp.from(NOW)), eq(null), eq(1L));
verify(eventService).send(any(CollectionStartedEvent.class));
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class IntakeIntegrationTest method should_reject_publication_too_large.
@Test(expected = LicenseViolationException.class)
@Sql(scripts = "/sql/base-data.sql")
public void should_reject_publication_too_large() {
CustomerData customerData = customerService.getCustomerDataByLicenseKey("");
customerService.assertPublicationSize(customerData, 100_000);
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class DashboardIntegrationTest 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 DashboardIntegrationTest method should_accept_publication.
@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_publication() {
CustomerData customerData = customerService.getCustomerDataByLicenseKey("");
customerService.assertPublicationSize(customerData, 10);
}
use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.
the class DashboardIntegrationTest method should_accept_valid_getCustomerDataByExternalId_without_pricePlanOverride.
@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByExternalId_without_pricePlanOverride() {
CustomerData customerData = customerService.getCustomerDataByExternalId("test", "external-2");
assertThat(customerData.getCustomerId(), is(2L));
assertThat(customerData.getPricePlan().getOverrideBy(), nullValue());
assertThat(customerData.isTrialPeriodExpired(Instant.now()), is(false));
}
Aggregations