DEBUG:: achievement things (tests all work now)
This commit is contained in:
@@ -3,8 +3,9 @@ package greenify.server;
|
|||||||
import greenify.server.data.model.Achievement;
|
import greenify.server.data.model.Achievement;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class AllAchievements {
|
public class AllAchievements {
|
||||||
private static final List<Achievement> allAchievements = Arrays.asList(
|
private static final List<Achievement> allAchievements = Arrays.asList(
|
||||||
@@ -16,8 +17,12 @@ public class AllAchievements {
|
|||||||
* This method gets default achievements.
|
* This method gets default achievements.
|
||||||
* @return the list of default achievements
|
* @return the list of default achievements
|
||||||
*/
|
*/
|
||||||
public static List<Achievement> getDefaults() {
|
public static Map<String, Boolean> getDefaults() {
|
||||||
return new ArrayList<>(allAchievements);
|
Map<String, Boolean> all = new HashMap<>();
|
||||||
|
for (Achievement achievement : allAchievements) {
|
||||||
|
all.put(achievement.getName(), achievement.isAchieved());
|
||||||
|
}
|
||||||
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import lombok.Data;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -19,7 +18,6 @@ import javax.persistence.GenerationType;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@@ -50,7 +48,7 @@ public class User {
|
|||||||
private Collection<User> friends;
|
private Collection<User> friends;
|
||||||
|
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
private List<Achievement> achievements;
|
private Map<String, Boolean> achievements;
|
||||||
|
|
||||||
public User() {}
|
public User() {}
|
||||||
|
|
||||||
@@ -182,7 +180,7 @@ public class User {
|
|||||||
* This method sets the achievements of the user.
|
* This method sets the achievements of the user.
|
||||||
* @param achievements achievements of the user
|
* @param achievements achievements of the user
|
||||||
*/
|
*/
|
||||||
public void setAchievements(List<Achievement> achievements) {
|
public void setAchievements(Map<String, Boolean> achievements) {
|
||||||
this.achievements = achievements;
|
this.achievements = achievements;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +188,7 @@ public class User {
|
|||||||
* This method gets the achievements of the user.
|
* This method gets the achievements of the user.
|
||||||
* @return achievements of the user
|
* @return achievements of the user
|
||||||
*/
|
*/
|
||||||
public List<Achievement> getAchievements() {
|
public Map<String, Boolean> getAchievements() {
|
||||||
return this.achievements;
|
return this.achievements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package greenify.server.data.model;
|
package greenify.server.data.model;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import greenify.common.ApplicationException;
|
import greenify.common.ApplicationException;
|
||||||
|
|||||||
Reference in New Issue
Block a user