@@ -0,0 +1,2752 @@
+/*%0A * Copyright 2019, TeamDev. All rights reserved.%0A *%0A * Redistribution and use in source and/or binary forms, with or without%0A * modification, must retain the above copyright notice and the following%0A * disclaimer.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR%0A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT%0A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY%0A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0A%0Apackage io.spine.client;%0A%0Aimport io.spine.core.UserId;%0Aimport io.spine.testing.TestValues;%0Aimport io.spine.testing.core.given.GivenUserId;%0Aimport org.junit.jupiter.api.AfterEach;%0Aimport org.junit.jupiter.api.BeforeEach;%0Aimport org.junit.jupiter.api.DisplayName;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport static com.google.common.truth.Truth.assertThat;%0Aimport static org.junit.jupiter.api.Assertions.assertFalse;%0Aimport static org.junit.jupiter.api.Assertions.assertTrue;%0A%0A@DisplayName(%22%60Client%60 should%22)%0Aclass ClientTest %7B%0A%0A    private Client client;%0A%0A    @BeforeEach%0A    void createClient() %7B%0A        int port = TestValues.random(64000, 65000);%0A        client = Client.connectTo(%22localhost%22, port)%0A                       .build();%0A    %7D%0A%0A    @AfterEach%0A    void closeClient() %7B%0A        client.close();%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22be opened upon creation%22)%0A    void opened() %7B%0A        assertTrue(client.isOpen());%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22close upon request%22)%0A    void closing() %7B%0A        client.close();%0A        assertFalse(client.isOpen());%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22have %60shutdown()%60 alias method%22)%0A    void shutdown() %7B%0A        client.shutdown();%0A        assertFalse(client.isOpen());%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22create requests on behalf of a user%22)%0A    void onBehalf() %7B%0A        UserId expected = GivenUserId.generated();%0A        ClientRequest request = client.onBehalfOf(expected);%0A        assertThat(request.user())%0A                .isEqualTo(expected);%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22create requests for a guest user%22)%0A    void guestRequest() %7B%0A        ClientRequest request = client.asGuest();%0A        assertThat(request.user())%0A                .isEqualTo(Client.DEFAULT_GUEST_ID);%0A    %7D%0A%7D%0A

Test opening client request