Skip to content

Commit

Permalink
fix: ajuste no atributo user.name para user.first_name #64
Browse files Browse the repository at this point in the history
  • Loading branch information
tacianosilva committed Apr 19, 2024
1 parent b2a7c0c commit fe5ea66
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class AbstractController {
protected void setUserAuth(ModelAndView modelAndView) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
User user = userService.findUserByEmail(auth.getName());
modelAndView.addObject("userName", user.getName() + " " + user.getLastName() + " (" + user.getEmail() + ")");
modelAndView.addObject("userName", user.getFirstName() + " " + user.getLastName() + " (" + user.getEmail() + ")");
modelAndView.addObject("authorities", getRoles(user));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/br/ufrn/dct/apf/controller/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ModelAndView homeAdmin() {
Authentication auth = context.getAuthentication();

User user = userService.findUserByEmail(auth.getName());
modelAndView.addObject("userName", user.getName() + " " + user.getLastName() + " (" + user.getEmail() + ")");
modelAndView.addObject("userName", user.getFirstName() + " " + user.getLastName() + " (" + user.getEmail() + ")");
modelAndView.addObject("authorities", getRoles(user));
modelAndView.addObject("adminMessage", "Content Available Only for Users with Admin Role");
modelAndView.setViewName("admin/home");
Expand Down Expand Up @@ -114,7 +114,7 @@ public ModelAndView accesssDenied() {
User user = getCurrentUser();

if (user != null) {
model.addObject("msg", "Hi " + user.getName() + ", you do not have permission to access this page!");
model.addObject("msg", "Hi " + user.getFirstName() + ", you do not have permission to access this page!");
} else {
model.addObject("msg", "You do not have permission to access this page!");
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/br/ufrn/dct/apf/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public class User implements Serializable {
@Transient
private String password;

@Column(name = "name")
@Column(name = "first_name")
@NotEmpty(message = "*Please provide your name")
private String name;
private String firstName;

@Column(name = "last_name")
@NotEmpty(message = "*Please provide your last name")
Expand Down Expand Up @@ -83,12 +83,12 @@ public void setPassword(String password) {
this.password = password;
}

public String getName() {
return name;
public String getFirstName() {
return firstName;
}

public void setName(String name) {
this.name = name;
public void setFirstName(String name) {
this.firstName = name;
}

public String getLastName() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/admin/user/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<tbody>
<tr th:each="usuario : ${users}">
<td th:text="${usuario.id}"></td>
<td th:text="${usuario.name}"></td>
<td th:text="${usuario.firstName}"></td>
<td th:text="${usuario.email}"></td>
<td th:text="${usuario.roles}"></td>
<td>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/project/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<strong>Data Functions</strong>
Expand Down Expand Up @@ -149,7 +149,7 @@
<tbody>
<tr th:each="member : ${project.team}">
<td th:text="${member.user.id}"></td>
<td th:text="${member.user.name}"></td>
<td th:text="${member.user.firstName}"></td>
<td th:text="${member.user.roles}"></td>
<td th:text="${member.attribution.name}"></td>
<td>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<h2>Registration Form</h2>
<div class="form-group">
<div class="col-sm-9">
<label th:if="${#fields.hasErrors('name')}" th:errors="*{name}"
<label th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}"
class="validation-message"></label>
<input type="text" th:field="*{name}" placeholder="Name"
<input type="text" th:field="*{firstName}" placeholder="First Name"
class="form-control" />
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/user/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Role</th>
Expand All @@ -44,7 +44,7 @@
<tbody>
<tr th:each="usuario : ${user}">
<td th:text="${usuario.id}"></td>
<td th:text="${usuario.name}"></td>
<td th:text="${usuario.firstName}"></td>
<td th:text="${usuario.lastName}"></td>
<td th:text="${usuario.email}"></td>
<td th:text="${usuario.roles}"></td>
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/br/ufrn/dct/apf/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public static void main(String[] args) {

User analista = new User();
analista.setId(1L);
analista.setName("Taciano");
analista.setFirstName("Taciano");
analista.setLastName("Morais Silva");
analista.setEmail("[email protected]");
analista.setPassword("12345");

User desenvolvedor = new User();
desenvolvedor.setId(2L);
desenvolvedor.setName("Zé");
desenvolvedor.setFirstName("Zé");
desenvolvedor.setLastName("Silva");
desenvolvedor.setEmail("[email protected]");
desenvolvedor.setPassword("12345");
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/br/ufrn/dct/apf/ConceitosTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ public void conceitos() throws BusinessRuleException {
System.out.println("Criando o usuário ...");

User analista = new User();
analista.setName("Taciano");
analista.setFirstName("Taciano");
analista.setLastName("Silva");
analista.setEmail("[email protected]");
analista.setPassword("12345");
analista.setActive(1);

User developer = new User();
developer.setName("Zé");
developer.setFirstName("Zé");
developer.setLastName("Silva");
developer.setEmail("[email protected]");
developer.setPassword("12345");
developer.setActive(1);

User developerMaria = new User();
developerMaria.setName("Maria");
developerMaria.setFirstName("Maria");
developerMaria.setLastName("Silva");
developerMaria.setEmail("[email protected]");
developerMaria.setPassword("12345");
Expand Down Expand Up @@ -181,7 +181,7 @@ public void conceitos() throws BusinessRuleException {
Set<Member> team = project.getTeam();

for (Member member : team) {
System.out.println("Membro ID = " + member.getId() + ", Name = " + member.getUser().getName());
System.out.println("Membro ID = " + member.getId() + ", Name = " + member.getUser().getFirstName());
}

System.out.println("Listar os User Stories do Projeto ID = " + project.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void findByName() {
private User createUser() {
user1 = new User();

user1.setName("Taciano Silva");
user1.setFirstName("Taciano");
user1.setLastName("Silva");
user1.setEmail("[email protected]");
user1.setPassword("12345");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class AbstractServiceTest extends AbstractTestNGSpringContextTes
protected User createUser(String name, String lastName) {
User user = new User();

user.setName(name);
user.setFirstName(name);
user.setLastName(lastName);
user.setEmail(name+lastName+"@gmail.com");
user.setPassword("12345");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public void delete() throws BusinessRuleException {
private User createUser(String name, String lastName, String email) {
User user = new User();

user.setName(name);
user.setFirstName(name);
user.setLastName(lastName);
user.setEmail(email);
user.setPassword("12345");
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/br/ufrn/dct/apf/service/TeamServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ public void startTest() throws BusinessRuleException {
softAssert = new SoftAssert();

analista = new User();
analista.setName("Taciano");
analista.setFirstName("Taciano");
analista.setLastName("Morais Silva");
analista.setEmail("[email protected]");
analista.setPassword("12345");

desenvolvedor = new User();
desenvolvedor.setName("Zé");
desenvolvedor.setFirstName("Zé");
desenvolvedor.setLastName("Silva");
desenvolvedor.setEmail("[email protected]");
desenvolvedor.setPassword("12345");

dev2 = new User();
dev2.setName("dev2");
dev2.setFirstName("dev2");
dev2.setLastName("Silva");
dev2.setEmail("[email protected]");
dev2.setPassword("12345");
Expand Down Expand Up @@ -179,7 +179,7 @@ public void save() throws BusinessRuleException {
softAssert.assertFalse(team1.contains(m2), "T02.4 - False:");

for (Member member : team1) {
System.out.println(member.getUser().getName());
System.out.println(member.getUser().getFirstName());
System.out.println(member.getProject().getName());
}
System.out.println("Team 1 contais m1: " + team1.contains(m1));
Expand Down Expand Up @@ -212,7 +212,7 @@ public void save() throws BusinessRuleException {
System.out.println("Team contais m1: " + team2.contains(m1));
System.out.println("Team contais m2: " + team2.contains(m2));
for (Member member : team2) {
System.out.println(member.getUser().getName());
System.out.println(member.getUser().getFirstName());
System.out.println(member.getProject().getName());
}

Expand Down Expand Up @@ -265,7 +265,7 @@ public void saveMember() throws BusinessRuleException {
softAssert.assertFalse(team1.contains(m2), "T02.4 - False:");

for (Member member : team1) {
System.out.println(member.getUser().getName());
System.out.println(member.getUser().getFirstName());
System.out.println(member.getProject().getName());
}
System.out.println("Team 1 contais m1: " + team1.contains(m1));
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/br/ufrn/dct/apf/service/UserServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void startTest() {

user1 = new User();

user1.setName("Taciano Silva");
user1.setFirstName("Taciano Silva");
user1.setLastName("Silva");
user1.setEmail("[email protected]");
user1.setPassword("12345");
Expand Down Expand Up @@ -64,7 +64,7 @@ public void findOne() {

softAssert.assertNotNull(found, "T01 - NotNull:");

softAssert.assertEquals(found.getName(), user1.getName(), "T03 - Equals:");
softAssert.assertEquals(found.getFirstName(), user1.getFirstName(), "T03 - Equals:");
softAssert.assertEquals(found.getLastName(), user1.getLastName(), "T04 - Equals:");
softAssert.assertEquals(found.getEmail(), user1.getEmail(), "T05 - Equals:");

Expand All @@ -82,7 +82,7 @@ public void findUserByEmail() {

softAssert.assertNotNull(found, "T01 - NotNull:");

softAssert.assertEquals(found.getName(), user1.getName(), "T03 - Equals:");
softAssert.assertEquals(found.getFirstName(), user1.getFirstName(), "T03 - Equals:");
softAssert.assertEquals(found.getLastName(), user1.getLastName(), "T04 - Equals:");
softAssert.assertEquals(found.getEmail(), user1.getEmail(), "T05 - Equals:");
softAssert.assertNotNull(found.getActive(), "T06 - NotNull:");
Expand All @@ -95,7 +95,7 @@ public void findUserByEmail() {
public void save() {
User user2 = new User();

user2.setName("Zé");
user2.setFirstName("Zé");
user2.setLastName("Brasil");
user2.setEmail("[email protected]");
user2.setPassword("345");
Expand All @@ -114,7 +114,7 @@ public void save() {
softAssert.assertNotNull(usuarios, "T03 - NotNull:");
softAssert.assertEquals(usuarios.size(), 2, "T04 - Equals:");

softAssert.assertEquals(found.getName(), user2.getName(), "T05 - Equals:");
softAssert.assertEquals(found.getFirstName(), user2.getFirstName(), "T05 - Equals:");
softAssert.assertEquals(found.getLastName(), user2.getLastName(), "T06 - Equals:");
softAssert.assertEquals(found.getEmail(), user2.getEmail(), "T07 - Equals:");

Expand All @@ -132,7 +132,7 @@ public void update() {

User update = service.findOne(id);

update.setName("Marcos");
update.setFirstName("Marcos");
update.setLastName("Morais");
update.setEmail("[email protected]");
// Simular o não preenchimento da senha
Expand All @@ -143,8 +143,8 @@ public void update() {
User found = service.findOne(id);

softAssert.assertNotNull(found, "T01 - NotNull:");
softAssert.assertEquals(found.getName(), "Marcos", "T02 - Equals:");
softAssert.assertNotEquals(found.getName(), "Taciano", "T03 - Equals:");
softAssert.assertEquals(found.getFirstName(), "Marcos", "T02 - Equals:");
softAssert.assertNotEquals(found.getFirstName(), "Taciano", "T03 - Equals:");
softAssert.assertEquals(found.getLastName(), "Morais", "T04 - Equals:");
softAssert.assertNotEquals(found.getLastName(), "Silva", "T05 - Equals:");
softAssert.assertEquals(found.getEmail(), "[email protected]", "T06 - Equals:");
Expand All @@ -170,7 +170,7 @@ public void update() {
User found2 = service.findOne(id);

softAssert.assertNotNull(found2, "T10 - NotNull:");
softAssert.assertEquals(found2.getName(), "Marcos", "T11 - Equals:");
softAssert.assertEquals(found2.getFirstName(), "Marcos", "T11 - Equals:");
softAssert.assertEquals(found2.getLastName(), "Morais", "T12 - Equals:");
softAssert.assertEquals(found2.getEmail(), "[email protected]", "T13 - Equals:");
softAssert.assertEquals(found2.getActive(), 1, "T14 - Equals:");
Expand All @@ -184,7 +184,7 @@ public void update() {
public void delete() {
User user3 = new User();

user3.setName("Test Project");
user3.setFirstName("Test Project");
user3.setLastName("TestNG Project");
user3.setEmail("[email protected]");
user3.setPassword("123");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void delete() throws BusinessRuleException {
private User createUser() {
User user = new User();

user.setName("Taciano Silva");
user.setFirstName("Taciano");
user.setLastName("Silva");
user.setEmail("[email protected]");
user.setPassword("12345");
Expand Down

0 comments on commit fe5ea66

Please sign in to comment.