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

package com.azure.resourcemanager.batch.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.batch.models.AutoUserScope;
import com.azure.resourcemanager.batch.models.AutoUserSpecification;
import com.azure.resourcemanager.batch.models.ElevationLevel;
import com.azure.resourcemanager.batch.models.UserIdentity;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class UserIdentityTests {
    @Test
    public void testDeserialize() {
        UserIdentity model =
            BinaryData
                .fromString("{\"userName\":\"gj\",\"autoUser\":{\"scope\":\"Task\",\"elevationLevel\":\"NonAdmin\"}}")
                .toObject(UserIdentity.class);
        Assertions.assertEquals("gj", model.username());
        Assertions.assertEquals(AutoUserScope.TASK, model.autoUser().scope());
        Assertions.assertEquals(ElevationLevel.NON_ADMIN, model.autoUser().elevationLevel());
    }

    @Test
    public void testSerialize() {
        UserIdentity model =
            new UserIdentity()
                .withUsername("gj")
                .withAutoUser(
                    new AutoUserSpecification()
                        .withScope(AutoUserScope.TASK)
                        .withElevationLevel(ElevationLevel.NON_ADMIN));
        model = BinaryData.fromObject(model).toObject(UserIdentity.class);
        Assertions.assertEquals("gj", model.username());
        Assertions.assertEquals(AutoUserScope.TASK, model.autoUser().scope());
        Assertions.assertEquals(ElevationLevel.NON_ADMIN, model.autoUser().elevationLevel());
    }
}
