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