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

package com.azure.resourcemanager.synapse.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.synapse.fluent.models.ClusterPrincipalAssignmentInner;
import com.azure.resourcemanager.synapse.models.ClusterPrincipalAssignmentListResult;
import com.azure.resourcemanager.synapse.models.ClusterPrincipalRole;
import com.azure.resourcemanager.synapse.models.PrincipalType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ClusterPrincipalAssignmentListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ClusterPrincipalAssignmentListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"principalId\":\"h\",\"role\":\"AllDatabasesAdmin\",\"tenantId\":\"infsz\",\"principalType\":\"User\",\"tenantName\":\"lqdhmrjzr\",\"principalName\":\"cxpjbyypsj\",\"provisioningState\":\"Deleting\",\"aadObjectId\":\"enky\"},\"id\":\"qzvs\",\"name\":\"xfxjelgcmpzqj\",\"type\":\"hhqxuwyvcacoyviv\"},{\"properties\":{\"principalId\":\"izus\",\"role\":\"AllDatabasesAdmin\",\"tenantId\":\"lbscmnlz\",\"principalType\":\"Group\",\"tenantName\":\"uf\",\"principalName\":\"gmvflnwyvqkx\",\"provisioningState\":\"Running\",\"aadObjectId\":\"niylyly\"},\"id\":\"xzutgqztwhghmupg\",\"name\":\"yjtcdxabbujftab\",\"type\":\"nbbklqpxzucafed\"}]}")
                .toObject(ClusterPrincipalAssignmentListResult.class);
        Assertions.assertEquals("h", model.value().get(0).principalId());
        Assertions.assertEquals(ClusterPrincipalRole.ALL_DATABASES_ADMIN, model.value().get(0).role());
        Assertions.assertEquals("infsz", model.value().get(0).tenantId());
        Assertions.assertEquals(PrincipalType.USER, model.value().get(0).principalType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ClusterPrincipalAssignmentListResult model =
            new ClusterPrincipalAssignmentListResult()
                .withValue(
                    Arrays
                        .asList(
                            new ClusterPrincipalAssignmentInner()
                                .withPrincipalId("h")
                                .withRole(ClusterPrincipalRole.ALL_DATABASES_ADMIN)
                                .withTenantId("infsz")
                                .withPrincipalType(PrincipalType.USER),
                            new ClusterPrincipalAssignmentInner()
                                .withPrincipalId("izus")
                                .withRole(ClusterPrincipalRole.ALL_DATABASES_ADMIN)
                                .withTenantId("lbscmnlz")
                                .withPrincipalType(PrincipalType.GROUP)));
        model = BinaryData.fromObject(model).toObject(ClusterPrincipalAssignmentListResult.class);
        Assertions.assertEquals("h", model.value().get(0).principalId());
        Assertions.assertEquals(ClusterPrincipalRole.ALL_DATABASES_ADMIN, model.value().get(0).role());
        Assertions.assertEquals("infsz", model.value().get(0).tenantId());
        Assertions.assertEquals(PrincipalType.USER, model.value().get(0).principalType());
    }
}
