Commit cd3051f894b3e87c5aec3ffe707e390b306fc094

Authored by Thomas Ziemer
1 parent f18d339f

bugfix: RestResponse glattgezogen

src/main/java/net/ziemers/swxercise/ui/RestResponse.java
1 1 package net.ziemers.swxercise.ui;
2 2  
3 3 import net.ziemers.swxercise.ui.enums.ResponseState;
4   -import net.ziemers.swxercise.ui.enums.ResponseState.SUCCESS;
5 4  
6 5 public class RestResponse {
7 6  
... ... @@ -23,5 +22,15 @@ public class RestResponse {
23 22 return responseState.getResponseText();
24 23 }
25 24  
  25 + @Override
  26 + public boolean equals(Object o) {
  27 + if (this == o) return true;
  28 + if (o == null || getClass() != o.getClass()) return false;
  29 +
  30 + RestResponse that = (RestResponse) o;
  31 +
  32 + return responseState == that.responseState;
  33 + }
  34 +
26 35 }
27 36  
... ...
src/main/java/net/ziemers/swxercise/ui/UserViewController.java
... ... @@ -10,9 +10,7 @@ import javax.ws.rs.core.MediaType;
10 10 import net.ziemers.swxercise.lg.model.user.User;
11 11 import net.ziemers.swxercise.lg.user.dto.UserDto;
12 12 import net.ziemers.swxercise.lg.user.service.UserService;
13   -
14   -import net.ziemers.swxercise.ui.RestResponse;
15   -import net.ziemers.swxercise.ui.enums.ResponseState.FAILED;
  13 +import net.ziemers.swxercise.ui.enums.ResponseState;
16 14  
17 15 /**
18 16 * REST-Methoden für die Benutzerverwaltung.
... ... @@ -70,7 +68,7 @@ public class UserViewController {
70 68 @Consumes(MediaType.APPLICATION_JSON)
71 69 @Produces(MediaType.APPLICATION_JSON)
72 70 public RestResponse createUser(UserDto dto) throws Exception {
73   - final Long id = userService.createUser(dto);
  71 + userService.createUser(dto);
74 72 return new RestResponse();
75 73 }
76 74  
... ...
src/test/java/net/ziemers/swxercise/ui/UserViewControllerTest.java
... ... @@ -25,7 +25,7 @@ public class UserViewControllerTest {
25 25  
26 26 private User user;
27 27  
28   - private String actualString;
  28 + private RestResponse actual;
29 29  
30 30 @Test
31 31 public void testJUnitFrameworkReturnsTrue() {
... ... @@ -117,7 +117,7 @@ public class UserViewControllerTest {
117 117 when(userService.loginUser(userDto)).thenReturn(true);
118 118 when(userService.getSessionUser()).thenReturn(user);
119 119  
120   - actualString = underTest.loginUser(userDto);
  120 + actual = underTest.loginUser(userDto);
121 121 }
122 122  
123 123 // then
... ... @@ -127,8 +127,8 @@ public class UserViewControllerTest {
127 127 }
128 128  
129 129 private void assertLoginSuccess() {
130   - final String expected = String.format("Ok (%s %s)", user.getFirstname(), user.getLastname());
131   - assertEquals(expected, actualString);
  130 + final RestResponse expected = new RestResponse();
  131 + assertEquals(expected, actual);
132 132 }
133 133  
134 134 }
... ...