Commit cd3051f894b3e87c5aec3ffe707e390b306fc094

Authored by Thomas Ziemer
1 parent f18d339f

bugfix: RestResponse glattgezogen

src/main/java/net/ziemers/swxercise/ui/RestResponse.java
1 package net.ziemers.swxercise.ui; 1 package net.ziemers.swxercise.ui;
2 2
3 import net.ziemers.swxercise.ui.enums.ResponseState; 3 import net.ziemers.swxercise.ui.enums.ResponseState;
4 -import net.ziemers.swxercise.ui.enums.ResponseState.SUCCESS;  
5 4
6 public class RestResponse { 5 public class RestResponse {
7 6
@@ -23,5 +22,15 @@ public class RestResponse { @@ -23,5 +22,15 @@ public class RestResponse {
23 return responseState.getResponseText(); 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,9 +10,7 @@ import javax.ws.rs.core.MediaType;
10 import net.ziemers.swxercise.lg.model.user.User; 10 import net.ziemers.swxercise.lg.model.user.User;
11 import net.ziemers.swxercise.lg.user.dto.UserDto; 11 import net.ziemers.swxercise.lg.user.dto.UserDto;
12 import net.ziemers.swxercise.lg.user.service.UserService; 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 * REST-Methoden für die Benutzerverwaltung. 16 * REST-Methoden für die Benutzerverwaltung.
@@ -70,7 +68,7 @@ public class UserViewController { @@ -70,7 +68,7 @@ public class UserViewController {
70 @Consumes(MediaType.APPLICATION_JSON) 68 @Consumes(MediaType.APPLICATION_JSON)
71 @Produces(MediaType.APPLICATION_JSON) 69 @Produces(MediaType.APPLICATION_JSON)
72 public RestResponse createUser(UserDto dto) throws Exception { 70 public RestResponse createUser(UserDto dto) throws Exception {
73 - final Long id = userService.createUser(dto); 71 + userService.createUser(dto);
74 return new RestResponse(); 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,7 +25,7 @@ public class UserViewControllerTest {
25 25
26 private User user; 26 private User user;
27 27
28 - private String actualString; 28 + private RestResponse actual;
29 29
30 @Test 30 @Test
31 public void testJUnitFrameworkReturnsTrue() { 31 public void testJUnitFrameworkReturnsTrue() {
@@ -117,7 +117,7 @@ public class UserViewControllerTest { @@ -117,7 +117,7 @@ public class UserViewControllerTest {
117 when(userService.loginUser(userDto)).thenReturn(true); 117 when(userService.loginUser(userDto)).thenReturn(true);
118 when(userService.getSessionUser()).thenReturn(user); 118 when(userService.getSessionUser()).thenReturn(user);
119 119
120 - actualString = underTest.loginUser(userDto); 120 + actual = underTest.loginUser(userDto);
121 } 121 }
122 122
123 // then 123 // then
@@ -127,8 +127,8 @@ public class UserViewControllerTest { @@ -127,8 +127,8 @@ public class UserViewControllerTest {
127 } 127 }
128 128
129 private void assertLoginSuccess() { 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 }