// 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 java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class UserSessionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UserSessionInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"objectId\":\"jswsrmslyz\",\"userPrincipalName\":\"zbchckqqzqioxiy\",\"applicationType\":\"Desktop\",\"sessionState\":\"Unknown\",\"activeDirectoryUserName\":\"nkedyatrwyhqmib\",\"createTime\":\"2021-06-15T22:18:06Z\"},\"id\":\"wit\",\"name\":\"mypyynpcdpu\",\"type\":\"nzgmwznmabik\"}")
                .toObject(UserSessionInner.class);
        Assertions.assertEquals("zbchckqqzqioxiy", model.userPrincipalName());
        Assertions.assertEquals(ApplicationType.DESKTOP, model.applicationType());
        Assertions.assertEquals(SessionState.UNKNOWN, model.sessionState());
        Assertions.assertEquals("nkedyatrwyhqmib", model.activeDirectoryUsername());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-15T22:18:06Z"), model.createTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UserSessionInner model =
            new UserSessionInner()
                .withUserPrincipalName("zbchckqqzqioxiy")
                .withApplicationType(ApplicationType.DESKTOP)
                .withSessionState(SessionState.UNKNOWN)
                .withActiveDirectoryUsername("nkedyatrwyhqmib")
                .withCreateTime(OffsetDateTime.parse("2021-06-15T22:18:06Z"));
        model = BinaryData.fromObject(model).toObject(UserSessionInner.class);
        Assertions.assertEquals("zbchckqqzqioxiy", model.userPrincipalName());
        Assertions.assertEquals(ApplicationType.DESKTOP, model.applicationType());
        Assertions.assertEquals(SessionState.UNKNOWN, model.sessionState());
        Assertions.assertEquals("nkedyatrwyhqmib", model.activeDirectoryUsername());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-15T22:18:06Z"), model.createTime());
    }
}
