@Test @Sql(scripts = {"/sql/clearCity.sql", "/sql/clearTenant.sql"}) public void test_should_save_tenant() throws Exception { City city = City.builder().id(1L).build(); Tenant tenant = Tenant.builder() .code("AP.KURNOOL") .name("kurnool") .description("description") .domainUrl("http: .logoId("d45d7118-2013-11e7-93ae-92361f002671") .imageId("8716872c-cd50-4fbb-a0d6-722e6bc9c143") .type("CITY") .twitterUrl("twitterUrl") .facebookUrl("faceBookUrl") .emailId("email") .address("address") .contactNumber("contactNumber") .helpLineNumber("helpLineNumber") .city(city) .build(); tenantRepository.save(tenant); List<Map<String, Object>> result = namedParameterJdbcTemplate.query("SELECT * FROM tenant", new TenantResultExtractor()); Map<String, Object> row = result.get(0); assertThat(row.get(ID)).isEqualTo(1L); assertThat(row.get(CODE)).isEqualTo("AP.KURNOOL"); assertThat(row.get(NAME)).isEqualTo("kurnool"); assertThat(row.get(DESCRIPTION)).isEqualTo("description"); assertThat(row.get(DOMAIN_URL)).isEqualTo("http: assertThat(row.get(LOGO_ID)).isEqualTo("d45d7118-2013-11e7-93ae-92361f002671"); assertThat(row.get(IMAGE_ID)).isEqualTo("8716872c-cd50-4fbb-a0d6-722e6bc9c143"); assertThat(row.get(TYPE)).isEqualTo("CITY"); assertThat(row.get(CREATED_BY)).isEqualTo(1L); assertThat(row.get(CREATED_DATE)).isNotNull(); assertThat(row.get(LAST_MODIFIED_BY)).isEqualTo(1L); assertThat(row.get(LAST_MODIFIED_DATE)).isNotNull(); assertThat(row.get(TWITTER_URL)).isNotNull(); assertThat(row.get(FACEBOOK_URL)).isNotNull(); assertThat(row.get(EMAILID)).isNotNull(); assertThat(row.get(ADDRESS)).isEqualTo("address"); assertThat(row.get(CONTACTNUMBER)).isEqualTo("contactNumber"); assertThat(row.get(HELPLINENUMBER)).isEqualTo("helpLineNumber"); verify(cityRepository).save(city, "AP.KURNOOL"); }
@Transactional public org.egov.tenant.domain.model.Tenant save(final org.egov.tenant.domain.model.Tenant tenant) { final Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(Tenant.CODE, tenant.getCode()); put(Tenant.NAME, tenant.getName()); put(Tenant.DESCRIPTION, tenant.getDescription()); put(Tenant.DOMAIN_URL, tenant.getDomainUrl()); put(Tenant.LOGO_ID, tenant.getLogoId()); put(Tenant.IMAGE_ID, tenant.getImageId()); put(Tenant.TYPE, tenant.getType().toString()); put(Tenant.CREATED_BY, 1L); put(Tenant.CREATED_DATE, new Date()); put(Tenant.LAST_MODIFIED_BY, 1L); put(Tenant.LAST_MODIFIED_DATE, new Date()); put(Tenant.TWITTER_URL,tenant.getTwitterUrl()); put(Tenant.FACEBOOK_URL,tenant.getFacebookUrl()); put(Tenant.ADDRESS, tenant.getAddress()); put(Tenant.CONTACTNUMBER, tenant.getContactNumber()); put(Tenant.HELPLINENUMBER,tenant.getHelpLineNumber()); put(Tenant.EMAILID,tenant.getEmailId()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); cityRepository.save(tenant.getCity(), tenant.getCode()); return tenant; }
TenantRepository { @Transactional public org.egov.tenant.domain.model.Tenant save(final org.egov.tenant.domain.model.Tenant tenant) { final Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(Tenant.CODE, tenant.getCode()); put(Tenant.NAME, tenant.getName()); put(Tenant.DESCRIPTION, tenant.getDescription()); put(Tenant.DOMAIN_URL, tenant.getDomainUrl()); put(Tenant.LOGO_ID, tenant.getLogoId()); put(Tenant.IMAGE_ID, tenant.getImageId()); put(Tenant.TYPE, tenant.getType().toString()); put(Tenant.CREATED_BY, 1L); put(Tenant.CREATED_DATE, new Date()); put(Tenant.LAST_MODIFIED_BY, 1L); put(Tenant.LAST_MODIFIED_DATE, new Date()); put(Tenant.TWITTER_URL,tenant.getTwitterUrl()); put(Tenant.FACEBOOK_URL,tenant.getFacebookUrl()); put(Tenant.ADDRESS, tenant.getAddress()); put(Tenant.CONTACTNUMBER, tenant.getContactNumber()); put(Tenant.HELPLINENUMBER,tenant.getHelpLineNumber()); put(Tenant.EMAILID,tenant.getEmailId()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); cityRepository.save(tenant.getCity(), tenant.getCode()); return tenant; } }
TenantRepository { @Transactional public org.egov.tenant.domain.model.Tenant save(final org.egov.tenant.domain.model.Tenant tenant) { final Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(Tenant.CODE, tenant.getCode()); put(Tenant.NAME, tenant.getName()); put(Tenant.DESCRIPTION, tenant.getDescription()); put(Tenant.DOMAIN_URL, tenant.getDomainUrl()); put(Tenant.LOGO_ID, tenant.getLogoId()); put(Tenant.IMAGE_ID, tenant.getImageId()); put(Tenant.TYPE, tenant.getType().toString()); put(Tenant.CREATED_BY, 1L); put(Tenant.CREATED_DATE, new Date()); put(Tenant.LAST_MODIFIED_BY, 1L); put(Tenant.LAST_MODIFIED_DATE, new Date()); put(Tenant.TWITTER_URL,tenant.getTwitterUrl()); put(Tenant.FACEBOOK_URL,tenant.getFacebookUrl()); put(Tenant.ADDRESS, tenant.getAddress()); put(Tenant.CONTACTNUMBER, tenant.getContactNumber()); put(Tenant.HELPLINENUMBER,tenant.getHelpLineNumber()); put(Tenant.EMAILID,tenant.getEmailId()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); cityRepository.save(tenant.getCity(), tenant.getCode()); return tenant; } TenantRepository(CityRepository cityRepository, NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
TenantRepository { @Transactional public org.egov.tenant.domain.model.Tenant save(final org.egov.tenant.domain.model.Tenant tenant) { final Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(Tenant.CODE, tenant.getCode()); put(Tenant.NAME, tenant.getName()); put(Tenant.DESCRIPTION, tenant.getDescription()); put(Tenant.DOMAIN_URL, tenant.getDomainUrl()); put(Tenant.LOGO_ID, tenant.getLogoId()); put(Tenant.IMAGE_ID, tenant.getImageId()); put(Tenant.TYPE, tenant.getType().toString()); put(Tenant.CREATED_BY, 1L); put(Tenant.CREATED_DATE, new Date()); put(Tenant.LAST_MODIFIED_BY, 1L); put(Tenant.LAST_MODIFIED_DATE, new Date()); put(Tenant.TWITTER_URL,tenant.getTwitterUrl()); put(Tenant.FACEBOOK_URL,tenant.getFacebookUrl()); put(Tenant.ADDRESS, tenant.getAddress()); put(Tenant.CONTACTNUMBER, tenant.getContactNumber()); put(Tenant.HELPLINENUMBER,tenant.getHelpLineNumber()); put(Tenant.EMAILID,tenant.getEmailId()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); cityRepository.save(tenant.getCity(), tenant.getCode()); return tenant; } 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 { @Transactional public org.egov.tenant.domain.model.Tenant save(final org.egov.tenant.domain.model.Tenant tenant) { final Map<String, Object> parametersMap = new HashMap<String, Object>() {{ put(Tenant.CODE, tenant.getCode()); put(Tenant.NAME, tenant.getName()); put(Tenant.DESCRIPTION, tenant.getDescription()); put(Tenant.DOMAIN_URL, tenant.getDomainUrl()); put(Tenant.LOGO_ID, tenant.getLogoId()); put(Tenant.IMAGE_ID, tenant.getImageId()); put(Tenant.TYPE, tenant.getType().toString()); put(Tenant.CREATED_BY, 1L); put(Tenant.CREATED_DATE, new Date()); put(Tenant.LAST_MODIFIED_BY, 1L); put(Tenant.LAST_MODIFIED_DATE, new Date()); put(Tenant.TWITTER_URL,tenant.getTwitterUrl()); put(Tenant.FACEBOOK_URL,tenant.getFacebookUrl()); put(Tenant.ADDRESS, tenant.getAddress()); put(Tenant.CONTACTNUMBER, tenant.getContactNumber()); put(Tenant.HELPLINENUMBER,tenant.getHelpLineNumber()); put(Tenant.EMAILID,tenant.getEmailId()); }}; namedParameterJdbcTemplate.update(INSERT_QUERY, parametersMap); cityRepository.save(tenant.getCity(), tenant.getCode()); return tenant; } 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);  }