@Test public void should_getFilterData() { 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); when(jdbcTemplate.queryForList(anyString(), eq(String.class), eq(customerId))) .thenReturn( asList("app2", "app1", "app3"), asList("env2", "env1", "env3"), asList("loc2", "loc1", "loc3")); GetMethodsFormData formData = dashboardService.getMethodsFormData(); 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())); }
@Override @Transactional(readOnly = true) public @NotNull GetMethodsFormData getMethodsFormData() { Long customerId = customerIdProvider.getCustomerId(); CustomerData customerData = customerService.getCustomerDataByCustomerId(customerId); List<String> applications = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM applications WHERE customerId = ? ", String.class, customerId); List<String> environments = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM environments WHERE customerId = ? ", String.class, customerId); List<String> locations = jdbcTemplate.queryForList( "SELECT DISTINCT locationNoVersion FROM method_locations WHERE customerId = ? ", String.class, customerId); return GetMethodsFormData.builder() .applications(applications) .environments(environments) .locations(locations) .retentionPeriodDays(customerData.getPricePlan().getRetentionPeriodDays()) .build(); }
DashboardServiceImpl implements DashboardService { @Override @Transactional(readOnly = true) public @NotNull GetMethodsFormData getMethodsFormData() { Long customerId = customerIdProvider.getCustomerId(); CustomerData customerData = customerService.getCustomerDataByCustomerId(customerId); List<String> applications = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM applications WHERE customerId = ? ", String.class, customerId); List<String> environments = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM environments WHERE customerId = ? ", String.class, customerId); List<String> locations = jdbcTemplate.queryForList( "SELECT DISTINCT locationNoVersion FROM method_locations WHERE customerId = ? ", String.class, customerId); return GetMethodsFormData.builder() .applications(applications) .environments(environments) .locations(locations) .retentionPeriodDays(customerData.getPricePlan().getRetentionPeriodDays()) .build(); } }
DashboardServiceImpl implements DashboardService { @Override @Transactional(readOnly = true) public @NotNull GetMethodsFormData getMethodsFormData() { Long customerId = customerIdProvider.getCustomerId(); CustomerData customerData = customerService.getCustomerDataByCustomerId(customerId); List<String> applications = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM applications WHERE customerId = ? ", String.class, customerId); List<String> environments = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM environments WHERE customerId = ? ", String.class, customerId); List<String> locations = jdbcTemplate.queryForList( "SELECT DISTINCT locationNoVersion FROM method_locations WHERE customerId = ? ", String.class, customerId); return GetMethodsFormData.builder() .applications(applications) .environments(environments) .locations(locations) .retentionPeriodDays(customerData.getPricePlan().getRetentionPeriodDays()) .build(); }  }
DashboardServiceImpl implements DashboardService { @Override @Transactional(readOnly = true) public @NotNull GetMethodsFormData getMethodsFormData() { Long customerId = customerIdProvider.getCustomerId(); CustomerData customerData = customerService.getCustomerDataByCustomerId(customerId); List<String> applications = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM applications WHERE customerId = ? ", String.class, customerId); List<String> environments = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM environments WHERE customerId = ? ", String.class, customerId); List<String> locations = jdbcTemplate.queryForList( "SELECT DISTINCT locationNoVersion FROM method_locations WHERE customerId = ? ", String.class, customerId); return GetMethodsFormData.builder() .applications(applications) .environments(environments) .locations(locations) .retentionPeriodDays(customerData.getPricePlan().getRetentionPeriodDays()) .build(); }  @Override @Transactional(readOnly = true) GetMethodsResponse2 getMethods2(@Valid GetMethodsRequest request); @Override @Transactional(readOnly = true) Optional<MethodDescriptor1> getMethodById(@NotNull Long methodId); @Override @Transactional(readOnly = true) GetStatusResponse getStatus(); @Override @Transactional(readOnly = true) @NotNull GetMethodsFormData getMethodsFormData(); }
DashboardServiceImpl implements DashboardService { @Override @Transactional(readOnly = true) public @NotNull GetMethodsFormData getMethodsFormData() { Long customerId = customerIdProvider.getCustomerId(); CustomerData customerData = customerService.getCustomerDataByCustomerId(customerId); List<String> applications = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM applications WHERE customerId = ? ", String.class, customerId); List<String> environments = jdbcTemplate.queryForList( "SELECT DISTINCT name FROM environments WHERE customerId = ? ", String.class, customerId); List<String> locations = jdbcTemplate.queryForList( "SELECT DISTINCT locationNoVersion FROM method_locations WHERE customerId = ? ", String.class, customerId); return GetMethodsFormData.builder() .applications(applications) .environments(environments) .locations(locations) .retentionPeriodDays(customerData.getPricePlan().getRetentionPeriodDays()) .build(); }  @Override @Transactional(readOnly = true) GetMethodsResponse2 getMethods2(@Valid GetMethodsRequest request); @Override @Transactional(readOnly = true) Optional<MethodDescriptor1> getMethodById(@NotNull Long methodId); @Override @Transactional(readOnly = true) GetStatusResponse getStatus(); @Override @Transactional(readOnly = true) @NotNull GetMethodsFormData getMethodsFormData();  }