|
|
@ -0,0 +1,46 @@ |
|
|
|
package de.fd.fh.network; |
|
|
|
|
|
|
|
import de.fd.fh.shared.network.messages.RegistrateRequest; |
|
|
|
import feign.Feign; |
|
|
|
import feign.Response; |
|
|
|
import feign.gson.GsonDecoder; |
|
|
|
import feign.gson.GsonEncoder; |
|
|
|
import feign.mock.HttpMethod; |
|
|
|
import feign.mock.MockClient; |
|
|
|
import feign.mock.MockTarget; |
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
|
|
class AccessClientTest |
|
|
|
{ |
|
|
|
private AccessClient client; |
|
|
|
private MockClient mockClient; |
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
void before() |
|
|
|
{ |
|
|
|
mockClient = new MockClient(); |
|
|
|
|
|
|
|
client = Feign.builder() |
|
|
|
.decoder(new GsonDecoder()) |
|
|
|
.encoder(new GsonEncoder()) |
|
|
|
.client(mockClient) |
|
|
|
.target(new MockTarget<>(AccessClient.class)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void testRegistrate() |
|
|
|
{ |
|
|
|
mockClient.ok(HttpMethod.POST, "/accounts/registrate"); |
|
|
|
|
|
|
|
final RegistrateRequest request = RegistrateRequest.of("TestName", "TestPassword"); |
|
|
|
|
|
|
|
final Response result = client.registrate(request); |
|
|
|
|
|
|
|
assertEquals(200, result.status(), "Should return status code 200."); |
|
|
|
|
|
|
|
mockClient.verifyStatus(); |
|
|
|
} |
|
|
|
} |