Search in sources :

Example 1 with GetMethodsFormData

use of io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData in project codekvast by crispab.

the class DashboardServiceImplTest method should_getFilterData.

@Test
public void should_getFilterData() {
    // given
    PricePlanDefaults ppd = PricePlanDefaults.TEST;
    long customerId = 1L;
    when(customerIdProvider.getCustomerId()).thenReturn(customerId);
    CustomerData customerData = CustomerData.builder().customerId(customerId).customerName("customerName").pricePlan(PricePlan.of(ppd)).source("source").collectionStartedAt(null).trialPeriodEndsAt(null).build();
    when(customerService.getCustomerDataByCustomerId(eq(customerId))).thenReturn(customerData);
    // noinspection unchecked
    when(jdbcTemplate.queryForList(anyString(), eq(String.class), eq(customerId))).thenReturn(asList("app2", "app1", "app3"), asList("env2", "env1", "env3"), asList("loc2", "loc1", "loc3"));
    // when
    GetMethodsFormData formData = dashboardService.getMethodsFormData();
    // then
    assertThat(formData, is(GetMethodsFormData.builder().application("app1").application("app2").application("app3").environment("env1").environment("env2").environment("env3").location("loc1").location("loc2").location("loc3").retentionPeriodDays(ppd.getRetentionPeriodDays()).build()));
}
Also used : CustomerData(io.codekvast.common.customer.CustomerData) GetMethodsFormData(io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData) Mockito.anyString(org.mockito.Mockito.anyString) PricePlanDefaults(io.codekvast.common.customer.PricePlanDefaults) Test(org.junit.jupiter.api.Test)

Example 2 with GetMethodsFormData

use of io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData in project codekvast by crispab.

the class DashboardApiController method getMethodsFormData.

@GetMapping("/dashboard/api/v1/methodsFormData")
public GetMethodsFormData getMethodsFormData() {
    GetMethodsFormData data = dashboardService.getMethodsFormData();
    logger.debug("{}", data);
    return data;
}
Also used : GetMethodsFormData(io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with GetMethodsFormData

use of io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData in project codekvast by crispab.

the class DashboardIntegrationTest method should_getFilterData_for_known_customerId.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_getFilterData_for_known_customerId() {
    // given
    setSecurityContextCustomerId(1L);
    // when
    GetMethodsFormData getMethodsFormData = dashboardService.getMethodsFormData();
    // then
    assertThat(getMethodsFormData.getApplications(), contains("app1", "app2", "app3", "app4"));
    assertThat(getMethodsFormData.getEnvironments(), contains("env1", "env2", "env3", "env4"));
    assertThat(getMethodsFormData.getLocations(), contains("loc1", "loc2", "loc3"));
}
Also used : GetMethodsFormData(io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Sql(org.springframework.test.context.jdbc.Sql)

Aggregations

GetMethodsFormData (io.codekvast.dashboard.dashboard.model.methods.GetMethodsFormData)3 CustomerData (io.codekvast.common.customer.CustomerData)1 PricePlanDefaults (io.codekvast.common.customer.PricePlanDefaults)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 Mockito.anyString (org.mockito.Mockito.anyString)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 Sql (org.springframework.test.context.jdbc.Sql)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1