|
@ -1,8 +1,10 @@ |
|
|
package de.fd.fh.network; |
|
|
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.ChangeUserRequest; |
|
|
import de.fd.fh.shared.network.messages.PlayerResponse; |
|
|
import de.fd.fh.shared.network.messages.PlayerResponse; |
|
|
import feign.Feign; |
|
|
import feign.Feign; |
|
|
|
|
|
import feign.Request; |
|
|
import feign.gson.GsonDecoder; |
|
|
import feign.gson.GsonDecoder; |
|
|
import feign.gson.GsonEncoder; |
|
|
import feign.gson.GsonEncoder; |
|
|
import feign.mock.HttpMethod; |
|
|
import feign.mock.HttpMethod; |
|
@ -11,8 +13,7 @@ import feign.mock.MockTarget; |
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull; |
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
|
|
|
class UserClientTest |
|
|
class UserClientTest |
|
|
{ |
|
|
{ |
|
@ -52,6 +53,34 @@ class UserClientTest |
|
|
assertEquals("TestName", response.getName()); |
|
|
assertEquals("TestName", response.getName()); |
|
|
assertEquals("12345", response.getId().getIdentifier()); |
|
|
assertEquals("12345", response.getId().getIdentifier()); |
|
|
|
|
|
|
|
|
mockClient.verifyOne(HttpMethod.POST, "/users"); |
|
|
|
|
|
|
|
|
final Request sended = mockClient.verifyOne(HttpMethod.POST, "/users"); |
|
|
|
|
|
|
|
|
|
|
|
assertTrue(sended.headers().get(Utils.AUTHENTICATION_HEADER).stream().findFirst().isPresent()); |
|
|
|
|
|
assertEquals("Bearer TestAuthHeader", |
|
|
|
|
|
sended.headers().get(Utils.AUTHENTICATION_HEADER).stream().findFirst().get()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void getPlayerTest() |
|
|
|
|
|
{ |
|
|
|
|
|
mockClient.ok(HttpMethod.GET, "/users/12345", |
|
|
|
|
|
"{\n" + |
|
|
|
|
|
" \"id\": {\n" + |
|
|
|
|
|
" \"identifier\":\"12345\"\n" + |
|
|
|
|
|
" },\n" + |
|
|
|
|
|
" \"name\":\"TestName\"\n" + |
|
|
|
|
|
"}"); |
|
|
|
|
|
|
|
|
|
|
|
final PlayerResponse response = client.getPlayer("TestAuthHeader", "12345"); |
|
|
|
|
|
|
|
|
|
|
|
assertNotNull(response); |
|
|
|
|
|
assertEquals("TestName", response.getName()); |
|
|
|
|
|
assertEquals("12345", response.getId().getIdentifier()); |
|
|
|
|
|
|
|
|
|
|
|
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()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |