// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.desktopvirtualization.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.desktopvirtualization.fluent.models.UserSessionInner;
import com.azure.resourcemanager.desktopvirtualization.models.ApplicationType;
import com.azure.resourcemanager.desktopvirtualization.models.SessionState;
import com.azure.resourcemanager.desktopvirtualization.models.UserSessionList;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class UserSessionListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UserSessionList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"objectId\":\"obyu\",\"userPrincipalName\":\"rpqlp\",\"applicationType\":\"Desktop\",\"sessionState\":\"Disconnected\",\"activeDirectoryUserName\":\"qgbdbuta\",\"createTime\":\"2021-06-13T06:16:01Z\"},\"id\":\"btkuwhh\",\"name\":\"hykojoxafnndlpic\",\"type\":\"koymkcd\"},{\"properties\":{\"objectId\":\"kkpwdreqnovvq\",\"userPrincipalName\":\"vljxywsu\",\"applicationType\":\"RemoteApp\",\"sessionState\":\"Active\",\"activeDirectoryUserName\":\"dsytgadgvr\",\"createTime\":\"2021-05-05T10:23:30Z\"},\"id\":\"en\",\"name\":\"qnzarrwl\",\"type\":\"uu\"},{\"properties\":{\"objectId\":\"kacewiipfp\",\"userPrincipalName\":\"ji\",\"applicationType\":\"RemoteApp\",\"sessionState\":\"Disconnected\",\"activeDirectoryUserName\":\"ohqkvpuvksgpls\",\"createTime\":\"2021-01-28T10:41:26Z\"},\"id\":\"ynfs\",\"name\":\"n\",\"type\":\"jphuopxodlqi\"}],\"nextLink\":\"torzih\"}")
                .toObject(UserSessionList.class);
        Assertions.assertEquals("rpqlp", model.value().get(0).userPrincipalName());
        Assertions.assertEquals(ApplicationType.DESKTOP, model.value().get(0).applicationType());
        Assertions.assertEquals(SessionState.DISCONNECTED, model.value().get(0).sessionState());
        Assertions.assertEquals("qgbdbuta", model.value().get(0).activeDirectoryUsername());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-13T06:16:01Z"), model.value().get(0).createTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UserSessionList model =
            new UserSessionList()
                .withValue(
                    Arrays
                        .asList(
                            new UserSessionInner()
                                .withUserPrincipalName("rpqlp")
                                .withApplicationType(ApplicationType.DESKTOP)
                                .withSessionState(SessionState.DISCONNECTED)
                                .withActiveDirectoryUsername("qgbdbuta")
                                .withCreateTime(OffsetDateTime.parse("2021-06-13T06:16:01Z")),
                            new UserSessionInner()
                                .withUserPrincipalName("vljxywsu")
                                .withApplicationType(ApplicationType.REMOTE_APP)
                                .withSessionState(SessionState.ACTIVE)
                                .withActiveDirectoryUsername("dsytgadgvr")
                                .withCreateTime(OffsetDateTime.parse("2021-05-05T10:23:30Z")),
                            new UserSessionInner()
                                .withUserPrincipalName("ji")
                                .withApplicationType(ApplicationType.REMOTE_APP)
                                .withSessionState(SessionState.DISCONNECTED)
                                .withActiveDirectoryUsername("ohqkvpuvksgpls")
                                .withCreateTime(OffsetDateTime.parse("2021-01-28T10:41:26Z"))));
        model = BinaryData.fromObject(model).toObject(UserSessionList.class);
        Assertions.assertEquals("rpqlp", model.value().get(0).userPrincipalName());
        Assertions.assertEquals(ApplicationType.DESKTOP, model.value().get(0).applicationType());
        Assertions.assertEquals(SessionState.DISCONNECTED, model.value().get(0).sessionState());
        Assertions.assertEquals("qgbdbuta", model.value().get(0).activeDirectoryUsername());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-13T06:16:01Z"), model.value().get(0).createTime());
    }
}
