|
| 1 | +package eu.solven.kumite.account; |
| 2 | + |
| 3 | +import java.util.Optional; |
| 4 | +import java.util.UUID; |
| 5 | + |
| 6 | +import org.assertj.core.api.Assertions; |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 9 | +import org.mockito.Mockito; |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; |
| 11 | +import org.springframework.test.context.ActiveProfiles; |
| 12 | +import org.springframework.test.context.ContextConfiguration; |
| 13 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 14 | +import org.springframework.web.reactive.function.server.ServerRequest; |
| 15 | +import org.springframework.web.reactive.function.server.ServerResponse; |
| 16 | + |
| 17 | +import eu.solven.kumite.account.fake_player.RandomPlayer; |
| 18 | +import eu.solven.kumite.app.IKumiteSpringProfiles; |
| 19 | +import eu.solven.kumite.app.KumiteServerComponentsConfiguration; |
| 20 | + |
| 21 | +@ExtendWith(SpringExtension.class) |
| 22 | +@ContextConfiguration(classes = { |
| 23 | + |
| 24 | + KumiteServerComponentsConfiguration.class, |
| 25 | + |
| 26 | + AccountSearchHandler.class, |
| 27 | + |
| 28 | +}) |
| 29 | +@ActiveProfiles({ IKumiteSpringProfiles.P_INMEMORY }) |
| 30 | +public class TestKumiteAccountsHandler { |
| 31 | + @Autowired |
| 32 | + AccountSearchHandler accountsSearchHandler; |
| 33 | + |
| 34 | + @Test |
| 35 | + public void testNoFilter() { |
| 36 | + ServerRequest request = Mockito.mock(ServerRequest.class); |
| 37 | + |
| 38 | + Assertions.assertThatThrownBy(() -> accountsSearchHandler.searchAccounts(request).block()) |
| 39 | + .isInstanceOf(IllegalArgumentException.class); |
| 40 | + } |
| 41 | + |
| 42 | + @Test |
| 43 | + public void testUnknownAccount() { |
| 44 | + ServerRequest request = Mockito.mock(ServerRequest.class); |
| 45 | + Mockito.when(request.queryParam("account_id")).thenReturn(Optional.of(UUID.randomUUID().toString())); |
| 46 | + |
| 47 | + // TODO Check the output is empty |
| 48 | + ServerResponse serverResponse = accountsSearchHandler.searchAccounts(request).block(); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void testRandomPlayer() { |
| 53 | + ServerRequest request = Mockito.mock(ServerRequest.class); |
| 54 | + Mockito.when(request.queryParam("account_id")).thenReturn(Optional.of(RandomPlayer.ACCOUNT_ID.toString())); |
| 55 | + |
| 56 | + // TODO Check the output is empty |
| 57 | + accountsSearchHandler.searchAccounts(request).block(); |
| 58 | + } |
| 59 | +} |
0 commit comments