|
|
@ -3,6 +3,7 @@ package de.fd.fh.network; |
|
|
|
import de.fd.fh.shared.Utils; |
|
|
|
import de.fd.fh.shared.network.messages.ChangeUserRequest; |
|
|
|
import de.fd.fh.shared.network.messages.PlayerResponse; |
|
|
|
import de.fd.fh.shared.network.messages.UserRequest; |
|
|
|
import feign.Feign; |
|
|
|
import feign.Request; |
|
|
|
import feign.gson.GsonDecoder; |
|
|
@ -61,23 +62,46 @@ class UserClientTest |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void getPlayerTest() |
|
|
|
void getShortPlayerTest() |
|
|
|
{ |
|
|
|
mockClient.ok(HttpMethod.GET, "/users/12345", |
|
|
|
"{\n" + |
|
|
|
" \"id\": {\n" + |
|
|
|
" \"id\":\"12345\",\n" + |
|
|
|
" \"name\":\"TestName\"\n" + |
|
|
|
"}"); |
|
|
|
|
|
|
|
final UserRequest response = client.getShortPlayer("TestAuthHeader", "12345"); |
|
|
|
|
|
|
|
assertNotNull(response); |
|
|
|
assertEquals("TestName", response.getName()); |
|
|
|
assertEquals("12345", response.getId()); |
|
|
|
|
|
|
|
final Request sended = mockClient.verifyOne(HttpMethod.GET, "/users/12345"); |
|
|
|
|
|
|
|
assertTrue(sended.headers().get(Utils.AUTHENTICATION_HEADER).stream().findFirst().isPresent()); |
|
|
|
assertEquals("Bearer TestAuthHeader", |
|
|
|
sended.headers().get(Utils.AUTHENTICATION_HEADER).stream().findFirst().get()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void getCurrentPlayerTest() |
|
|
|
{ |
|
|
|
mockClient.ok(HttpMethod.GET, "/users", |
|
|
|
"{\n" + |
|
|
|
" \"id\":\n" + |
|
|
|
" {\n" + |
|
|
|
" \"identifier\":\"12345\"\n" + |
|
|
|
" },\n" + |
|
|
|
" \"name\":\"TestName\"\n" + |
|
|
|
"}"); |
|
|
|
|
|
|
|
final PlayerResponse response = client.getPlayer("TestAuthHeader", "12345"); |
|
|
|
final PlayerResponse response = client.getCurrentPlayer("TestAuthHeader"); |
|
|
|
|
|
|
|
assertNotNull(response); |
|
|
|
assertEquals("TestName", response.getName()); |
|
|
|
assertEquals("12345", response.getId().getIdentifier()); |
|
|
|
|
|
|
|
final Request sended = mockClient.verifyOne(HttpMethod.GET, "/users/12345"); |
|
|
|
final Request sended = mockClient.verifyOne(HttpMethod.GET, "/users"); |
|
|
|
|
|
|
|
assertTrue(sended.headers().get(Utils.AUTHENTICATION_HEADER).stream().findFirst().isPresent()); |
|
|
|
assertEquals("Bearer TestAuthHeader", |
|
|
|