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

package com.azure.resourcemanager.kusto.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.kusto.fluent.models.ClusterPrincipalAssignmentInner;
import com.azure.resourcemanager.kusto.models.ClusterPrincipalAssignmentListResult;
import com.azure.resourcemanager.kusto.models.ClusterPrincipalRole;
import com.azure.resourcemanager.kusto.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\":\"z\",\"role\":\"AllDatabasesViewer\",\"tenantId\":\"ac\",\"principalType\":\"App\",\"tenantName\":\"osfln\",\"principalName\":\"sfqpteehz\",\"provisioningState\":\"Canceled\",\"aadObjectId\":\"yqrimzin\"},\"id\":\"vswjdk\",\"name\":\"rsoodqxhcrmnoh\",\"type\":\"t\"},{\"properties\":{\"principalId\":\"whdsoifiyip\",\"role\":\"AllDatabasesViewer\",\"tenantId\":\"qwpgrjbzn\",\"principalType\":\"App\",\"tenantName\":\"jxvsnbyxqabn\",\"principalName\":\"cpc\",\"provisioningState\":\"Deleting\",\"aadObjectId\":\"rzafbljjgpbtoqcj\"},\"id\":\"klj\",\"name\":\"vbqid\",\"type\":\"qajzyulpkudjkr\"},{\"properties\":{\"principalId\":\"hbzhfepg\",\"role\":\"AllDatabasesViewer\",\"tenantId\":\"e\",\"principalType\":\"Group\",\"tenantName\":\"ocxscpaierhhbcs\",\"principalName\":\"ummajtjaod\",\"provisioningState\":\"Creating\",\"aadObjectId\":\"bdxkqpxokaj\"},\"id\":\"onpimexgstxg\",\"name\":\"po\",\"type\":\"gmaajrm\"}]}")
                .toObject(ClusterPrincipalAssignmentListResult.class);
        Assertions.assertEquals("z", model.value().get(0).principalId());
        Assertions.assertEquals(ClusterPrincipalRole.ALL_DATABASES_VIEWER, model.value().get(0).role());
        Assertions.assertEquals("ac", model.value().get(0).tenantId());
        Assertions.assertEquals(PrincipalType.APP, 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("z")
                                .withRole(ClusterPrincipalRole.ALL_DATABASES_VIEWER)
                                .withTenantId("ac")
                                .withPrincipalType(PrincipalType.APP),
                            new ClusterPrincipalAssignmentInner()
                                .withPrincipalId("whdsoifiyip")
                                .withRole(ClusterPrincipalRole.ALL_DATABASES_VIEWER)
                                .withTenantId("qwpgrjbzn")
                                .withPrincipalType(PrincipalType.APP),
                            new ClusterPrincipalAssignmentInner()
                                .withPrincipalId("hbzhfepg")
                                .withRole(ClusterPrincipalRole.ALL_DATABASES_VIEWER)
                                .withTenantId("e")
                                .withPrincipalType(PrincipalType.GROUP)));
        model = BinaryData.fromObject(model).toObject(ClusterPrincipalAssignmentListResult.class);
        Assertions.assertEquals("z", model.value().get(0).principalId());
        Assertions.assertEquals(ClusterPrincipalRole.ALL_DATABASES_VIEWER, model.value().get(0).role());
        Assertions.assertEquals("ac", model.value().get(0).tenantId());
        Assertions.assertEquals(PrincipalType.APP, model.value().get(0).principalType());
    }
}
