Search in sources :

Example 26 with CustomerData

use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.

the class DashboardIntegrationTest 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());
}
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 27 with CustomerData

use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.

the class DashboardIntegrationTest method should_accept_valid_getCustomerDataByLicenseKey.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByLicenseKey() {
    CustomerData customerData = customerService.getCustomerDataByLicenseKey("");
    assertThat(customerData.getCustomerId(), is(1L));
    assertThat(customerData.getCustomerName(), is("Demo"));
    assertThat(customerData.getPricePlan().getName(), is("DEMO"));
}
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 28 with CustomerData

use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.

the class MariadbIntegrationTest method should_start_trial_period_at_first_agent_publishing.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_start_trial_period_at_first_agent_publishing() {
    // given
    Instant now = Instant.now();
    jdbcTemplate.update("UPDATE customers SET plan = 'test', collectionStartedAt = NULL, trialPeriodEndsAt = NULL WHERE id = 1");
    CustomerData customerData = customerService.getCustomerDataByCustomerId(1L);
    assertThat(customerData.getPricePlan().getMaxCollectionPeriodDays(), is(PricePlanDefaults.TEST.getMaxCollectionPeriodDays()));
    assertThat(customerData.getCollectionStartedAt(), is(nullValue()));
    assertThat(customerData.getTrialPeriodEndsAt(), is(nullValue()));
    assertThat(customerData.isTrialPeriodExpired(now), is(false));
    // when
    customerData = customerService.registerAgentDataPublication(customerData, now);
    // then
    assertThat(customerData.getCollectionStartedAt(), is(now));
    int days = customerData.getPricePlan().getMaxCollectionPeriodDays();
    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));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) Instant(java.time.Instant) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 29 with CustomerData

use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.

the class MariadbIntegrationTest method should_accept_valid_getCustomerDataByExternalId_with_pricePlanOverride.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByExternalId_with_pricePlanOverride() {
    CustomerData customerData = customerService.getCustomerDataByExternalId("external-1");
    assertThat(customerData.getCustomerId(), is(1L));
    assertThat(customerData.getCustomerName(), is("Demo"));
    assertThat(customerData.getPricePlan().getName(), is("DEMO"));
    assertThat(customerData.getPricePlan().getOverrideBy(), is("integration test"));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 30 with CustomerData

use of io.codekvast.common.customer.CustomerData in project codekvast by crispab.

the class MariadbIntegrationTest method should_accept_valid_getCustomerDataByLicenseKey.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_accept_valid_getCustomerDataByLicenseKey() {
    CustomerData customerData = customerService.getCustomerDataByLicenseKey("");
    assertThat(customerData.getCustomerId(), is(1L));
    assertThat(customerData.getCustomerName(), is("Demo"));
    assertThat(customerData.getPricePlan().getName(), is("DEMO"));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) 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