@Test @Sql(scripts = { "/sql/clearRole.sql" }) public void testshouldcreateroles() { RoleRequest roleRequest = new RoleRequest(); roleRequest.setRequestInfo(getRequestInfo()); roleRequest.setRoles(getRoles()); List<Role> roles = roleRepository.createRole(roleRequest); assertThat(roles.size()).isEqualTo(2); }
public List<Role> createRole(final RoleRequest roleRequest) { LOGGER.info("Create Role Repository::" + roleRequest); final String roleInsert = RoleQueryBuilder.insertRoleQuery(); 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("createdby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("createddate", new Date(new java.util.Date().getTime())) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleInsert, batchValues.toArray(new Map[roles.size()])); return roles; }
RoleRepository { public List<Role> createRole(final RoleRequest roleRequest) { LOGGER.info("Create Role Repository::" + roleRequest); final String roleInsert = RoleQueryBuilder.insertRoleQuery(); 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("createdby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("createddate", new Date(new java.util.Date().getTime())) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleInsert, batchValues.toArray(new Map[roles.size()])); return roles; } }
RoleRepository { public List<Role> createRole(final RoleRequest roleRequest) { LOGGER.info("Create Role Repository::" + roleRequest); final String roleInsert = RoleQueryBuilder.insertRoleQuery(); 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("createdby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("createddate", new Date(new java.util.Date().getTime())) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleInsert, batchValues.toArray(new Map[roles.size()])); return roles; }  }
RoleRepository { public List<Role> createRole(final RoleRequest roleRequest) { LOGGER.info("Create Role Repository::" + roleRequest); final String roleInsert = RoleQueryBuilder.insertRoleQuery(); 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("createdby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("createddate", new Date(new java.util.Date().getTime())) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleInsert, 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> createRole(final RoleRequest roleRequest) { LOGGER.info("Create Role Repository::" + roleRequest); final String roleInsert = RoleQueryBuilder.insertRoleQuery(); 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("createdby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("createddate", new Date(new java.util.Date().getTime())) .addValue("lastmodifiedby", Long.valueOf(roleRequest.getRequestInfo().getUserInfo().getId())) .addValue("lastmodifieddate", new Date(new java.util.Date().getTime())).getValues()); } namedParameterJdbcTemplate.batchUpdate(roleInsert, 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; }