Search in sources :

Example 21 with CustomerData

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));
}
Also used : CollectionStartedEvent(io.codekvast.common.messaging.model.CollectionStartedEvent) CustomerData(io.codekvast.common.customer.CustomerData) Timestamp(java.sql.Timestamp) Test(org.junit.jupiter.api.Test)

Example 22 with CustomerData

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);
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 23 with CustomerData

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"));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 24 with CustomerData

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);
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 25 with CustomerData

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));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Aggregations

CustomerData (io.codekvast.common.customer.CustomerData)48 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)28 Sql (org.springframework.test.context.jdbc.Sql)28 Test (org.junit.Test)22 Instant (java.time.Instant)13 Test (org.junit.jupiter.api.Test)10 Transactional (org.springframework.transaction.annotation.Transactional)9 PricePlanDefaults (io.codekvast.common.customer.PricePlanDefaults)4 PricePlan (io.codekvast.common.customer.PricePlan)3 GetStatusResponse (io.codekvast.dashboard.dashboard.model.status.GetStatusResponse)3 Timestamp (java.sql.Timestamp)3 CollectionStartedEvent (io.codekvast.common.messaging.model.CollectionStartedEvent)2 User (io.codekvast.login.model.User)2 CacheEvict (org.springframework.cache.annotation.CacheEvict)2 LicenseViolationException (io.codekvast.common.customer.LicenseViolationException)1 LicenseViolationEvent (io.codekvast.common.messaging.model.LicenseViolationEvent)1 GetMethodsFormData (io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData)1 AgentDescriptor (io.codekvast.dashboard.dashboard.model.status.AgentDescriptor)1 ApplicationDescriptor2 (io.codekvast.dashboard.dashboard.model.status.ApplicationDescriptor2)1 EnvironmentStatusDescriptor (io.codekvast.dashboard.dashboard.model.status.EnvironmentStatusDescriptor)1