@Test @Sql(scripts = { "/sql/clearAddresses.sql","/sql/clearUserRoles.sql","/sql/clearUsers.sql","/sql/createUsers.sql"}) public void test_should_save_new_address() { final Address domainAddress = Address.builder() .city("city") .userId(1l) .tenantId("ap.public") .address("address") .pinCode("pinCode") .type(AddressType.CORRESPONDENCE) .build(); final Address createdAddress = addressRepository.create(domainAddress, 1L, "ap.public"); assertNotNull(createdAddress); assertEquals("address", createdAddress.getAddress()); assertEquals("city", createdAddress.getCity()); assertEquals("pinCode", createdAddress.getPinCode()); assertEquals(AddressType.CORRESPONDENCE, createdAddress.getType()); }
public Address create(Address address, Long userId, String tenantId) { Map<String, Object> addressInputs = new HashMap<String, Object>(); addressInputs.put("id", getNextSequence()); addressInputs.put("type", address.getType().toString()); addressInputs.put("address", address.getAddress()); addressInputs.put("city", address.getCity()); addressInputs.put("pincode", address.getPinCode()); addressInputs.put("userid", userId); addressInputs.put("tenantid", tenantId); addressInputs.put("createddate", new Date()); addressInputs.put("lastmodifieddate", new Date()); addressInputs.put("createdby", userId); addressInputs.put("lastmodifiedby", address.getUserId()); namedParameterJdbcTemplate.update(INSERT_ADDRESS_BYUSERID, addressInputs); return address; }
AddressRepository { public Address create(Address address, Long userId, String tenantId) { Map<String, Object> addressInputs = new HashMap<String, Object>(); addressInputs.put("id", getNextSequence()); addressInputs.put("type", address.getType().toString()); addressInputs.put("address", address.getAddress()); addressInputs.put("city", address.getCity()); addressInputs.put("pincode", address.getPinCode()); addressInputs.put("userid", userId); addressInputs.put("tenantid", tenantId); addressInputs.put("createddate", new Date()); addressInputs.put("lastmodifieddate", new Date()); addressInputs.put("createdby", userId); addressInputs.put("lastmodifiedby", address.getUserId()); namedParameterJdbcTemplate.update(INSERT_ADDRESS_BYUSERID, addressInputs); return address; } }
AddressRepository { public Address create(Address address, Long userId, String tenantId) { Map<String, Object> addressInputs = new HashMap<String, Object>(); addressInputs.put("id", getNextSequence()); addressInputs.put("type", address.getType().toString()); addressInputs.put("address", address.getAddress()); addressInputs.put("city", address.getCity()); addressInputs.put("pincode", address.getPinCode()); addressInputs.put("userid", userId); addressInputs.put("tenantid", tenantId); addressInputs.put("createddate", new Date()); addressInputs.put("lastmodifieddate", new Date()); addressInputs.put("createdby", userId); addressInputs.put("lastmodifiedby", address.getUserId()); namedParameterJdbcTemplate.update(INSERT_ADDRESS_BYUSERID, addressInputs); return address; } AddressRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); }
AddressRepository { public Address create(Address address, Long userId, String tenantId) { Map<String, Object> addressInputs = new HashMap<String, Object>(); addressInputs.put("id", getNextSequence()); addressInputs.put("type", address.getType().toString()); addressInputs.put("address", address.getAddress()); addressInputs.put("city", address.getCity()); addressInputs.put("pincode", address.getPinCode()); addressInputs.put("userid", userId); addressInputs.put("tenantid", tenantId); addressInputs.put("createddate", new Date()); addressInputs.put("lastmodifieddate", new Date()); addressInputs.put("createdby", userId); addressInputs.put("lastmodifiedby", address.getUserId()); namedParameterJdbcTemplate.update(INSERT_ADDRESS_BYUSERID, addressInputs); return address; } AddressRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); Address create(Address address, Long userId, String tenantId); void update(List<Address> domainAddresses, Long userId, String tenantId); List<Address> find(Long userId, String tenantId); }
AddressRepository { public Address create(Address address, Long userId, String tenantId) { Map<String, Object> addressInputs = new HashMap<String, Object>(); addressInputs.put("id", getNextSequence()); addressInputs.put("type", address.getType().toString()); addressInputs.put("address", address.getAddress()); addressInputs.put("city", address.getCity()); addressInputs.put("pincode", address.getPinCode()); addressInputs.put("userid", userId); addressInputs.put("tenantid", tenantId); addressInputs.put("createddate", new Date()); addressInputs.put("lastmodifieddate", new Date()); addressInputs.put("createdby", userId); addressInputs.put("lastmodifiedby", address.getUserId()); namedParameterJdbcTemplate.update(INSERT_ADDRESS_BYUSERID, addressInputs); return address; } AddressRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); Address create(Address address, Long userId, String tenantId); void update(List<Address> domainAddresses, Long userId, String tenantId); List<Address> find(Long userId, String tenantId); static final String GET_ADDRESS_BY_USERID; static final String INSERT_ADDRESS_BYUSERID; static final String SELECT_NEXT_SEQUENCE; static final String DELETE_ADDRESSES; static final String DELETE_ADDRESS; static final String UPDATE_ADDRESS_BYIDAND_TENANTID; }