@Test @Sql(scripts = {"/sql/clearCity.sql", "/sql/clearTenant.sql", "/sql/insertTenantData.sql"}) public void test_should_create_city() { City city = City.builder() .name("Bengaluru") .localName("local name") .districtCode("AB") .districtName("district") .regionName("region name") .ulbGrade("municipality") .longitude(35.345) .latitude(75.234) .shapeFileLocation("shapeFileLocation") .captcha("captcha") .code("code") .build(); cityRepository.save(city, "AP.KURNOOL"); List<Map<String, Object>> result = namedParameterJdbcTemplate.query("SELECT * FROM city", new CityResultExtractor()); Map<String, Object> row = result.get(0); assertThat(row.get(ID)).isEqualTo(1L); assertThat(row.get(NAME)).isEqualTo("Bengaluru"); assertThat(row.get(LOCAL_NAME)).isEqualTo("local name"); assertThat(row.get(DISTRICT_CODE)).isEqualTo("AB"); assertThat(row.get(DISTRICT_NAME)).isEqualTo("district"); assertThat(row.get(REGION_NAME)).isEqualTo("region name"); assertThat(row.get(ULB_GRADE)).isEqualTo("municipality"); assertThat(row.get(SHAPEFILE_LOCATION)).isEqualTo("shapeFileLocation"); assertThat(row.get(CAPTCHA)).isEqualTo("captcha"); assertThat(row.get(CODE)).isEqualTo("code"); }
public City save(City city, String tenantCode) { Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(NAME, city.getName()); put(LOCAL_NAME, city.getLocalName()); put(DISTRICT_CODE, city.getDistrictCode()); put(DISTRICT_NAME, city.getDistrictName()); put(REGION_NAME, city.getRegionName()); put(LONGITUDE, city.getLongitude()); put(LATITUDE, city.getLatitude()); put(ULB_GRADE, city.getUlbGrade()); put(TENANT_CODE, tenantCode); put(CREATED_BY, city.getCreatedBy()); put(CREATED_DATE, city.getCreatedDate()); put(LAST_MODIFIED_BY, city.getLastModifiedBy()); put(LAST_MODIFIED_DATE, city.getLastModifiedDate()); put(SHAPEFILE_LOCATION,city.getShapeFileLocation()); put(CAPTCHA, city.getCaptcha()); put(CODE, city.getCode()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); return city; }
CityRepository { public City save(City city, String tenantCode) { Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(NAME, city.getName()); put(LOCAL_NAME, city.getLocalName()); put(DISTRICT_CODE, city.getDistrictCode()); put(DISTRICT_NAME, city.getDistrictName()); put(REGION_NAME, city.getRegionName()); put(LONGITUDE, city.getLongitude()); put(LATITUDE, city.getLatitude()); put(ULB_GRADE, city.getUlbGrade()); put(TENANT_CODE, tenantCode); put(CREATED_BY, city.getCreatedBy()); put(CREATED_DATE, city.getCreatedDate()); put(LAST_MODIFIED_BY, city.getLastModifiedBy()); put(LAST_MODIFIED_DATE, city.getLastModifiedDate()); put(SHAPEFILE_LOCATION,city.getShapeFileLocation()); put(CAPTCHA, city.getCaptcha()); put(CODE, city.getCode()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); return city; } }
CityRepository { public City save(City city, String tenantCode) { Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(NAME, city.getName()); put(LOCAL_NAME, city.getLocalName()); put(DISTRICT_CODE, city.getDistrictCode()); put(DISTRICT_NAME, city.getDistrictName()); put(REGION_NAME, city.getRegionName()); put(LONGITUDE, city.getLongitude()); put(LATITUDE, city.getLatitude()); put(ULB_GRADE, city.getUlbGrade()); put(TENANT_CODE, tenantCode); put(CREATED_BY, city.getCreatedBy()); put(CREATED_DATE, city.getCreatedDate()); put(LAST_MODIFIED_BY, city.getLastModifiedBy()); put(LAST_MODIFIED_DATE, city.getLastModifiedDate()); put(SHAPEFILE_LOCATION,city.getShapeFileLocation()); put(CAPTCHA, city.getCaptcha()); put(CODE, city.getCode()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); return city; } CityRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
CityRepository { public City save(City city, String tenantCode) { Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(NAME, city.getName()); put(LOCAL_NAME, city.getLocalName()); put(DISTRICT_CODE, city.getDistrictCode()); put(DISTRICT_NAME, city.getDistrictName()); put(REGION_NAME, city.getRegionName()); put(LONGITUDE, city.getLongitude()); put(LATITUDE, city.getLatitude()); put(ULB_GRADE, city.getUlbGrade()); put(TENANT_CODE, tenantCode); put(CREATED_BY, city.getCreatedBy()); put(CREATED_DATE, city.getCreatedDate()); put(LAST_MODIFIED_BY, city.getLastModifiedBy()); put(LAST_MODIFIED_DATE, city.getLastModifiedDate()); put(SHAPEFILE_LOCATION,city.getShapeFileLocation()); put(CAPTCHA, city.getCaptcha()); put(CODE, city.getCode()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); return city; } CityRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); City save(City city, String tenantCode); City update(City city, String tenantCode); City find(String tenantCode); }
CityRepository { public City save(City city, String tenantCode) { Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(NAME, city.getName()); put(LOCAL_NAME, city.getLocalName()); put(DISTRICT_CODE, city.getDistrictCode()); put(DISTRICT_NAME, city.getDistrictName()); put(REGION_NAME, city.getRegionName()); put(LONGITUDE, city.getLongitude()); put(LATITUDE, city.getLatitude()); put(ULB_GRADE, city.getUlbGrade()); put(TENANT_CODE, tenantCode); put(CREATED_BY, city.getCreatedBy()); put(CREATED_DATE, city.getCreatedDate()); put(LAST_MODIFIED_BY, city.getLastModifiedBy()); put(LAST_MODIFIED_DATE, city.getLastModifiedDate()); put(SHAPEFILE_LOCATION,city.getShapeFileLocation()); put(CAPTCHA, city.getCaptcha()); put(CODE, city.getCode()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); return city; } CityRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); City save(City city, String tenantCode); City update(City city, String tenantCode); City find(String tenantCode);  }