Add totalVeganMeal property and fix checkstyle errors
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
package greenify.server.rest;
|
||||
|
||||
import greenify.common.UserDto;
|
||||
import greenify.server.data.model.User;
|
||||
import greenify.server.data.repository.UserRepository;
|
||||
import greenify.server.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
|
||||
@@ -32,7 +32,7 @@ public class UserService {
|
||||
throw new ApplicationException("User already exists");
|
||||
}
|
||||
logger.info("Created user id=" + user.getId() + ", name=" + user.getName());
|
||||
return new UserDto(user.getId(), user.getName());
|
||||
return new UserDto(user.getId(), user.getName(), user.getVeganMeal());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ public class UserService {
|
||||
throw new ApplicationException("Wrong password");
|
||||
}
|
||||
}
|
||||
return new UserDto(user.getId(), user.getName());
|
||||
return new UserDto(user.getId(), user.getName(), user.getVeganMeal());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ public class UserControllerTest {
|
||||
@Test
|
||||
public void registerUserTest() throws Exception {
|
||||
given(this.userService.registerUser("name", "password"))
|
||||
.willReturn(new UserDto(1L, "name"));
|
||||
.willReturn(new UserDto(1L, "name", 0));
|
||||
mvc.perform(get("/registerUser")
|
||||
.param("name", "name")
|
||||
.param("password", "password")
|
||||
@@ -46,7 +46,7 @@ public class UserControllerTest {
|
||||
@Test
|
||||
public void loginUserTest() throws Exception {
|
||||
given(this.userService.loginUser("ceren", "password"))
|
||||
.willReturn(new UserDto(1L, "ceren"));
|
||||
.willReturn(new UserDto(1L, "ceren", 0));
|
||||
mvc.perform(get("/loginUser")
|
||||
.param("name", "ceren")
|
||||
.param("password", "password")
|
||||
|
||||
@@ -56,25 +56,6 @@ public class UserServiceTest {
|
||||
assertEquals(userRepository.findAll(), userService.getAllUsers());
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void validRegisterTest() {
|
||||
// String name = "new";
|
||||
// String password = "user";
|
||||
// if(userRepository.findByName(name) == null) {
|
||||
// UserDto found = userService.registerUser(name, password);
|
||||
// assertEquals(found.getName(), name);
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void addVeganMealTest() {
|
||||
// User user = new User(1L, "name", "password", 0);
|
||||
// User user = userRepository.findByName("x");
|
||||
// int veganMeal = user.getVeganMeal();
|
||||
// userService.addVeganMeal(user.getId(), user.getName());
|
||||
// assertEquals(user.getVeganMeal(), veganMeal++);
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void invalidLoginTest() {
|
||||
User user = null;
|
||||
|
||||
Reference in New Issue
Block a user