@Test @Sql(scripts = { "/sql/clearRole.sql", "/sql/insertRoleData.sql" }) public void testShouldUpdateRoles() { RoleRequest roleRequest = new RoleRequest(); roleRequest.setRequestInfo(getRequestInfo()); List<Role> roleList = new ArrayList<Role>(); Role role = Role.builder().id(1L).name("Citizen").code("citizencode").description("citizendescription").build(); roleList.add(role); roleRequest.setRoles(roleList); List<Role> roles = roleRepository.updateRole(roleRequest); assertThat(roles.size()).isEqualTo(1); assertThat(roles.get(0).getCode().equals("citizencode")); assertThat(roles.get(0).getDescription().equals("citizendescription")); }
public List<Role> updateRole(final RoleRequest roleRequest) { LOGGER.info("update Role Repository::" + roleRequest); final String roleUpdate = RoleQueryBuilder.updateRoleQuery(); List<Role> roles = roleRequest.getRoles(); List<Map<String, Object>> batchValues = new ArrayList<>(roles.size()); for (Role role : roles) { batchValues.add(new MapSqlParameterSource("name", role.getName()).addValue("code", role.getCode()) .addValue("description", role.getDescription()) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleUpdate, batchValues.toArray(new Map[roles.size()])); return roles; }
RoleRepository { public List<Role> updateRole(final RoleRequest roleRequest) { LOGGER.info("update Role Repository::" + roleRequest); final String roleUpdate = RoleQueryBuilder.updateRoleQuery(); List<Role> roles = roleRequest.getRoles(); List<Map<String, Object>> batchValues = new ArrayList<>(roles.size()); for (Role role : roles) { batchValues.add(new MapSqlParameterSource("name", role.getName()).addValue("code", role.getCode()) .addValue("description", role.getDescription()) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleUpdate, batchValues.toArray(new Map[roles.size()])); return roles; } }
RoleRepository { public List<Role> updateRole(final RoleRequest roleRequest) { LOGGER.info("update Role Repository::" + roleRequest); final String roleUpdate = RoleQueryBuilder.updateRoleQuery(); List<Role> roles = roleRequest.getRoles(); List<Map<String, Object>> batchValues = new ArrayList<>(roles.size()); for (Role role : roles) { batchValues.add(new MapSqlParameterSource("name", role.getName()).addValue("code", role.getCode()) .addValue("description", role.getDescription()) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleUpdate, batchValues.toArray(new Map[roles.size()])); return roles; }  }
RoleRepository { public List<Role> updateRole(final RoleRequest roleRequest) { LOGGER.info("update Role Repository::" + roleRequest); final String roleUpdate = RoleQueryBuilder.updateRoleQuery(); List<Role> roles = roleRequest.getRoles(); List<Map<String, Object>> batchValues = new ArrayList<>(roles.size()); for (Role role : roles) { batchValues.add(new MapSqlParameterSource("name", role.getName()).addValue("code", role.getCode()) .addValue("description", role.getDescription()) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleUpdate, batchValues.toArray(new Map[roles.size()])); return roles; }  List<Role> createRole(final RoleRequest roleRequest); List<Role> updateRole(final RoleRequest roleRequest); boolean checkRoleNameDuplicationValidationErrors(String roleName); List<Role> getAllMDMSRoles(RoleSearchCriteria roleSearchCriteria); static RequestInfo getRInfo(); }
RoleRepository { public List<Role> updateRole(final RoleRequest roleRequest) { LOGGER.info("update Role Repository::" + roleRequest); final String roleUpdate = RoleQueryBuilder.updateRoleQuery(); List<Role> roles = roleRequest.getRoles(); List<Map<String, Object>> batchValues = new ArrayList<>(roles.size()); for (Role role : roles) { batchValues.add(new MapSqlParameterSource("name", role.getName()).addValue("code", role.getCode()) .addValue("description", role.getDescription()) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleUpdate, batchValues.toArray(new Map[roles.size()])); return roles; }  List<Role> createRole(final RoleRequest roleRequest); List<Role> updateRole(final RoleRequest roleRequest); boolean checkRoleNameDuplicationValidationErrors(String roleName); List<Role> getAllMDMSRoles(RoleSearchCriteria roleSearchCriteria); static RequestInfo getRInfo(); static final Logger LOGGER; }