Fix checkstyle errors

This commit is contained in:
Merel Steenbergen
2019-03-26 11:24:10 +01:00
parent 4a6d4c7043
commit f39aef31d0
3 changed files with 23 additions and 20 deletions

View File

@@ -7,16 +7,11 @@ import lombok.Data;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.*;
import java.util.logging.Logger;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Entity
@@ -27,7 +22,6 @@ public class User {
@Id
@NotNull
@GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
private Long id;
@NotNull
@@ -118,6 +112,10 @@ public class User {
return (ArrayList<User>)this.friends;
}
/**
* Adds a friend to the friendslist of the user.
* @param user the friend you want to add.
*/
public void addFriend(User user) {
if (user.equals(this)) {
throw new ApplicationException("Cannot add yourself as a friend");
@@ -143,6 +141,10 @@ public class User {
+ this.password + ")";
}
/**
* Returns the name and score of the friends in JSON. Needed for the leaderboard.
* @return a JSON object of the friendlist with only names and scores.
*/
public String friendsToString(){
String result = "friends=[";
for (User u : friends) {

View File

@@ -49,7 +49,8 @@ public class UserServiceTest {
.thenReturn(alex);
User lola = new User(2L, "lola", "password");
when(userRepository.findByName(lola.getName()))
.thenReturn(lola); }
.thenReturn(lola);
}
@Test
public void validLoginTest() {