@Test @Sql(scripts = {"/sql/clearCity.sql", "/sql/clearTenant.sql", "/sql/insertTenantData.sql","/sql/updateTenantData.sql"}) public void test_should_return_all_tenants() throws Exception { TenantSearchCriteria tenantSearchCriteria = TenantSearchCriteria.builder() .tenantCodes(null) .build(); City kurnoolCity = City.builder().id(2L).build(); City guntoorCity = City.builder().id(1L).build(); when(cityRepository.find("AP.GUNTOOR")).thenReturn(guntoorCity); when(cityRepository.find("AP.KURNOOL")).thenReturn(kurnoolCity); List<Tenant> tenants = tenantRepository.find(tenantSearchCriteria); assertThat(tenants.size()).isEqualTo(2); }
public List<org.egov.tenant.domain.model.Tenant> find(TenantSearchCriteria tenantSearchCriteria) { List<Tenant> tenants = Collections.emptyList(); if(CollectionUtils.isEmpty(tenantSearchCriteria.getTenantCodes())) tenants = getAllTenants(); else tenants = getTenantsForGivenCodes(tenantSearchCriteria); return tenants.stream() .map(Tenant::toDomain) .map(this::getCityForTenant) .collect(Collectors.toList()); }
TenantRepository { public List<org.egov.tenant.domain.model.Tenant> find(TenantSearchCriteria tenantSearchCriteria) { List<Tenant> tenants = Collections.emptyList(); if(CollectionUtils.isEmpty(tenantSearchCriteria.getTenantCodes())) tenants = getAllTenants(); else tenants = getTenantsForGivenCodes(tenantSearchCriteria); return tenants.stream() .map(Tenant::toDomain) .map(this::getCityForTenant) .collect(Collectors.toList()); } }
TenantRepository { public List<org.egov.tenant.domain.model.Tenant> find(TenantSearchCriteria tenantSearchCriteria) { List<Tenant> tenants = Collections.emptyList(); if(CollectionUtils.isEmpty(tenantSearchCriteria.getTenantCodes())) tenants = getAllTenants(); else tenants = getTenantsForGivenCodes(tenantSearchCriteria); return tenants.stream() .map(Tenant::toDomain) .map(this::getCityForTenant) .collect(Collectors.toList()); } TenantRepository(CityRepository cityRepository, NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
TenantRepository { public List<org.egov.tenant.domain.model.Tenant> find(TenantSearchCriteria tenantSearchCriteria) { List<Tenant> tenants = Collections.emptyList(); if(CollectionUtils.isEmpty(tenantSearchCriteria.getTenantCodes())) tenants = getAllTenants(); else tenants = getTenantsForGivenCodes(tenantSearchCriteria); return tenants.stream() .map(Tenant::toDomain) .map(this::getCityForTenant) .collect(Collectors.toList()); } TenantRepository(CityRepository cityRepository, NamedParameterJdbcTemplate namedParameterJdbcTemplate); List<org.egov.tenant.domain.model.Tenant> find(TenantSearchCriteria tenantSearchCriteria); @Transactional org.egov.tenant.domain.model.Tenant save(final org.egov.tenant.domain.model.Tenant tenant); @Transactional org.egov.tenant.domain.model.Tenant update(final org.egov.tenant.domain.model.Tenant tenant); Long isTenantPresent(String tenantCode); }
TenantRepository { public List<org.egov.tenant.domain.model.Tenant> find(TenantSearchCriteria tenantSearchCriteria) { List<Tenant> tenants = Collections.emptyList(); if(CollectionUtils.isEmpty(tenantSearchCriteria.getTenantCodes())) tenants = getAllTenants(); else tenants = getTenantsForGivenCodes(tenantSearchCriteria); return tenants.stream() .map(Tenant::toDomain) .map(this::getCityForTenant) .collect(Collectors.toList()); } TenantRepository(CityRepository cityRepository, NamedParameterJdbcTemplate namedParameterJdbcTemplate); List<org.egov.tenant.domain.model.Tenant> find(TenantSearchCriteria tenantSearchCriteria); @Transactional org.egov.tenant.domain.model.Tenant save(final org.egov.tenant.domain.model.Tenant tenant); @Transactional org.egov.tenant.domain.model.Tenant update(final org.egov.tenant.domain.model.Tenant tenant); Long isTenantPresent(String tenantCode);  }