ADD:: RemoveFriend method and test in client.userService

This commit is contained in:
Merel Steenbergen
2019-04-01 16:46:01 +02:00
parent 6d37b99c14
commit 12b05f3b73
2 changed files with 26 additions and 0 deletions

View File

@@ -230,6 +230,24 @@ public class UserService {
.encode().toUri(), String.class); .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. * Gets the footprint inputs of the user.
* @param name the username of the current user. * @param name the username of the current user.

View File

@@ -147,6 +147,14 @@ public class UserServiceTest {
userService.addFriend("Eric", "Ceren"); userService.addFriend("Eric", "Ceren");
Mockito.verify(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");
}
} }