ADD:: RemoveFriend method and test in client.userService
This commit is contained in:
@@ -230,6 +230,24 @@ public class UserService {
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a friend from the friendslist of the user.
|
||||
* @param name the username of the current user.
|
||||
* @param friend the username of the friend you want to remove.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void removeFriend(String name, String friend) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/removeFriend")
|
||||
.queryParam("name", name)
|
||||
.queryParam("friend",friend);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the footprint inputs of the user.
|
||||
* @param name the username of the current user.
|
||||
|
||||
@@ -147,6 +147,14 @@ public class UserServiceTest {
|
||||
userService.addFriend("Eric", "Ceren");
|
||||
Mockito.verify(userService).addFriend("Eric", "Ceren");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeFriendTest() throws Exception {
|
||||
userService.addFriend("Eric", "Ceren");
|
||||
Mockito.verify(userService).addFriend("Eric", "Ceren");
|
||||
userService.removeFriend("Eric", "Ceren");
|
||||
Mockito.verify(userService).removeFriend("Eric", "Ceren");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user