UPDATE:: checkstyle fixes
This commit is contained in:
@@ -75,8 +75,8 @@ public class Achievement {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Achievement(name=" + name + ", description=" + description +
|
||||
", achieved=" + achieved + ")";
|
||||
return "Achievement(name=" + name + ", description=" + description
|
||||
+ ", achieved=" + achieved + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,9 +88,9 @@ public class Achievement {
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof Achievement) {
|
||||
Achievement that = (Achievement) other;
|
||||
return achieved == that.achieved &&
|
||||
name.equals(that.name) &&
|
||||
Objects.equals(description, that.description);
|
||||
return achieved == that.achieved
|
||||
&& name.equals(that.name)
|
||||
&& Objects.equals(description, that.description);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -82,4 +82,10 @@ public class UserController {
|
||||
@RequestParam(value = "friend") String friend) {
|
||||
userService.addFriend(name, friend);
|
||||
}
|
||||
|
||||
/* @RequestMapping("/addAchievement")
|
||||
public void addAchievement(@RequestParam(value = "name") String name,
|
||||
@RequestParam(value = "achievement") String achievement) {
|
||||
userService.achievementAchieved(name, achievement);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class AchievementService {
|
||||
private Logger logger = LoggerFactory.getLogger(UserService.class);
|
||||
|
||||
/**
|
||||
* This method updates all achievements of a user
|
||||
* This method updates all achievements of a user.
|
||||
* @param user the user for whom the achievements change
|
||||
*/
|
||||
public void updateAchievements(User user) {
|
||||
@@ -26,7 +26,7 @@ public class AchievementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method changes achiev1 when this is the case
|
||||
* This method changes achiev1 when this is the case.
|
||||
* @param user user for whom achiev1 changes
|
||||
*/
|
||||
public void achieveGettingStarted(User user) {
|
||||
|
||||
@@ -143,7 +143,7 @@ public class UserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* This methods sets a achievement
|
||||
* This methods sets a achievement.
|
||||
* @param name name of the user
|
||||
* @param achievement name of the achievement
|
||||
* @param achieved (not) achieved
|
||||
@@ -163,7 +163,7 @@ public class UserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets whether the achievement is achieved
|
||||
* This method gets whether the achievement is achieved.
|
||||
* @param name of the user
|
||||
* @param achievement name of the achievement
|
||||
* @return (not) achieved
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package greenify.server;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import greenify.server.AllAchievements;
|
||||
import greenify.server.data.model.Achievement;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class AllAchievementsTest {
|
||||
|
||||
@Test
|
||||
@@ -21,9 +20,12 @@ class AllAchievementsTest {
|
||||
@Test
|
||||
void getDefaultsTest() {
|
||||
List<Achievement> all = new ArrayList<Achievement>() {{
|
||||
add(new Achievement("Starting off", "You did your first green activity", false));
|
||||
add(new Achievement("Social butterfly", "You added three friends", false));
|
||||
}};
|
||||
add(new Achievement(
|
||||
"Starting off", "You did your first green activity", false));
|
||||
add(new Achievement(
|
||||
"Social butterfly", "You added three friends", false));
|
||||
}
|
||||
};
|
||||
assertEquals(all.size(), AllAchievements.getDefaults().size());
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
package greenify.server.data.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class AchievementTest {
|
||||
private Achievement achievement = new Achievement("SavedCO2", "You saved 100 cow farts of CO2!", true);
|
||||
private Achievement other = new Achievement("SavedCO2", "You saved 100 cow farts of CO2!", true);
|
||||
private Achievement achievement = new Achievement("SavedCO2",
|
||||
"You saved 100 cow farts of CO2!", true);
|
||||
private Achievement other = new Achievement("SavedCO2",
|
||||
"You saved 100 cow farts of CO2!", true);
|
||||
|
||||
@Test
|
||||
public void getAndSetTest() {
|
||||
@@ -22,7 +25,9 @@ class AchievementTest {
|
||||
|
||||
@Test
|
||||
public void toStringTest() {
|
||||
assertEquals("Achievement(name=SavedCO2, description=You saved 100 cow farts of CO2!, achieved=true)", achievement.toString());
|
||||
assertEquals("Achievement(name=SavedCO2, "
|
||||
+ "description=You saved 100 cow farts of CO2!, achieved=true)",
|
||||
achievement.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package greenify.server.service;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import greenify.common.ApplicationException;
|
||||
import greenify.common.UserDto;
|
||||
import greenify.server.InputValidator;
|
||||
import greenify.server.data.model.User;
|
||||
import greenify.server.data.repository.UserRepository;
|
||||
import org.junit.Before;
|
||||
@@ -18,8 +14,6 @@ import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class AchievementServiceTest {
|
||||
@TestConfiguration
|
||||
@@ -66,7 +60,7 @@ public class AchievementServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void AchieveGettingStartedTest() {
|
||||
public void achieveGettingStartedTest() {
|
||||
User alex = userRepository.findByName("alex");
|
||||
userService.setInput("alex", "input_size", "5");
|
||||
achievementService.achieveGettingStarted(alex);
|
||||
|
||||
Reference in New Issue
Block a user